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
{{ message }}
Repository navigation
Nullness Checker: spurious return.type.incompatible for a local array returned from an implicit lambda inside a generic method call #2134
The Nullness Checker reports a false-positive return.type.incompatible on a block-bodied lambda that assigns a local variable and returns it, when the lambda is passed as an argument to a generic method whose type argument is inferred. javac alone compiles it.
error: [return.type.incompatible] incompatible types in return.
return of(
^
type of expression: @NonNull Object @Nullable []
method return type: @NonNull Object @NonNull []
1 error
The lambda parameter l is not used in the body at all, so this is not related to #2084. x is a fresh, non-null array (new Object[0]), so the refined type of x at the return x; statement should be @NonNull Object @NonNull [], not @Nullable.
Variant
Result
as above
false positive
same lambda body, but as a plain field initializer (Supplier<Object[]> s = () -> { Object[] x = new Object[0]; return x; };), not an argument to a generic method
ok
So the false positive appears specific to a lambda's block body being checked while it's the argument to a generic method invocation with its own type argument inference, not to block-bodied lambdas returning locals in general.
Expected: no error.
Environment: master 3591d45bec, JDK 25. Confirmed present identically on both master and the #2084 fix branch (unaffected by that fix).
Activity