checker-framework icon indicating copy to clipboard operation
checker-framework copied to clipboard

Incorrect enclosing types

Open smillst opened this issue 4 years ago • 0 comments

The following code should issue an error, but doesn't.

import org.checkerframework.checker.nullness.qual.Nullable;

public class Issue4853B {
  interface Interface<Q> {}

  static class MyClass<T> {
    class InnerMyClass implements Interface<T> {}
  }

  abstract static class SubMyClass extends MyClass<@Nullable String> {
    protected void f() {
      // :: error: (assignment)
      Interface<@Nullable String> callback = method();  // missing error here.
    }
     abstract InnerMyClass method();
  }
}

The problem is the return type of method is MyClass<@NonNull String>.InnerMyClass where @NonNull is defaulted. Instead of defaulting, the enclosing type of InnerMyClass should be computed from the enclosing type of this. I would guess there are other place where the Checker Framework isn't computing the correct enclosing type.

smillst avatar Aug 11 '21 20:08 smillst