Wed, 14 May 2014 15:41:28 -0600
8034223: Most-specific should not have any special treatment for boxed vs. unboxed types
Summary: Rewrite most-specific logic to conform to JLS 8 15.12.2.5
Reviewed-by: vromero
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 | } |