Wed, 27 Apr 2016 01:34:52 +0800
Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/langtools/
changeset: 2573:53ca196be1ae
tag: jdk8u25-b17
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @bug 8003280 |
aoqi@0 | 4 | * @summary Add lambda tests |
aoqi@0 | 5 | * check that raw qualifier in unbound method reference is inferred from descriptor |
aoqi@0 | 6 | * @compile/fail/ref=MethodReference48.out -XDrawDiagnostics MethodReference48.java |
aoqi@0 | 7 | */ |
aoqi@0 | 8 | |
aoqi@0 | 9 | public class MethodReference48 { |
aoqi@0 | 10 | |
aoqi@0 | 11 | static class Foo<X> { |
aoqi@0 | 12 | X m() { return null; }; |
aoqi@0 | 13 | } |
aoqi@0 | 14 | |
aoqi@0 | 15 | interface SAM1 { |
aoqi@0 | 16 | Foo<Object> m(Foo<String> fs); |
aoqi@0 | 17 | } |
aoqi@0 | 18 | |
aoqi@0 | 19 | interface SAM2 { |
aoqi@0 | 20 | Integer m(Foo<Integer> fi); |
aoqi@0 | 21 | } |
aoqi@0 | 22 | |
aoqi@0 | 23 | interface SAM3 { |
aoqi@0 | 24 | Object m(Foo<Integer> fi); |
aoqi@0 | 25 | } |
aoqi@0 | 26 | |
aoqi@0 | 27 | static void g1(SAM1 s) { } //return type not compatible |
aoqi@0 | 28 | |
aoqi@0 | 29 | static void g2(SAM2 s) { } //ok |
aoqi@0 | 30 | |
aoqi@0 | 31 | static void g3(SAM3 s) { } //ok |
aoqi@0 | 32 | |
aoqi@0 | 33 | static void g4(SAM1 s) { } //return type not compatible |
aoqi@0 | 34 | static void g4(SAM2 s) { } //ok |
aoqi@0 | 35 | static void g4(SAM3 s) { } //ok |
aoqi@0 | 36 | |
aoqi@0 | 37 | public static void main(String[] args) { |
aoqi@0 | 38 | g1(Foo::m); |
aoqi@0 | 39 | g2(Foo::m); |
aoqi@0 | 40 | g3(Foo::m); |
aoqi@0 | 41 | g4(Foo::m); |
aoqi@0 | 42 | } |
aoqi@0 | 43 | } |