typetools / typetools/checker-framework
Constructor returns @UnderInitialization object with @UnderInitialization argument
Open
@mernst is already working on this.
Since May 3, 2023.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Not sure if this is related to #409 but the setup is similar.
When a constructor for a class Bar takes a @UnderInitialization object as argument, it's return type somehow becomes @UnderInitialization(Bar.class) Bar. This sometimes cause false positive errors.
Command
checker/bin/javac -processor nullness Foo.java
Input
File Foo.java
final class Foo {
private static class Bar {
private Bar(@UnderInitialization Foo foo) {}
}
public Foo() {
bar = new Bar(this);
}
private Bar bar;
}
Output
Foo.java:12: error: [assignment] incompatible types in assignment.
bar = new Bar(this);
^
found : @UnderInitialization(com.google.Foo.Bar.class) @NonNull Bar
required: @Initialized @NonNull Bar
1 error
Expectation
Return type of a constructor should always be @Initialized.
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.
Assessment
This issue has not been assessed yet.