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

Regression in 3.21.2: pattern matching for instanceof crashes with AsSuperVisitor: type is not an erased subtype of supertype #5039

Closed
eikemeier opened this issue Feb 2, 2022 · 0 comments · Fixed by #5040
Assignees
Labels
Milestone

Comments

@eikemeier
Copy link

Example repository at https://github.com/eikemeier/checker-framework-jdk17

  public boolean equals(@Nullable Object o) {
    return o == this
        || o instanceof Greeting that
        && Objects.equals(name, that.name);
  }

crashes on JDK17 with version 3.21.2:

error: AsSuperVisitor: type is not an erased subtype of supertype.
  type: Object
  superType: Greeting
  ; The Checker Framework crashed.  Please report the crash.
  Compilation unit: src/main/java/com/example/hello_world/Greeting.java
  Last visited tree at line 21 column 12:
          || o instanceof Greeting that
  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:145)
          at org.checkerframework.framework.type.AsSuperVisitor.visitDeclared_Declared(AsSuperVisitor.java:333)
          at org.checkerframework.framework.type.AsSuperVisitor.visitDeclared_Declared(AsSuperVisitor.java:29)
          at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:311)
          at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visit(AbstractAtmComboVisitor.java:65)
          at org.checkerframework.framework.type.AsSuperVisitor.visit(AsSuperVisitor.java:98)
          at org.checkerframework.framework.type.AsSuperVisitor.asSuper(AsSuperVisitor.java:80)
          at org.checkerframework.framework.util.AnnotatedTypes.asSuper(AnnotatedTypes.java:113)
          at org.checkerframework.framework.util.AnnotatedTypes.castedAsSuper(AnnotatedTypes.java:141)
          at org.checkerframework.framework.type.DefaultTypeHierarchy.visitTypeArgs(DefaultTypeHierarchy.java:476)
          at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:448)
          at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:45)
          at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:311)
          at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:155)
          at org.checkerframework.checker.nullness.KeyForAnnotatedTypeFactory$KeyForTypeHierarchy.isSubtype(KeyForAnnotatedTypeFactory.java:152)
          at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:131)
          at org.checkerframework.common.basetype.BaseTypeVisitor.visitInstanceOf(BaseTypeVisitor.java:2395)
          at org.checkerframework.common.basetype.BaseTypeVisitor.visitInstanceOf(BaseTypeVisitor.java:180)

The program compiles with version 3.21.1. Tested on macOS and Linux.

@smillst smillst self-assigned this Feb 2, 2022
@mernst mernst added the crash label Feb 2, 2022
@mernst mernst added this to the Critical milestone Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants