[ https://issues.apache.org/jira/browse/GROOVY-6745?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-6745. ----------------------------- > Java8 Lambda var args and Closures > ---------------------------------- > > Key: GROOVY-6745 > URL: https://issues.apache.org/jira/browse/GROOVY-6745 > Project: Groovy > Issue Type: Improvement > Affects Versions: 2.3.0-beta-2 > Reporter: Stephen Mallette > Assignee: Eric Milles > Priority: Major > > Text below is taken from this thread in the mailing list: > http://groovy.markmail.org/thread/xgw5g4fdolxssjj6 > Please see this simple Java8 class: > {code:java} > import java.util.function.*; > class Marko { > public isA(Supplier<String> supplier) { > return supplier.get(); > } > public isA(Supplier<String>... suppliers) { > String temp = ""; > for(int i=0; i<suppliers.length; i++) { > temp = temp + suppliers[i].get(); > } > return temp; > } > } > {code} > I am delighted that Groovy 2.3.0-beta-2 supports the following > auto-conversion from closure to Java8 lambda. > {code:none} > gremlin> m.isA{'human'} > ==>human > {code} > However, note the issue with the Supplier[] var args method call. > {code:none} > gremlin> m.isA{'human'}{'animal'} > No signature of method: Marko.isA() is applicable for argument types: > (groovysh_evaluate$_run_closure1, groovysh_evaluate$_run_closure2) values: > [groovysh_evaluate$_run_closure1@39d9314d, > groovysh_evaluate$_run_closure2@b978d10] > Possible solutions: isA([Ljava.util.function.Supplier;), > isA(java.util.function.Supplier), is(java.lang.Object), find(), any(), > use([Ljava.lang.Object;) > Display stack trace? [yN] > gremlin> m.isA({'human'}{'animal'}) > No signature of method: Marko.isA() is applicable for argument types: > (java.lang.String) values: [human] > Possible solutions: isA([Ljava.util.function.Supplier;), > isA(java.util.function.Supplier), is(java.lang.Object), > use([Ljava.lang.Object;), find(), any() > Display stack trace? [yN] > gremlin> > {code} > It is interesting to note that this conversion works: > {code:none} > gremlin> suppliers = [{'human'},{'animal'}] as Supplier[] > ==>groovysh_evaluate$_run_closure1@727eb8cb > ==>groovysh_evaluate$_run_closure2@39d9314d > gremlin> m.isA(suppliers) > ==>humananimal > {code} > It would be sweet if 2.3.0 GA provided support for auto conversion of closure > var args to Java8 function var args. -- This message was sent by Atlassian Jira (v8.20.10#820010)