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 generic method reference is inferred when type parameters are omitted |
28 * check that generic method reference is inferred when type parameters are omitted |
29 * @run main MethodReference44 |
29 * @compile/fail/ref=MethodReference44.out -XDrawDiagnostics MethodReference44.java |
30 */ |
30 */ |
31 public class MethodReference44 { |
31 public class MethodReference44 { |
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 |
54 SuperFoo<Object> m(); |
46 SuperFoo<Object> m(); |
55 } |
47 } |
56 |
48 |
57 static <X extends Number> Foo<X> m() { return null; } |
49 static <X extends Number> Foo<X> m() { return null; } |
58 |
50 |
59 static void g(SAM1 s) { assertTrue(false); } |
51 static void g1(SAM1 s) { } |
60 static void g(SAM2 s) { assertTrue(true); } |
52 |
61 static void g(SAM3 s) { assertTrue(false); } |
53 static void g2(SAM2 s) { } |
|
54 |
|
55 static void g3(SAM3 s) { } |
|
56 |
|
57 static void g4(SAM1 s) { } |
|
58 static void g4(SAM2 s) { } |
|
59 static void g4(SAM3 s) { } |
62 |
60 |
63 public static void main(String[] args) { |
61 public static void main(String[] args) { |
64 g(MethodReference44::m); |
62 g1(MethodReference44::m); |
65 assertTrue(assertionCount == 1); |
63 g2(MethodReference44::m); |
|
64 g3(MethodReference44::m); |
|
65 g4(MethodReference44::m); |
66 } |
66 } |
67 } |
67 } |