typetools / checker-framework-inference

Inference of pluggable types for Java
10 stars 33 forks source link

Inference error in scenario involving enums and generics #6

Open jthaine opened 8 years ago

jthaine commented 8 years ago

What steps will reproduce the problem? Enable and run the following test: testdata/sparta-source/Issue6.java

What is the expected output? What do you see instead? The test should pass. Instead, an exception is thrown:

[junit] INFO: - compiler.err.proc.messager: Unexpected AnnotatedTypeMirror with no primary annotation!
[junit] toSearch=Enum<capture#787 of ? extends Enum<capture#787 of ?>>
[junit] top=@checkers.inference.quals.VarAnnot
[junit] source=Enum<capture#787 of ? extends Enum<capture#787 of ?>>
[junit] Compilation unit: /Users/javier/sparta3/checker-framework-inference/testdata/sparta-source/Issue6.java
[junit] Exception: java.lang.Throwable; Stack trace: org.checkerframework.framework.source.SourceChecker.errorAbort(SourceChecker.java:669)
[junit] org.checkerframework.javacutil.ErrorReporter.errorAbort(ErrorReporter.java:28)
[junit] org.checkerframework.framework.util.AnnotatedTypes.findEffectiveAnnotationInHierarchy(AnnotatedTypes.java:1682)
[junit] org.checkerframework.framework.util.AnnotatedTypes.findEffectiveAnnotationInHierarchy(AnnotatedTypes.java:1638)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.subtypeAndCompare(StructuralEqualityComparer.java:349)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitTypevar_Typevar(StructuralEqualityComparer.java:300)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitTypevar_Typevar(StructuralEqualityComparer.java:36)
[junit] org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:598)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:92)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.checkOrAreEqual(StructuralEqualityComparer.java:163)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.areAllEqual(StructuralEqualityComparer.java:145)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitTypeArgs(StructuralEqualityComparer.java:237)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitDeclared_Declared(StructuralEqualityComparer.java:214)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitDeclared_Declared(StructuralEqualityComparer.java:36)
[junit] org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:302)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:92)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitWildcard_Wildcard(StructuralEqualityComparer.java:383)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitWildcard_Wildcard(StructuralEqualityComparer.java:36)
[junit] org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:646)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:92)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.checkOrAreEqual(StructuralEqualityComparer.java:163)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.areAllEqual(StructuralEqualityComparer.java:145)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitTypeArgs(StructuralEqualityComparer.java:237)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitDeclared_Declared(StructuralEqualityComparer.java:214)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.visitDeclared_Declared(StructuralEqualityComparer.java:36)
[junit] org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:302)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.areEqual(StructuralEqualityComparer.java:75)
[junit] org.checkerframework.framework.type.StructuralEqualityComparer.areEqualInHierarchy(StructuralEqualityComparer.java:101)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.areEqualInHierarchy(DefaultTypeHierarchy.java:359)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.isContainedBy(DefaultTypeHierarchy.java:390)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.compareTypeArgs(DefaultTypeHierarchy.java:503)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.visitTypeArgs(DefaultTypeHierarchy.java:478)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:447)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.visitDeclared_Declared(DefaultTypeHierarchy.java:51)
[junit] org.checkerframework.framework.util.AtmCombo.accept(AtmCombo.java:302)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:220)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:170)
[junit] org.checkerframework.framework.type.DefaultTypeHierarchy.isSubtype(DefaultTypeHierarchy.java:151)
[junit] checkers.inference.InferenceVisitor.commonAssignmentCheck(InferenceVisitor.java:535)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.commonAssignmentCheck(BaseTypeVisitor.java:1858)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.checkArguments(BaseTypeVisitor.java:2216)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.visitMethodInvocation(BaseTypeVisitor.java:931)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.visitMethodInvocation(BaseTypeVisitor.java:173)
[junit] com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1477)
[junit] com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:273)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:173)
[junit] com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:243)
[junit] com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1302)
[junit] com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:273)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:173)
[junit] com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
[junit] com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:162)
[junit] com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:918)
[junit] com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:273)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:173)
[junit] com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:81)
[junit] com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:144)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:507)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.visitMethod(BaseTypeVisitor.java:173)
[junit] com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:800)
[junit] com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:273)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.scan(BaseTypeVisitor.java:173)
[junit] com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:81)
[junit] com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
[junit] com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:99)
[junit] com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:133)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:323)
[junit] org.checkerframework.common.basetype.BaseTypeVisitor.visitClass(BaseTypeVisitor.java:173)
[junit] com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:720)
[junit] com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:50)
[junit] org.checkerframework.framework.source.SourceVisitor.visit(SourceVisitor.java:70)
[junit] org.checkerframework.framework.source.SourceChecker.typeProcess(SourceChecker.java:889)
[junit] org.checkerframework.common.basetype.BaseTypeChecker.typeProcess(BaseTypeChecker.java:452)
[junit] org.checkerframework.javacutil.AbstractTypeProcessor$AttributionTaskListener.finished(AbstractTypeProcessor.java:205)
[junit] com.sun.tools.javac.api.ClientCodeWrapper$WrappedTaskListener.finished(ClientCodeWrapper.java:681)
[junit] com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:111)
[junit] com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1342)
[junit] com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1296)
[junit] com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:901)
[junit] com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:860)
[junit] com.sun.tools.javac.main.Main.compile(Main.java:523)
[junit] com.sun.tools.javac.main.Main.compile(Main.java:381)
[junit] com.sun.tools.javac.main.Main.compile(Main.java:370)
[junit] com.sun.tools.javac.main.Main.compile(Main.java:361)
[junit] checkers.inference.CheckerFrameworkUtil.invokeCheckerFramework(CheckerFrameworkUtil.java:12)
[junit] checkers.inference.InferenceMain.startCheckerFramework(InferenceMain.java:173)
[junit] checkers.inference.InferenceMain.run(InferenceMain.java:135)
[junit] checkers.inference.InferenceMain.main(InferenceMain.java:107)

What version of the product are you using? 17f60a462162a on branch: master

smillst commented 8 years ago

Also crashes on 2cdf7bc2f3

smillst commented 8 years ago

Javier ran the Nullness Checker on this code and it did not crash. So, this must be some bug in the way that inference is using isSubtype.