Tue, 10 Sep 2013 13:47:51 +0200
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 * Overloaded methods take raw SAM types that have type inference according to SAM descriptor
6 should have ambiguous resolution of method
7 * @compile/fail/ref=InferenceTest_neg1_2.out -XDrawDiagnostics InferenceTest_neg1_2.java
8 */
10 public class InferenceTest_neg1_2 {
12 public static void main(String[] args) {
13 InferenceTest_neg1_2 test = new InferenceTest_neg1_2();
14 test.method(n -> null); //method 1-5 all match
15 test.method(n -> "a"); //method 2, 4 match
16 test.method(n -> 0); //method 1, 3, 5 match
17 }
19 void method(SAM1 s) { //method 1
20 Integer i = s.foo("a");
21 }
23 void method(SAM2 s) { //method 2
24 String str = s.foo(0);
25 }
27 void method(SAM3<Integer> s) { //method 3
28 Integer i = s.get(0);
29 }
31 void method(SAM4<Double, String> s) { //method 4
32 String str = s.get(0.0);
33 }
35 void method(SAM5<Integer> s) { //method 5
36 Integer i = s.get(0.0);
37 }
39 interface SAM1 {
40 Integer foo(String a);
41 }
43 interface SAM2 {
44 String foo(Integer a);
45 }
47 interface SAM3<T> {
48 T get(T t);
49 }
51 interface SAM4<T, V> {
52 V get(T t);
53 }
55 interface SAM5<T> {
56 T get(Double i);
57 }
58 }