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 correctness of structural most specific test routine |
aoqi@0 | 6 | * @compile/fail/ref=MostSpecific03.out -XDrawDiagnostics MostSpecific03.java |
aoqi@0 | 7 | */ |
aoqi@0 | 8 | |
aoqi@0 | 9 | class Test { |
aoqi@0 | 10 | |
aoqi@0 | 11 | interface IntMapper { |
aoqi@0 | 12 | int map(); |
aoqi@0 | 13 | } |
aoqi@0 | 14 | |
aoqi@0 | 15 | interface LongMapper { |
aoqi@0 | 16 | long map(); |
aoqi@0 | 17 | } |
aoqi@0 | 18 | |
aoqi@0 | 19 | void m(IntMapper... im) { } |
aoqi@0 | 20 | void m(LongMapper... lm) { } |
aoqi@0 | 21 | |
aoqi@0 | 22 | void m2(IntMapper im1, IntMapper... im) { } |
aoqi@0 | 23 | void m2(LongMapper... lm) { } |
aoqi@0 | 24 | |
aoqi@0 | 25 | void test1() { |
aoqi@0 | 26 | m(); //ambiguous |
aoqi@0 | 27 | m(()->1); //ok |
aoqi@0 | 28 | m(()->1, ()->1); //ok |
aoqi@0 | 29 | m(()->1, ()->1, ()->1); //ok |
aoqi@0 | 30 | } |
aoqi@0 | 31 | |
aoqi@0 | 32 | void test2() { |
aoqi@0 | 33 | m(null, null); //ambiguous |
aoqi@0 | 34 | m(()->1, null); //ambiguous |
aoqi@0 | 35 | m(null, ()->1); //ambiguous |
aoqi@0 | 36 | m(()->1L, null); //ok |
aoqi@0 | 37 | m(null, ()->1L); //ok |
aoqi@0 | 38 | } |
aoqi@0 | 39 | |
aoqi@0 | 40 | void test3() { |
aoqi@0 | 41 | m2(); //ok |
aoqi@0 | 42 | m2(()->1); //ambiguous |
aoqi@0 | 43 | m2(()->1, ()->1); //ok |
aoqi@0 | 44 | m2(()->1, ()->1, ()->1); //ok |
aoqi@0 | 45 | } |
aoqi@0 | 46 | |
aoqi@0 | 47 | void test4() { |
aoqi@0 | 48 | m2(null, null, null); //ambiguous |
aoqi@0 | 49 | m2(()->1, null, null); //ambiguous |
aoqi@0 | 50 | m2(null, ()->1, null); //ambiguous |
aoqi@0 | 51 | m2(null, null, ()->1); //ambiguous |
aoqi@0 | 52 | m2(()->1, ()->1, null); //ambiguous |
aoqi@0 | 53 | m2(null, ()->1, ()->1); //ambiguous |
aoqi@0 | 54 | m2(()->1, null, ()->1); //ambiguous |
aoqi@0 | 55 | |
aoqi@0 | 56 | m2(()->1L, null, null); //ok |
aoqi@0 | 57 | m2(null, ()->1L, null); //ok |
aoqi@0 | 58 | m2(null, null, ()->1L); //ok |
aoqi@0 | 59 | m2(()->1L, ()->1L, null); //ok |
aoqi@0 | 60 | m2(null, ()->1L, ()->1L); //ok |
aoqi@0 | 61 | m2(()->1L, null, ()->1L); //ok |
aoqi@0 | 62 | } |
aoqi@0 | 63 | } |