Sat, 22 Dec 2018 13:10:38 -0800
Added tag jdk8u202-b25 for changeset 15d8c732039b
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 pair of bound/non-bound method references checked correctly |
aoqi@0 | 6 | * @author Maurizio Cimadamore |
aoqi@0 | 7 | * @compile/fail/ref=MethodReference22.out -XDrawDiagnostics MethodReference22.java |
aoqi@0 | 8 | */ |
aoqi@0 | 9 | |
aoqi@0 | 10 | class MethodReference22 { |
aoqi@0 | 11 | |
aoqi@0 | 12 | void m1(String x) { } |
aoqi@0 | 13 | void m1(MethodReference22 rec, String x) { } |
aoqi@0 | 14 | |
aoqi@0 | 15 | static void m2(String x) { } |
aoqi@0 | 16 | static void m2(MethodReference22 rec, String x) { } |
aoqi@0 | 17 | |
aoqi@0 | 18 | static void m3(String x) { } |
aoqi@0 | 19 | void m3(MethodReference22 rec, String x) { } |
aoqi@0 | 20 | |
aoqi@0 | 21 | void m4(String x) { } |
aoqi@0 | 22 | static void m4(MethodReference22 rec, String x) { } |
aoqi@0 | 23 | |
aoqi@0 | 24 | interface SAM1 { |
aoqi@0 | 25 | void m(String x); |
aoqi@0 | 26 | } |
aoqi@0 | 27 | |
aoqi@0 | 28 | interface SAM2 { |
aoqi@0 | 29 | void m(MethodReference22 rec, String x); |
aoqi@0 | 30 | } |
aoqi@0 | 31 | |
aoqi@0 | 32 | static void call1(SAM1 s) { } |
aoqi@0 | 33 | |
aoqi@0 | 34 | static void call2(SAM2 s) { } |
aoqi@0 | 35 | |
aoqi@0 | 36 | static void call3(SAM1 s) { } |
aoqi@0 | 37 | static void call3(SAM2 s) { } |
aoqi@0 | 38 | |
aoqi@0 | 39 | static void test1() { |
aoqi@0 | 40 | SAM1 s1 = MethodReference22::m1; //fail |
aoqi@0 | 41 | call1(MethodReference22::m1); //fail |
aoqi@0 | 42 | SAM1 s2 = MethodReference22::m2; //ok |
aoqi@0 | 43 | call1(MethodReference22::m2); //ok |
aoqi@0 | 44 | SAM1 s3 = MethodReference22::m3; //ok |
aoqi@0 | 45 | call1(MethodReference22::m3); //ok |
aoqi@0 | 46 | SAM1 s4 = MethodReference22::m4; //fail |
aoqi@0 | 47 | call1(MethodReference22::m4); //fail |
aoqi@0 | 48 | } |
aoqi@0 | 49 | |
aoqi@0 | 50 | static void test2() { |
vromero@2193 | 51 | SAM2 s1 = MethodReference22::m1; //ok |
vromero@2193 | 52 | call2(MethodReference22::m1); //ok |
vromero@2193 | 53 | SAM2 s2 = MethodReference22::m2; //ok |
vromero@2193 | 54 | call2(MethodReference22::m2); //ok |
vromero@2193 | 55 | SAM2 s3 = MethodReference22::m3; //fail |
vromero@2193 | 56 | call2(MethodReference22::m3); //fail |
vromero@2193 | 57 | SAM2 s4 = MethodReference22::m4; //fail |
vromero@2193 | 58 | call2(MethodReference22::m4); //fail |
aoqi@0 | 59 | } |
aoqi@0 | 60 | |
aoqi@0 | 61 | static void test3() { |
vromero@2193 | 62 | call3(MethodReference22::m1); //ok |
vromero@2193 | 63 | call3(MethodReference22::m2); //ambiguous |
aoqi@0 | 64 | call3(MethodReference22::m3); //ok |
aoqi@0 | 65 | call3(MethodReference22::m4); //fail |
aoqi@0 | 66 | } |
aoqi@0 | 67 | } |