test/tools/javac/lambda/methodReference/MethodRef_neg.java

Wed, 14 May 2014 15:41:28 -0600

author
dlsmith
date
Wed, 14 May 2014 15:41:28 -0600
changeset 2395
9c577131ffa6
parent 0
959103a6100f
permissions
-rw-r--r--

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

     1 /*
     2  * @test /nodynamiccopyright/
     3  * @bug 8003280
     4  * @summary Add lambda tests
     5  *   This is negative test for wrong parameter/return type in method references
     6  * @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java
     7  */
     9 public class MethodRef_neg {
    11     static interface A {void m(Integer i);}
    13     static interface B {void m(String s);}
    15     static interface C {Integer m();}
    17     static interface D {String m();}
    20     static void bar(int x) { }
    22     int foo() {
    23         return 5;
    24     }
    26     static void make() { }
    28     void method() {
    29         A a = MethodRef_neg::bar; //boxing on parameter type is ok
    30         B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int
    31         C c = this::foo; //boxing on return type is ok
    32         D d = this::foo; //wrong return type, required: String, actual: int
    33         a = MethodRef_neg::make; //missing parameter
    34         c = MethodRef_neg::make; //missing return type
    35     }
    36 }

mercurial