eisop / checker-framework

Pluggable type-checking for Java
https://eisop.github.io/
Other
15 stars 16 forks source link

Don't erase the type argument of receiver #793

Open Ao-senXiong opened 1 week ago

Ao-senXiong commented 1 week ago

for this code

public class Test<T> {
   Test <T> a;

    Test() {
        a = new Test<>();
        foo();
    }

    void foo() {}
}

error message before the change:

Test.java:6: error: [method.invocation.invalid] call to foo() not allowed on the given receiver.
        foo();
           ^
  found   : @UnderInitialization(Test.class) Test</*RAW*/>
  required: @Initialized Test</*RAW*/>

error message after the change:

Test.java:6: error: [method.invocation.invalid] call to foo() not allowed on the given receiver.
        foo();
           ^
  found   : @UnderInitialization(Test.class) Test<T extends @Initialized Object>
  required: @Initialized Test<T extends @Initialized Object>
1 error
wmdietl commented 1 week ago

Maybe this would fix #104? Can you try with tests from that issue?

Ao-senXiong commented 1 week ago

Maybe this would fix #104? Can you try with tests from that issue?

Just checked, this did not fix it.

Ao-senXiong commented 2 days ago

This is a partial fix, look into the error message in subclass and #104