Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Maybe, it's related to GROOVY-10674
I have the following code
class A<D, I> {} class B { <T extends A<Character, Boolean>, X extends T>void m(T p1, X p2) {} } public class Test { void test() { A<Character, Boolean> x = null; (new B()).m(x, new A<>()); } }
Actual behavior
>>> a serious error occurred: BUG! exception in phase 'instruction selection' in source unit 'test.groovy' Expected earlier checking to detect generics parameter arity mismatch Expected: A<D,I> Supplied: A<T extends A<java.lang.Character, java.lang.Boolean>> >>> stacktrace: BUG! exception in phase 'instruction selection' in source unit 'test.groovy' Expected earlier checking to detect generics parameter arity mismatch Expected: A<D,I> Supplied: A<T extends A<java.lang.Character, java.lang.Boolean>> at org.codehaus.groovy.ast.tools.GenericsUtils.extractPlaceholders(GenericsUtils.java:185) at org.codehaus.groovy.ast.tools.GenericsUtils.extractPlaceholders(GenericsUtils.java:149) at org.codehaus.groovy.ast.GenericsType.compareGenericsWithBound(GenericsType.java:337) at org.codehaus.groovy.ast.GenericsType.checkGenerics(GenericsType.java:261) at org.codehaus.groovy.ast.GenericsType.isCompatibleWith(GenericsType.java:240) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsConnections(StaticTypeCheckingSupport.java:1615) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.inferenceCheck(StaticTypeCheckingSupport.java:1529) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(StaticTypeCheckingSupport.java:1469) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(StaticTypeCheckingSupport.java:1417) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.typeCheckMethodsWithGenericsOrFail(StaticTypeCheckingVisitor.java:5858) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:3608) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:219) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:77) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:212) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2219) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:175) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBlockStatement(StaticTypeCheckingVisitor.java:4045) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:139) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:118) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitConstructorOrMethod$28(StaticTypeCheckingVisitor.java:2644) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doWithTypeCheckingExtensions(StaticTypeCheckingVisitor.java:456) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2644) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2627) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2606) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitConstructorOrMethod(StaticCompilationVisitor.java:189) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:204) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1143) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1136) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitClass$3(StaticTypeCheckingVisitor.java:492) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doWithTypeCheckingExtensions(StaticTypeCheckingVisitor.java:456) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:492) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:151) at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:68) at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.call(ASTTransformationCustomizer.groovy:303) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:937) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:692) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:666) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:647) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205)
Expected behavior
Compile successfully
Tested against master (commit: 2095b9eb3b73c5bcf27625395c24fa5210890443)