Am 01.02.2018 um 12:50 schrieb Jesper Steen Møller:
[...]
class R implements Runnable { void run(){}}
def m(Runnable r1, R r2, r3) {
r1()
r2()
r3()
}
m(new R(), new R(), new R())
Currently, in the 'native-lambda' branch, r1() succeeds, whereas the latter two
fail to run/compile (depending on dynamic/static compilation), as 'avafanasiev'
commented on. I do find that confusing: Dynamically, my opinion is that the
three should work the same.
For static compilation, r1() and r2() should work IMHO, and r3() should be
rejected. This shouldn't surprise anyone, I think.
you mean because the m has a return value and r3() is void? That is
currently passing compilation and the result will be null. This covers
with the dynamic version.
Also, surprise-wise,
class Q implements Runnable, Predicate<String> { void run(){}; boolean
test(String s) { s } }
def n(Runnable q1, Predicate<String> q2, Q q2, q3) {
r1()
r2()
r3()
}
m(new R(), new R(), new R())
you surely did mean:
def n(Runnable q1, Predicate<String> q2, Q q2, q3) {
q1()
q2()
q3() >> q4()
}
m(new Q(), new Q(), new Q(), new Q())
I expect this to work then too ;)
bye Jochen