typetools / typetools/checker-framework
Error messages involving generic anonymous classes
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 440
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 134
Description
Run the Nullness Checker on:
import org.checkerframework.checker.nullness.qual.Nullable;
interface I<T> {
void foo(T p);
}
class Foo {
void foo(I<@Nullable Object> p) {}
void bar() {
foo(new I<Object>() {
public void foo(Object p) {}
});
}
}
You will get:
Bug.java:10: error: [argument.type.incompatible] incompatible types in argument.
foo(new I<Object>() {
^
found : Foo.@Initialized @NonNull <anonymous Foo$1>
required: @Initialized @NonNull I<@Initialized @Nullable Object>
1 error
The <anonymous Foo$1> is making it hard to see that the type argument mismatches.
If you change the example to have a Java type mismatch, e.g. to:
void foo(I<String> p) {}
void bar() {
foo(new I<Object>() {
you get:
Bug.java:10: error: incompatible types: <anonymous I<Object>> cannot be converted to I<String>
That is, instead of Foo$1 you see the more useful I<Object>.
We should do the same thing for the Checker Framework.
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 by running the supplied Java example with the Nullness Checker and compare its diagnostic with javac's output for the modified example. Trace the diagnostic formatting for anonymous classes; done means the Checker Framework reports the implemented interface and its type argument instead of the generated Foo$1 name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100