Skip to content

fix: solve JDT Null Analysis Mismatch Error#1429

Merged
rubenporras merged 1 commit intoeclipse-lsp4e:mainfrom
rubenporras:jdtNull
Nov 27, 2025
Merged

fix: solve JDT Null Analysis Mismatch Error#1429
rubenporras merged 1 commit intoeclipse-lsp4e:mainfrom
rubenporras:jdtNull

Conversation

@rubenporras
Copy link
Copy Markdown
Contributor

No description provided.

@rubenporras rubenporras requested a review from sebthom November 26, 2025 11:09
static List<@Nullable ? extends WorkspaceSymbol> eitherToWorkspaceSymbols(
final @Nullable Either<List<? extends SymbolInformation>, List<@Nullable ? extends WorkspaceSymbol>> source) {
return source == null //
? List.of()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does List.of not work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check if this can be solved via a change to the external null annotations

Copy link
Copy Markdown
Member

@sebthom sebthom Nov 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because of the external null annotations? The signature in java looks equal to me

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the EEAs make the actual contract of List.of visible.

@rubenporras rubenporras changed the title fix: solve JDT Null Analysis Missmatch Error fix: solve JDT Null Analysis Mismatch Error Nov 27, 2025
@rubenporras rubenporras merged commit 52b9f92 into eclipse-lsp4e:main Nov 27, 2025
11 checks passed
@rubenporras rubenporras deleted the jdtNull branch November 27, 2025 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants