test/tools/javac/lambda/funcInterfaces/NonSAM3.java

changeset 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/funcInterfaces/NonSAM3.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,24 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *   This test is for identifying a non-SAM type: Having overloaded methods due to inheritance
     1.9 + * @compile/fail/ref=NonSAM3.out -XDrawDiagnostics NonSAM3.java Helper.java
    1.10 + */
    1.11 +
    1.12 +import java.util.Collection;
    1.13 +import java.util.List;
    1.14 +
    1.15 +public class NonSAM3 {
    1.16 +    void method() {
    1.17 +        //all of the following will have compile error: "the target type of a lambda conversion has multiple non-overriding abstract methods"
    1.18 +        FooBar fb = (Number n) -> 100;
    1.19 +        FooBar fb2 = (Integer i) -> 100;
    1.20 +        DE de = (List<Integer> list) -> 100;
    1.21 +        DE de2 = (List<?> list) -> 100;
    1.22 +        DE de3 = (List list) -> 100;
    1.23 +        DE de4 = (Collection<Integer> collection) -> 100;
    1.24 +        DE de5 = (Collection<?> collection) -> 100;
    1.25 +        DE de6 = (Collection collection) -> 100;
    1.26 +    }
    1.27 +}

mercurial