typetools / typetools/checker-framework
Field with @RequiresNonNull + @MonotonicNonNull is treated as nullable inside lambda
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
class Require {
@MonotonicNonNull String s;
@RequiresNonNull("s")
Supplier<String> s() {
return () -> s;
}
interface Supplier<T> {
T get();
}
}
Actual:
$ ./checker-framework-3.43.0/checker/bin/javac -processor nullness Require.java
Require.java:9: error: [return] incompatible types in return.
return () -> s;
^
type of expression: @Initialized @MonotonicNonNull String
method return type: @Initialized @NonNull String
1 error
Expected:
No error: Even though the lambda may run later, s is not only known to be non-null initially but is also known to remain so because of @MonotonicNonNull.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Require.java reproducer and run it through the nullness processor using the command shown in the issue. Trace how @RequiresNonNull and @MonotonicNonNull information is handled across the lambda; done means the example compiles without the reported return-type error and has regression coverage.
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
- 45/100