test/tools/javac/lambda/LambdaConv21.java

Fri, 30 May 2014 12:54:16 +0200

author
jlahoda
date
Fri, 30 May 2014 12:54:16 +0200
changeset 2410
e64bb2f5f0cf
parent 1433
4f9853659bf1
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8031967: For some sources compiler compiles for ever
Summary: Avoid creating DeferredTypes for method calls with method calls as receivers if the site can be determined reliably
Reviewed-by: mcimadamore, vromero
Contributed-by: maurizio.cimadamore@oracle.com, jan.lahoda@oracle.com

mcimadamore@1415 1 /*
mcimadamore@1415 2 * @test /nodynamiccopyright/
mcimadamore@1415 3 * @bug 8003280
mcimadamore@1415 4 * @summary Add lambda tests
mcimadamore@1415 5 * check that code generation handles void-compatibility correctly
mcimadamore@1415 6 * @compile/fail/ref=LambdaConv21.out -XDrawDiagnostics LambdaConv21.java
mcimadamore@1415 7 */
mcimadamore@1415 8
mcimadamore@1415 9 class LambdaConv21 {
mcimadamore@1415 10
mcimadamore@1415 11 interface SAM_void<X> {
mcimadamore@1415 12 void m();
mcimadamore@1415 13 }
mcimadamore@1415 14
mcimadamore@1415 15 interface SAM_java_lang_Void {
mcimadamore@1415 16 Void m();
mcimadamore@1415 17 }
mcimadamore@1415 18
mcimadamore@1415 19 static void m_void() { }
mcimadamore@1415 20
mcimadamore@1415 21 static Void m_java_lang_Void() { return null; }
mcimadamore@1415 22
mcimadamore@1415 23 static void testExpressionLambda() {
mcimadamore@1415 24 SAM_void s1 = ()->m_void(); //ok
mcimadamore@1415 25 SAM_java_lang_Void s2 = ()->m_void(); //no - incompatible target
mcimadamore@1433 26 SAM_void s3 = ()->m_java_lang_Void(); //ok - expression statement lambda is compatible with void
mcimadamore@1415 27 SAM_java_lang_Void s4 = ()->m_java_lang_Void(); //ok
mcimadamore@1415 28 }
mcimadamore@1415 29
mcimadamore@1415 30 static void testStatementLambda() {
mcimadamore@1415 31 SAM_void s1 = ()-> { m_void(); }; //ok
mcimadamore@1415 32 SAM_java_lang_Void s2 = ()-> { m_void(); }; //no - missing return value
mcimadamore@1415 33 SAM_void s3 = ()-> { return m_java_lang_Void(); }; //no - unexpected return value
mcimadamore@1415 34 SAM_java_lang_Void s4 = ()-> { return m_java_lang_Void(); }; //ok
mcimadamore@1415 35 SAM_void s5 = ()-> { m_java_lang_Void(); }; //ok
mcimadamore@1415 36 SAM_java_lang_Void s6 = ()-> { m_java_lang_Void(); }; //no - missing return value
mcimadamore@1415 37 }
mcimadamore@1415 38 }

mercurial