You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MNN.java:10: error: [monotonic.type.incompatible] cannot assign org.checkerframework.checker.nullness.qual.MonotonicNonNull to org.checkerframework.checker.nullness.qual.MonotonicNonNull (monotonic type).
this.foo(field);
^
full type found: @Initialized @MonotonicNonNull Object
1 error
The read of field has type @MonotonicNonNull, which is then the inferred type argument type for foo.
However, when the checker then checks whether the argument type is a subtype of the parameter type, the rule for @MonotonicNonNull prevents that the @MonotonicNonNull is assigned to itself.
I think in general the type of the field read this.field should be @Nullable, not @MonotonicNonNull.
When making the method type argument explicitly @Nullable, the problem goes away.
The alternative would be to change method type argument inference to avoid inferring certain annotations, in particular @MonotonicNonNull.
For @MonotonicNonNull I think I would first try changing the type of the read to @Nullable; if we can already think of other cases where avoiding certain annotations would be required, we should add it as another constraint for #979.
The text was updated successfully, but these errors were encountered:
Run the Nullness Checker on the following example:
We get:
The read of
field
has type@MonotonicNonNull
, which is then the inferred type argument type forfoo
.However, when the checker then checks whether the argument type is a subtype of the parameter type, the rule for
@MonotonicNonNull
prevents that the@MonotonicNonNull
is assigned to itself.I think in general the type of the field read
this.field
should be@Nullable
, not@MonotonicNonNull
.When making the method type argument explicitly
@Nullable
, the problem goes away.The alternative would be to change method type argument inference to avoid inferring certain annotations, in particular
@MonotonicNonNull
.For
@MonotonicNonNull
I think I would first try changing the type of the read to@Nullable
; if we can already think of other cases where avoiding certain annotations would be required, we should add it as another constraint for #979.The text was updated successfully, but these errors were encountered: