blob: 3f24387d9fbd7726185e70a90ae5a5ae5d793f58 [file]
import groovy.transform.CompileStatic
import groovy.transform.stc.ClosureParams
import groovy.transform.stc.FromString
class Foo {
void bar() {
println 'Haha!'
}
}
class Tor<D,U> {
public void foo(@ClosureParams(value=FromString,options=["D,List<U>", "D"]) Closure cl) {
if (cl.maximumNumberOfParameters==2) {
cl.call(3, [new Foo(), new Foo()])
} else {
cl.call(3)
}
}
}
@CompileStatic
def test() {
def tor = new Tor<Integer,Foo>()
tor.foo (r, e) -> { r.times (a) -> { e.each (it) -> { it.bar() } } }
tor.foo (it) -> { it.times (x) -> { println 'polymorphic' } }
}