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

Tue, 10 Sep 2013 13:47:51 +0200

author
jfranck
date
Tue, 10 Sep 2013 13:47:51 +0200
changeset 2020
bb7271e64ef6
parent 0
959103a6100f
permissions
-rw-r--r--

8005222: Fixed bugs should have tests with bugid in @bug tag
Reviewed-by: jfranck, jjg
Contributed-by: Andreas Lundblad <andreas.lundblad@oracle.com>

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 8003280
     4  * @summary Add lambda tests
     5  *   This test is for identifying a non-SAM type: Having overloaded methods due to inheritance
     6  * @compile/fail/ref=NonSAM3.out -XDrawDiagnostics NonSAM3.java Helper.java
     7  */
     9 import java.util.Collection;
    10 import java.util.List;
    12 public class NonSAM3 {
    13     void method() {
    14         //all of the following will have compile error: "the target type of a lambda conversion has multiple non-overriding abstract methods"
    15         FooBar fb = (Number n) -> 100;
    16         FooBar fb2 = (Integer i) -> 100;
    17         DE de = (List<Integer> list) -> 100;
    18         DE de2 = (List<?> list) -> 100;
    19         DE de3 = (List list) -> 100;
    20         DE de4 = (Collection<Integer> collection) -> 100;
    21         DE de5 = (Collection<?> collection) -> 100;
    22         DE de6 = (Collection collection) -> 100;
    23     }
    24 }

mercurial