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

Static Compilation with Diamond of local EnumMap<>

    XMLWordPrintableJSON

Details

    Description

      Foo.groovy
      import groovy.transform.CompileStatic
      
      @CompileStatic
      class Foo
      {
          enum Blah {
              ONE, TWO
          }
      
          void broken()
          {
              Map<Blah,Object> foo = new EnumMap<>(Blah.class);
              assert foo.size() == 0;
          }
      
          void works()
          {
              Map<Blah,Object> foo = new HashMap<>();
              assert foo.size() == 0;
          }
      }
      
      "c:\Program Files (x86)\Groovy\Groovy-2.4.3\bin\groovyc" Foo.groovy
      
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      General error during instruction selection: 1
      
      java.lang.ArrayIndexOutOfBoundsException: 1
              at org.codehaus.groovy.ast.tools.GenericsUtils.extractPlaceholders(GenericsUtils.java:164)
              at org.codehaus.groovy.ast.tools.GenericsUtils.extractPlaceholders(GenericsUtils.java:136)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(StaticTypeCheckingSupport.java:1342)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(StaticTypeCheckingSupport.java:1323)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.typeCheckMethodsWithGenericsOrFail(StaticTypeCheckingVisitor.java:4476)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2926)
              at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:294)
              at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBinaryExpression(StaticTypeCheckingVisitor.java:548)
              at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:49)
              at org.codehaus.groovy.ast.CodeVisitorSupport.visitBooleanExpression(CodeVisitorSupport.java:166)
              at org.codehaus.groovy.ast.expr.BooleanExpression.visit(BooleanExpression.java:40)
              at org.codehaus.groovy.ast.CodeVisitorSupport.visitAssertStatement(CodeVisitorSupport.java:77)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitAssertStatement(ClassCodeVisitorSupport.java:158)
              at org.codehaus.groovy.ast.stmt.AssertStatement.visit(AssertStatement.java:47)
              at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163)
              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.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1770)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2103)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2062)
              at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:160)
              at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1083)
              at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
              at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:247)
              at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:119)
              at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:60)
              at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:132)
              at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:176)
              at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1052)
              at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:588)
              at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:566)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:543)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:522)
              at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:59)
              at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:215)
              at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:148)
              at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:178)
              at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:162)
              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:606)
              at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:106)
              at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:128)
      
      1 error
      

      Attachments

        Activity

          People

            emilles Eric Milles
            dsheehan Dan Sheehan
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: