diff -r 7993cfab8610 -r 4a6acc42c3a1 test/tools/javac/lambda/8016177/T8016177c.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8016177/T8016177c.java Mon Sep 02 22:38:36 2013 +0100 @@ -0,0 +1,47 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8016081 8016178 + * @summary structural most specific and stuckness + * @compile/fail/ref=T8016177c.out -XDrawDiagnostics T8016177c.java + */ + +class T8016177c { + + interface Function { + Y m(X x); + } + + interface ExtFunction extends Function { } + + U m1(Function f) { return null; } + U m1(ExtFunction f) { return null; } + + void m2(Function f) { } + void m2(ExtFunction f) { } + + void m3(Function f) { } + void m3(ExtFunction f) { } + + int g1(Object s) { return 1; } + + int g2(Number s) { return 1; } + int g2(Object s) { return 1; } + + void test() { + m1((Integer x)->x); //ok - explicit lambda - subtyping picks most specific + m2((Integer x)->x); //ok - explicit lambda - subtyping picks most specific + m3((Integer x)->x); //ok - explicit lambda (only one applicable) + + m1(x->1); //ok - stuck lambda but nominal most specific wins + m2(x->1); //ok - stuck lambda but nominal most specific wins + m3(x->1); //ambiguous - implicit lambda & different params + + m1(this::g1); //ok - unambiguous ref - subtyping picks most specific + m2(this::g1); //ok - unambiguous ref - subtyping picks most specific + m3(this::g1); //ambiguous - both applicable, neither most specific + + m1(this::g2); //ok - stuck mref but nominal most specific wins + m2(this::g2); //ok - stuck mref but nominal most specific wins + m3(this::g2); //ambiguous - different params + } +}