Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10230

Unexpected generics parameter arity mismatch in the "instruction selection" phase

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-beta-2, 3.0.11, 2.5.19
    • None
    • None

    Description

      The following program

      class Foo<T1, T2> {}
      class A {
        <T extends Foo<Number, Number>> T m(T x) {
          x
        }
      }
      class B extends A {
        <T extends Foo<Number, Number>> T m(T x) {
          T z = null;
          super.m((true) ? z : z)
        }
      }
      

      crashes the compiler and produces the following stack trace

      >>> 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: Foo<T1,T2>
      Supplied: Foo<T>
      >>> stacktrace:
      BUG! exception in phase 'instruction selection' in source unit 'test.groovy' Expected earlier checking to detect generics parameter arity mismatch
      Expected: Foo<T1,T2>
      Supplied: Foo<T>
              at org.codehaus.groovy.ast.tools.GenericsUtils.extractPlaceholders(GenericsUtils.java:195)
              at org.codehaus.groovy.ast.tools.GenericsUtils.extractPlaceholders(GenericsUtils.java:146)
              at org.codehaus.groovy.ast.GenericsType.compareGenericsWithBound(GenericsType.java:384)
              at org.codehaus.groovy.ast.GenericsType.checkGenerics(GenericsType.java:308)
              at org.codehaus.groovy.ast.GenericsType.isCompatibleWith(GenericsType.java:259)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsConnections(StaticTypeCheckingSupport.java:1610)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferReturnTypeGenerics(StaticTypeCheckingVisitor.java:5323)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:3578)
              at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:414)
              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:204)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2169)
              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:168)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBlockStatement(StaticTypeCheckingVisitor.java:3992)
              at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:70)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:142)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2602)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2591)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2565)
              at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:239)
              at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1131)
              at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1124)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:436)
              at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:197)
              at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:68)
              at org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.call(ASTTransformationCustomizer.groovy:298)
              at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:925)
              at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:654)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:631)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:607)
              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)
              at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189)
      
      

      Tested against master

      Attachments

        Activity

          People

            emilles Eric Milles
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: