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

Mon, 21 Jan 2013 20:13:56 +0000

author
mcimadamore
date
Mon, 21 Jan 2013 20:13:56 +0000
changeset 1510
7873d37f5b37
parent 0
959103a6100f
permissions
-rw-r--r--

8005244: Implement overload resolution as per latest spec EDR
Summary: Add support for stuck expressions and provisional applicability
Reviewed-by: jjg

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 }

mercurial