test/tools/javac/lambda/MethodReference41.java

changeset 2000
4a6acc42c3a1
parent 1415
01c9d4161882
child 2015
a4b9a8859e58
equal deleted inserted replaced
1999:7993cfab8610 2000:4a6acc42c3a1
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 MethodReference41 29 * @compile/fail/ref=MethodReference41.out -XDrawDiagnostics MethodReference41.java
30 */ 30 */
31 public class MethodReference41 { 31 public class MethodReference41 {
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 interface SAM1 { 33 interface SAM1 {
42 void m(String s); 34 void m(String s);
43 } 35 }
44 36
52 44
53 static class Foo<X extends Number> { 45 static class Foo<X extends Number> {
54 Foo(X x) { } 46 Foo(X x) { }
55 } 47 }
56 48
49 static void m1(SAM1 s) { }
57 50
58 static void m(SAM1 s) { assertTrue(false); } 51 static void m2(SAM2 s) { }
59 static void m(SAM2 s) { assertTrue(true); } 52
60 static void m(SAM3 s) { assertTrue(false); } 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) { }
61 58
62 public static void main(String[] args) { 59 public static void main(String[] args) {
63 m(Foo::new); 60 m1(Foo::new);
64 assertTrue(assertionCount == 1); 61 m2(Foo::new);
62 m3(Foo::new);
63 m4(Foo::new);
65 } 64 }
66 } 65 }

mercurial