You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Krzysztof Białek (JIRA)" <ji...@apache.org> on 2016/03/14 21:46:33 UTC
[jira] [Created] (GROOVY-7789) ClosureParams type inference
compilation error when wrapping closure with object
Krzysztof Białek created GROOVY-7789:
----------------------------------------
Summary: ClosureParams type inference compilation error when wrapping closure with object
Key: GROOVY-7789
URL: https://issues.apache.org/jira/browse/GROOVY-7789
Project: Groovy
Issue Type: Bug
Components: Static compilation
Affects Versions: 2.4.6
Reporter: Krzysztof Białek
The following code does not compile:
{code}
import groovy.transform.*
import groovy.transform.stc.*
@CompileStatic
class Test {
class A<IN> {
Closure c
A(@ClosureParams(value = FromString, options = 'IN') Closure c) {
this.c = c
}
void call(IN param) {
c.call(param)
}
}
def <IN> A wrap(@ClosureParams(value = FromString, options = 'IN') Closure c) {
new A<IN>(c)
}
def test() {
(wrap { i -> i.size() }).call([])
}
}
{code}
Compilation error:
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/tmp/groovy-2.4.6/test.groovy: 25: [Static type checking] - Cannot find matching method java.lang.Object#size(). Please check if the declared type is right and if the method exists.
@ line 24, column 22.
(wrap { i -> i.size() }).call([])
{code}
I'd expect 'i' being infered as java.util.List
Explicit this.<List>wrap does not help neither
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)