1 /* |
1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 8003280 |
26 * @bug 8003280 |
27 * @summary Add lambda tests |
27 * @summary Add lambda tests |
28 * check that diamond inference is applied when using raw constructor reference qualifier |
28 * check that diamond inference is applied when using raw constructor reference qualifier |
29 * @run main MethodReference42 |
29 * @compile/fail/ref=MethodReference42.out -XDrawDiagnostics MethodReference42.java |
30 */ |
30 */ |
31 public class MethodReference42 { |
31 public class MethodReference42 { |
32 |
|
33 static int assertionCount = 0; |
|
34 |
|
35 static void assertTrue(boolean cond) { |
|
36 assertionCount++; |
|
37 if (!cond) |
|
38 throw new AssertionError(); |
|
39 } |
|
40 |
32 |
41 static class SuperFoo<X> { } |
33 static class SuperFoo<X> { } |
42 |
34 |
43 static class Foo<X extends Number> extends SuperFoo<X> { } |
35 static class Foo<X extends Number> extends SuperFoo<X> { } |
44 |
36 |
52 |
44 |
53 interface SAM3 { |
45 interface SAM3 { |
54 SuperFoo<Object> m(); |
46 SuperFoo<Object> m(); |
55 } |
47 } |
56 |
48 |
57 static void m(SAM1 s) { assertTrue(false); } |
49 static void m1(SAM1 s) { } |
58 static void m(SAM2 s) { assertTrue(true); } |
50 |
59 static void m(SAM3 s) { assertTrue(false); } |
51 static void m2(SAM2 s) { } |
|
52 |
|
53 static void m3(SAM3 s) { } |
|
54 |
|
55 static void m4(SAM1 s) { } |
|
56 static void m4(SAM2 s) { } |
|
57 static void m4(SAM3 s) { } |
60 |
58 |
61 public static void main(String[] args) { |
59 public static void main(String[] args) { |
62 m(Foo::new); |
60 m1(Foo::new); |
63 assertTrue(assertionCount == 1); |
61 m2(Foo::new); |
|
62 m3(Foo::new); |
|
63 m4(Foo::new); |
64 } |
64 } |
65 } |
65 } |