Tue, 21 May 2013 13:50:56 +0100
8005207: test has 2 @bug tags
Reviewed-by: mcimadamore
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * @test /nodynamiccopyright/ |
aoqi@0 | 3 | * @bug 8003280 |
aoqi@0 | 4 | * @summary Add lambda tests |
aoqi@0 | 5 | * This is negative test for wrong parameter/return type in method references |
aoqi@0 | 6 | * @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java |
aoqi@0 | 7 | */ |
aoqi@0 | 8 | |
aoqi@0 | 9 | public class MethodRef_neg { |
aoqi@0 | 10 | |
aoqi@0 | 11 | static interface A {void m(Integer i);} |
aoqi@0 | 12 | |
aoqi@0 | 13 | static interface B {void m(String s);} |
aoqi@0 | 14 | |
aoqi@0 | 15 | static interface C {Integer m();} |
aoqi@0 | 16 | |
aoqi@0 | 17 | static interface D {String m();} |
aoqi@0 | 18 | |
aoqi@0 | 19 | |
aoqi@0 | 20 | static void bar(int x) { } |
aoqi@0 | 21 | |
aoqi@0 | 22 | int foo() { |
aoqi@0 | 23 | return 5; |
aoqi@0 | 24 | } |
aoqi@0 | 25 | |
aoqi@0 | 26 | static void make() { } |
aoqi@0 | 27 | |
aoqi@0 | 28 | void method() { |
aoqi@0 | 29 | A a = MethodRef_neg::bar; //boxing on parameter type is ok |
aoqi@0 | 30 | B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int |
aoqi@0 | 31 | C c = this::foo; //boxing on return type is ok |
aoqi@0 | 32 | D d = this::foo; //wrong return type, required: String, actual: int |
aoqi@0 | 33 | a = MethodRef_neg::make; //missing parameter |
aoqi@0 | 34 | c = MethodRef_neg::make; //missing return type |
aoqi@0 | 35 | } |
aoqi@0 | 36 | } |