typetools / typetools/checker-framework
@NotOnlyInitialized ignored in inline initialization scenarios
Open
Nobody has claimed this yet.
bug
False Positive (false warning or imprecision)
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
@NotOnlyInitialized seems to fall short in cases of inline initialization.
import org.checkerframework.checker.initialization.qual.NotOnlyInitialized;
import org.checkerframework.checker.initialization.qual.UnderInitialization;
class A {
static interface I {}
static class B {
B(@UnderInitialization I stuff) { }
}
static class Fails implements I {
@NotOnlyInitialized B bar = new B(this);
// a.java:15: error: [assignment.type.incompatible] incompatible types in assignment.
// @NotOnlyInitialized B bar = new B(this);
// ^
// found : @UnderInitialization(A.B.class) @NonNull B
// required: @Initialized @NonNull B
}
static class works implements I {
@NotOnlyInitialized B bar;
{
bar = new B(this); // works
}
}
}
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 Java reproducer in the issue and compare the inline field initializer with the equivalent initializer block. Trace how the initialization checker handles @NotOnlyInitialized assignments involving new B(this); done means the inline form receives the intended treatment without regressing the working form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100