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

crash when annotating a lambda parameter

    XMLWordPrintableJSON

Details

    Description

      I have the following program

      import java.lang.annotation.*;
      import java.util.function.*;
      
      @Target(ElementType.TYPE_USE)
      @interface Nullable {}
      
      class Test {
        public static void main() {
          IntUnaryOperator x = (@Nullable Integer y) -> 1;
        }
      } 

      Actual behavior

      The compiler crashes

      >>> a serious error occurred: BUG! exception in phase 'class generation' in source unit 'test.groovy' Adding type annotation @Nullable to non-redirect node: int
      >>> stacktrace:
      BUG! exception in phase 'class generation' in source unit 'test.groovy' Adding type annotation @Nullable to non-redirect node: int
              at org.codehaus.groovy.ast.ClassNode.addTypeAnnotation(ClassNode.java:1673)
              at org.codehaus.groovy.ast.ClassNode.addTypeAnnotations(ClassNode.java:1684)
              at org.codehaus.groovy.classgen.ExtendedVerifier.extractTypeUseAnnotations(ExtendedVerifier.java:269)
              at org.codehaus.groovy.classgen.ExtendedVerifier.visitConstructorOrMethod(ExtendedVerifier.java:173)
              at org.codehaus.groovy.classgen.ExtendedVerifier.visitMethod(ExtendedVerifier.java:220)
              at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1331)
              at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1324)
              at org.codehaus.groovy.classgen.ExtendedVerifier.visitClass(ExtendedVerifier.java:127)
              at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:775)
              at org.codehaus.groovy.control.CompilationUnit$4.call(CompilationUnit.java:828)
              at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:952)
              at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:698)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:672)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:653)
              at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:312)
              at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:241)
              at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:166)
              at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:206)
              at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:190)
       

      Notes

      Tested against master (commit: 168bb9bc078ec7f68c47af4571ce0238496235f1)

      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: