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

STC: lambda expression on wildcard generics fail to resolve param type(s)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.0-rc-2
    • Fix Version/s: 3.0.0-rc-3
    • Component/s: None
    • Labels:
      None

      Description

      Follow up to GROOVY-9342. Consider the following:

      @groovy.transform.CompileStatic
      class Test1 {
          static int acc = 1
          static { [1, 2, 3].forEach(e -> acc += e) }
      }
      assert Test1.acc == 7
      
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
          TestScript60.groovy: 5: [Static type checking] - Cannot find matching method int#plus(java.lang.Object). Please check if the declared type is correct and if the method exists.
           @ line 5, column 49.
             atic { [1, 2, 3].forEach(e -> acc += e)
                                           ^
      
          1 error
              at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:287)
              at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1091)
              at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633)
              at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:612)
              at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:589)
              at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:367)
              at groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:310)
              ...
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emilles Eric Milles
                Reporter:
                emilles Eric Milles
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h