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

STC: NPE in StaticTypeCheckingVisitor.inferSAMTypeGenericsInAssignment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-beta-1, 2.5.7
    • None
    • None

    Description

      Consider the following:

      @groovy.transform.CompileStatic
      void meth() {
        java.util.concurrent.Callable<String> call = { -> '' }
      }
      

      This code produces:

      BUG! exception in phase 'instruction selection' in source unit 'Blah.groovy' unexpected NullpointerException
      	at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1148)
      	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:654)
      	at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:632)
      	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:609)
      	...
      Caused by: java.lang.NullPointerException
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferSAMTypeGenericsInAssignment(StaticTypeCheckingVisitor.java:4282)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.getResultType(StaticTypeCheckingVisitor.java:4133)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitBinaryExpression(StaticTypeCheckingVisitor.java:831)
      	...
      

      The method in StaticTypeCheckingVisitor calls ClosureExpression.getParameters(), which returns null for a closure expression like "

      { -> '' }

      ".

      Attachments

        Activity

          People

            paulk Paul King
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: