typetools / typetools/checker-framework

Array element type should not be inferred as @Poly*

Open
#653 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
1.1k
Forks
440
Avg merge
1d 12h
Merged PRs (30d)
134

Description

Consider the code in file checker-framework/checker/tests/nullness/Issue653.java.

An expression

  new String[] {myNonNullString}

is inferred to be of type

  @PolyNull String []

when used in a context where that type is expected.

The expression should be inferred to be of type

  @NonNull String []

instead.

More generally, @PolyNull should not be considered a type itself -- it's really a type variable.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with checker-framework/checker/tests/nullness/Issue653.java and inspect how the array initializer is inferred when it contains myNonNullString. Trace the handling of @PolyNull as a type variable in the relevant type-inference code. Done means the expression is inferred as @NonNull String[] rather than @PolyNull String[] in this context, with the regression covered by the issue test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.