fix: solve JDT Null Analysis Mismatch Error#1429
fix: solve JDT Null Analysis Mismatch Error#1429rubenporras merged 1 commit intoeclipse-lsp4e:mainfrom
Conversation
| static List<@Nullable ? extends WorkspaceSymbol> eitherToWorkspaceSymbols( | ||
| final @Nullable Either<List<? extends SymbolInformation>, List<@Nullable ? extends WorkspaceSymbol>> source) { | ||
| return source == null // | ||
| ? List.of() |
There was a problem hiding this comment.
Not for me, then I get the marker:
Null type mismatch (type annotations): required '@nonnull List<@nullable ? extends WorkspaceSymbol>' but this expression has type '@nonnull List<@nonnull WorkspaceSymbol>'
It looks to me that the JDT does not like than one is List.of() is guaranteed to be not null, and the other expression is Nullable.
I tried NullSafetyHelper.castNullable(List.of()) which also causes the JDT to complain.
It looks to me like a litimation of the JDT null analysis, or at least I do not understand why it is complaining.
There was a problem hiding this comment.
I'll check if this can be solved via a change to the external null annotations
There was a problem hiding this comment.
@rubenporras List.of has the contract that it only returns lists with non-null elements. But you can replace List.of with Collections.emptyList() and it should work.
There was a problem hiding this comment.
Is this because of the external null annotations? The signature in java looks equal to me
There was a problem hiding this comment.
Yes the EEAs make the actual contract of List.of visible.
No description provided.