typetools / typetools/checker-framework

Allow dataflow refinement of wildcard bounds

Open
#470 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The checker fails to infer a non-null type for the wildcard in List<?> lx = ...:

import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;

abstract class Test {
  abstract List<? extends @NonNull Object> getList();
  void f() {
    List<?> lx = getList();
    for (Object l : lx) {
      l.toString();
    }
  }
}
$ ~/jsr308/checker-framework-1.9.5/checker/bin/javac -processor org.checkerframework.checker.nullness.NullnessChecker -version Test.java
javac 1.8.0-jsr308-1.9.5
Test.java:9: error: [dereference.of.nullable] dereference of possibly-null reference l
      l.toString();
      ^
1 error

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 by reproducing the failure in Test.java with the NullnessChecker command shown in the issue. Trace how wildcard bounds and dataflow refinement are handled, then add a regression test showing that iterating List<?> obtained from List<? extends @NonNull Object> permits l.toString() without a nullable-reference diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.