mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-17 01:24:33 +02:00
8003280: Add lambda tests
Turn on lambda expression, method reference and default method support Reviewed-by: jjg
This commit is contained in:
parent
c39f1d99b4
commit
a494f0ab86
451 changed files with 15433 additions and 488 deletions
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 8003280
|
||||
* @summary Add lambda tests
|
||||
* This is negative test for wrong parameter/return type in method references
|
||||
* @compile/fail/ref=MethodRef_neg.out -XDrawDiagnostics MethodRef_neg.java
|
||||
*/
|
||||
|
||||
public class MethodRef_neg {
|
||||
|
||||
static interface A {void m(Integer i);}
|
||||
|
||||
static interface B {void m(String s);}
|
||||
|
||||
static interface C {Integer m();}
|
||||
|
||||
static interface D {String m();}
|
||||
|
||||
|
||||
static void bar(int x) { }
|
||||
|
||||
int foo() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
static void make() { }
|
||||
|
||||
void method() {
|
||||
A a = MethodRef_neg::bar; //boxing on parameter type is ok
|
||||
B b = MethodRef_neg::bar; //wrong parameter type, required: String, actual: int
|
||||
C c = this::foo; //boxing on return type is ok
|
||||
D d = this::foo; //wrong return type, required: String, actual: int
|
||||
a = MethodRef_neg::make; //missing parameter
|
||||
c = MethodRef_neg::make; //missing return type
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue