Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset eb6ee6a5f2fe
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @bug 8009131 |
aoqi@0 | 4 | * @summary Overload: javac should discard methods that lead to errors in lambdas with implicit parameter types |
aoqi@0 | 5 | * @compile/fail/ref=TargetType66.out -XDrawDiagnostics TargetType66.java |
aoqi@0 | 6 | */ |
aoqi@0 | 7 | class TargetType66 { |
aoqi@0 | 8 | interface SAM1 { |
aoqi@0 | 9 | void m(String s); |
aoqi@0 | 10 | } |
aoqi@0 | 11 | |
aoqi@0 | 12 | interface SAM2 { |
aoqi@0 | 13 | void m(Integer s); |
aoqi@0 | 14 | } |
aoqi@0 | 15 | |
aoqi@0 | 16 | void g(SAM1 s1) { } |
aoqi@0 | 17 | void g(SAM2 s2) { } |
aoqi@0 | 18 | |
aoqi@0 | 19 | void test() { |
aoqi@0 | 20 | g(x->{ String s = x; }); //ambiguous |
aoqi@0 | 21 | g(x->{ Integer i = x; }); //ambiguous |
aoqi@0 | 22 | g(x->{ Object o = x; }); //ambiguous |
aoqi@0 | 23 | g(x->{ Character c = x; }); //error: inapplicable methods |
aoqi@0 | 24 | g(x->{ Character c = ""; }); //error: incompatible types |
aoqi@0 | 25 | } |
aoqi@0 | 26 | } |