test/tools/javac/lambda/MostSpecific03.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/MostSpecific03.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,63 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  check correctness of structural most specific test routine
     1.9 + * @compile/fail/ref=MostSpecific03.out -XDrawDiagnostics MostSpecific03.java
    1.10 + */
    1.11 +
    1.12 +class Test {
    1.13 +
    1.14 +    interface IntMapper {
    1.15 +        int map();
    1.16 +    }
    1.17 +
    1.18 +    interface LongMapper {
    1.19 +        long map();
    1.20 +    }
    1.21 +
    1.22 +    void m(IntMapper... im) { }
    1.23 +    void m(LongMapper... lm) { }
    1.24 +
    1.25 +    void m2(IntMapper im1, IntMapper... im) { }
    1.26 +    void m2(LongMapper... lm) { }
    1.27 +
    1.28 +    void test1() {
    1.29 +        m(); //ambiguous
    1.30 +        m(()->1); //ok
    1.31 +        m(()->1, ()->1); //ok
    1.32 +        m(()->1, ()->1, ()->1); //ok
    1.33 +    }
    1.34 +
    1.35 +    void test2() {
    1.36 +        m(null, null); //ambiguous
    1.37 +        m(()->1, null); //ambiguous
    1.38 +        m(null, ()->1); //ambiguous
    1.39 +        m(()->1L, null); //ok
    1.40 +        m(null, ()->1L); //ok
    1.41 +    }
    1.42 +
    1.43 +    void test3() {
    1.44 +        m2(); //ok
    1.45 +        m2(()->1); //ambiguous
    1.46 +        m2(()->1, ()->1); //ok
    1.47 +        m2(()->1, ()->1, ()->1); //ok
    1.48 +    }
    1.49 +
    1.50 +    void test4() {
    1.51 +        m2(null, null, null); //ambiguous
    1.52 +        m2(()->1, null, null); //ambiguous
    1.53 +        m2(null, ()->1, null); //ambiguous
    1.54 +        m2(null, null, ()->1); //ambiguous
    1.55 +        m2(()->1, ()->1, null); //ambiguous
    1.56 +        m2(null, ()->1, ()->1); //ambiguous
    1.57 +        m2(()->1, null, ()->1); //ambiguous
    1.58 +
    1.59 +        m2(()->1L, null, null); //ok
    1.60 +        m2(null, ()->1L, null); //ok
    1.61 +        m2(null, null, ()->1L); //ok
    1.62 +        m2(()->1L, ()->1L, null); //ok
    1.63 +        m2(null, ()->1L, ()->1L); //ok
    1.64 +        m2(()->1L, null, ()->1L); //ok
    1.65 +    }
    1.66 +}

mercurial