Iurii created GROOVY-8138:
-----------------------------

             Summary: Compile static to support streams
                 Key: GROOVY-8138
                 URL: https://issues.apache.org/jira/browse/GROOVY-8138
             Project: Groovy
          Issue Type: New Feature
          Components: Static compilation
    Affects Versions: 2.4.10
         Environment: Windows 7, JDK 1.8.0_66
            Reporter: Iurii


The following code
{code}
import groovy.transform.CompileStatic

import static java.util.stream.Collectors.toList

@CompileStatic
class Test {
    static void main(String[] args) {
        List<String> tables = ['a', 'b']
        println tables.stream().filter { tableName -> tableName.contains('a') 
}.collect(toList())
    }
}
{code}

fails with the error:
Error:(9, 55) Groovyc: [Static type checking] - Cannot find matching method 
java.lang.Object#contains(java.lang.String). Please check if the declared type 
is right and if the method exists.

But works fine with compile dynamic.
It would be great if CompileStatic get all required types from the steam (type 
info should be there, Java can handle similar code)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to