Skip to content

nestedAnnotationsForMethods on return value dropped in type inference #1942

Description

@jeffrey-easyesi

The new JDK models annotate some methods as returning CompletableFuture<@Nullable Void>. But when used in an argument from which a type variable is inferred, the model's @Nullable gets dropped.

For example:

// allowed
CompletableFuture<@Nullable Void> f1 = CompletableFuture.allOf();
// [NullAway] incompatible types: CompletableFuture<Void> cannot be converted to CompletableFuture<@Nullable Void>
CompletableFuture<@Nullable Void> f2 = Optional.of(CompletableFuture.allOf()).get();

Activity

  1. self-assigned this
    on Oct 9, 2026
  2. msridhar commented on Oct 9, 2026

    @msridhar
    Contributor

    Thanks for the report! @subhramit is working on a deeper fix for this type of issue by addressing #1585. Rather than adding another hack for this specific case, I think we'll wait to see if that better fix works out

  3. subhramit commented on Oct 9, 2026

    @subhramit
    Contributor

    Ack @jeffrey-easyesi, thanks for the report.
    Expect this to be fixed in an upcoming release.

  4. added a commit that references this issue on Oct 9, 2026
  5. added
    jspecify
    on Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

false positivejdk-modelsjspecify

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions