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