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

error: StructuralEqualityComparer: unexpected combination: type #6856

Closed
theosotr opened this issue Oct 11, 2024 · 1 comment · Fixed by #6857
Closed

error: StructuralEqualityComparer: unexpected combination: type #6856

theosotr opened this issue Oct 11, 2024 · 1 comment · Fixed by #6857

Comments

@theosotr
Copy link

Command

javac -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
  -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \
  -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED \
-processor org.checkerframework.checker.nullness.NullnessChecker \
-cp checker/dist/checker.jar -Aignorejdkastub Test.java

File

import java.util.Collections;

public class Test {
  static void test (Class<String> p) {
      var x = Collections.checkedCollection((Collections.emptyList()), p);
  }
}

Actual behavior

error: StructuralEqualityComparer: unexpected combination:  type: [TYPEVAR class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable] E extends Object  supertype: [DECLARED class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType] String
    visitHistory = org.checkerframework.framework.type.StructuralEqualityVisitHistory@67cd193d
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.48.1-SNAPSHOT, branch master, 2024-10-11, commit f503ebc, dirty=true. 
  Compilation unit: Test.java
  Last visited tree at line 5 column 15:
        var x = Collections.checkedCollection((Collections.emptyList()), p);
  Exception: java.lang.Throwable; java.lang.Throwable
  	at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:26)
  	at org.checkerframework.framework.type.visitor.AtmComboVisitor.defaultAction(AtmComboVisitor.java:66)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:49)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:30)
  	at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visitTypevar_Declared(AbstractAtmComboVisitor.java:512)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.visitTypevar_Declared(StructuralEqualityComparer.java:387)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.visitTypevar_Declared(StructuralEqualityComparer.java:30)
  	at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:589)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:84)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.areEqualInHierarchy(StructuralEqualityComparer.java:94)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.areEqualInHierarchy(DefaultTypeHierarchy.java:339)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedBy(DefaultTypeHierarchy.java:415)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedMany(DefaultTypeHierarchy.java:645)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitTypeArgs(DefaultTypeHierarchy.java:609)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:542)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:49)
  	at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:313)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:259)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:137)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3147)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3122)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.checkArguments(BaseTypeVisitor.java:3692)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethodInvocation(BaseTypeVisitor.java:1852)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethodInvocation(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1832)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitVariable(TreeScanner.java:243)
  	at org.checkerframework.framework.source.SourceVisitor.visitVariable(SourceVisitor.java:104)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:1624)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1040)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:272)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1104)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:224)
  	at org.checkerframework.framework.source.SourceVisitor.visitMethod(SourceVisitor.java:110)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processMethodTree(BaseTypeVisitor.java:1067)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:963)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:948)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:203)
  	at org.checkerframework.framework.source.SourceVisitor.visitClass(SourceVisitor.java:98)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processClassTree(BaseTypeVisitor.java:612)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:558)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:855)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:66)
  	at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:86)
  	at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1347)
  	at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1268)
  	at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:188)
  	at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:876)
  	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:133)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1443)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1400)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:976)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
  	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
  	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
error: StructuralEqualityComparer: unexpected combination:  type: [TYPEVAR class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedTypeVariable] E extends @Initialized @Nullable Object  supertype: [DECLARED class org.checkerframework.framework.type.AnnotatedTypeMirror$AnnotatedDeclaredType] @Initialized @NonNull String
    visitHistory = org.checkerframework.framework.type.StructuralEqualityVisitHistory@258291de
  ; The Checker Framework crashed.  Please report the crash.  Version: Checker Framework 3.48.1-SNAPSHOT, branch master, 2024-10-11, commit f503ebc, dirty=true. 
  Compilation unit: Test.java
  Last visited tree at line 5 column 15:
        var x = Collections.checkedCollection((Collections.emptyList()), p);
  Exception: java.lang.Throwable; java.lang.Throwable
  	at org.checkerframework.javacutil.BugInCF.<init>(BugInCF.java:26)
  	at org.checkerframework.framework.type.visitor.AtmComboVisitor.defaultAction(AtmComboVisitor.java:66)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:49)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.defaultAction(StructuralEqualityComparer.java:30)
  	at org.checkerframework.framework.type.visitor.AbstractAtmComboVisitor.visitTypevar_Declared(AbstractAtmComboVisitor.java:512)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.visitTypevar_Declared(StructuralEqualityComparer.java:387)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.visitTypevar_Declared(StructuralEqualityComparer.java:30)
  	at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:589)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:84)
  	at org.checkerframework.framework.type.StructuralEqualityComparer.areEqualInHierarchy(StructuralEqualityComparer.java:94)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.areEqualInHierarchy(DefaultTypeHierarchy.java:339)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedBy(DefaultTypeHierarchy.java:415)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedMany(DefaultTypeHierarchy.java:645)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitTypeArgs(DefaultTypeHierarchy.java:609)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:542)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:49)
  	at org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:313)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:259)
  	at org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:137)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3147)
  	at org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:237)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:3122)
  	at org.checkerframework.checker.nullness.NullnessVisitor.commonAssignmentCheck(NullnessVisitor.java:218)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.checkArguments(BaseTypeVisitor.java:3692)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethodInvocation(BaseTypeVisitor.java:1852)
  	at org.checkerframework.checker.nullness.NullnessVisitor.visitMethodInvocation(NullnessVisitor.java:546)
  	at org.checkerframework.checker.nullness.NullnessVisitor.visitMethodInvocation(NullnessVisitor.java:67)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1832)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitVariable(TreeScanner.java:243)
  	at org.checkerframework.framework.source.SourceVisitor.visitVariable(SourceVisitor.java:104)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitVariable(BaseTypeVisitor.java:1624)
  	at org.checkerframework.checker.initialization.InitializationVisitor.visitVariable(InitializationVisitor.java:158)
  	at org.checkerframework.checker.initialization.InitializationVisitor.visitVariable(InitializationVisitor.java:51)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1040)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:272)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1104)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:224)
  	at org.checkerframework.framework.source.SourceVisitor.visitMethod(SourceVisitor.java:110)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processMethodTree(BaseTypeVisitor.java:1067)
  	at org.checkerframework.checker.initialization.InitializationVisitor.processMethodTree(InitializationVisitor.java:293)
  	at org.checkerframework.checker.nullness.NullnessVisitor.processMethodTree(NullnessVisitor.java:528)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:963)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:948)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
  	at org.checkerframework.framework.source.SourceVisitor.scan(SourceVisitor.java:92)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:408)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:203)
  	at org.checkerframework.framework.source.SourceVisitor.visitClass(SourceVisitor.java:98)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.processClassTree(BaseTypeVisitor.java:612)
  	at org.checkerframework.checker.initialization.InitializationVisitor.processClassTree(InitializationVisitor.java:246)
  	at org.checkerframework.checker.nullness.NullnessVisitor.processClassTree(NullnessVisitor.java:592)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:558)
  	at org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:189)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:855)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:66)
  	at org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:86)
  	at org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:1347)
  	at org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:188)
  	at jdk.compiler/com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:876)
  	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:133)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1443)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1400)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:976)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
  	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
  	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
2 errors
@smillst
Copy link
Member

smillst commented Oct 11, 2024

Thanks for reporting! This example no longer crashes with master, but it does produce a false positive:

Issue6856.java:4: error: [type.arguments.not.inferred] Could not infer type arguments for Collections.checkedCollection
      var x = Collections.checkedCollection((Collections.emptyList()), p);
                                           ^
  unsatisfiable constraint: @UnknownKeyFor String <: E[ extends @UnknownKeyFor Object super @KeyForBottom Void]
1 error

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

Successfully merging a pull request may close this issue.

2 participants