ceylon / ceylon-spec

DEPRECATED
Apache License 2.0
108 stars 34 forks source link

Support Java nullability annotations #1424

Closed lucaswerkmeister closed 8 years ago

lucaswerkmeister commented 8 years ago

Several frameworks have attempted to improve on Java’s nullability support by introducing annotations for something being @Nullable or @NotNull/@NonNull/@Nonnull. We should recognize these annotations, and warn or error if:

Behavior on unannotated elements should not change. Some frameworks define only one annotation because the other is the default, but we can’t detect that.

Test cases / examples: https://gist.github.com/lucaswerkmeister/07556232a9bd060dd593

Annotations to support (suggestion, potentially incomplete; list from Kotlin):

Alternatively, we could assume that any annotation named @Nullable, @NotNull, @NonNull, @Nonnull has this meaning. I think that’s probably a reasonable assumption.

jvasileff commented 8 years ago

Minor implementation note: assigning null returned from a function marked @NotNull to a Ceylon optional should not result in a runtime error.

And we probably shouldn't have compile time errors for:

if (exists x = getRequired()) { ... }
lucaswerkmeister commented 8 years ago

Moved to ceylon/ceylon-model#8.