Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsSuperVisitor: type is not an erased subtype of supertype. #6393

Closed
cushon opened this issue Jan 11, 2024 · 1 comment · Fixed by #6394
Closed

AsSuperVisitor: type is not an erased subtype of supertype. #6393

cushon opened this issue Jan 11, 2024 · 1 comment · Fixed by #6394
Assignees

Comments

@cushon
Copy link
Contributor

cushon commented Jan 11, 2024

import java.io.IOException;
import java.io.Serializable;
import org.checkerframework.checker.nullness.qual.Nullable;

class T {

  public static class A implements Serializable {}

  static class G {
    public <T extends Serializable> @Nullable T g(Class<? super T> e) throws IOException {
      throw new AssertionError();
    }
  }

  static <T extends A> T f(Class<? super T> x, G y) {
    A z;
    try {
      z = y.g(x);
    } catch (IOException e) {
      throw new IllegalStateException(e);
    }
    return (T) z;
  }
}
$ ./checker-framework-3.42.0/checker/bin/javac -processor nullness T.java   |& less
error: AsSuperVisitor: type is not an erased subtype of supertype.
  type: Object
  superType: A
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.42.0.
  Compilation unit: T.java
  Last visited tree at line 18 column 7:
        z = y.g(x);
  Exception: java.lang.Throwable; java.lang.Throwable
        at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:34)
        at org.checkerframework.framework.type.AsSuperVisitor.errorTypeNotErasedSubtypeOfSuperType(AsSuperVisitor.java:148)
        at org.checkerframework.framework.type.AsSuperVisitor.visitDeclared_Declared(AsSuperVisitor.java:338)
        at org.checkerframework.framework.type.AsSuperVisitor.visitDeclared_Declared(AsSuperVisitor.java:30)
        at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:312)
        at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visit(AbstractAtmComboVisitor.java:34)
        at org.checkerframework.framework.type.AsSuperVisitor.visit(AsSuperVisitor.java:107)
        at org.checkerframework.framework.type.AsSuperVisitor.asSuper(AsSuperVisitor.java:88)
        at org.checkerframework.framework.util.AnnotatedTypes.asSuper(AnnotatedTypes.java:117)
@smillst
Copy link
Member

smillst commented Jan 12, 2024

This passes in master. I've added the test case: #6394.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants