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

Groovyc: BUG! exception in phase 'class generation' in source unit

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

      Description

      This code:

      @CompileStatic
          static main(args)
          {
              def list = [1, 2, 3]
      
              def sum = 0
              list.each { int i -> sum += i }
              println(sum)
      
              sum = list.inject(0, { int x, int y -> x + y })
              println(sum)
          }
      

      creates this error message:

      Groovyc: BUG! exception in phase 'class generation' in source unit 'C:\Users\Oliver\IdeaProjects\GroovyForEachSum\src\org\objectscape\LambdaTestStatic.groovy' At line 20 column 30
      On receiver: sum with message: plus and arguments: i
      This method should not have been called. Please try to create a simple example reproducing this error and filea bug report at http://jira.codehaus.org/browse/GROOVY
      at org.codehaus.groovy.classgen.asm.sc.StaticTypesCallSiteWriter.makeSingleArgumentCall(StaticTypesCallSiteWriter.java:535)
      at org.codehaus.groovy.classgen.asm.InvocationWriter.makeSingleArgumentCall(InvocationWriter.java:482)
      at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateBinaryExpression(BinaryExpressionHelper.java:504)
      at org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher.evaluateBinaryExpression(BinaryExpressionMultiTypeDispatcher.java:216)
      at org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher.doAssignmentToLocalVariable(BinaryExpressionMultiTypeDispatcher.java:362)
      at org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher.evaluateBinaryExpressionWithAssignment(BinaryExpressionMultiTypeDispatcher.java:346)
      at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:146)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:527)
      at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49)
      at org.codehaus.groovy.classgen.asm.StatementWriter.writeReturn(StatementWriter.java:582)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitReturnStatement(AsmClassGenerator.java:505)
      at org.codehaus.groovy.ast.stmt.ReturnStatement.visit(ReturnStatement.java:47)
      at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:81)
      at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:49)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:455)
      at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:319)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:276)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:396)
      at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1059)
      at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
      at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:180)
      at org.codehaus.groovy.control.CompilationUnit$14.call(CompilationUnit.java:786)
      at org.codehaus.groovy.control.CompilationUnit$14.call(CompilationUnit.java:803)
      at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1027)
      at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:564)
      at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:542)
      at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:519)
      at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:44)
      at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:129)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:112)

      Also happens without @CompileStatic:

      def list = [1, 2, 3]

      def sum = 0
      list.each

      { sum += it }

      println(sum)

      sum = list.inject(0,

      { x, y -> x + y }

      )
      println(sum)

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              oliver_plow Oliver Plow

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment