test/tools/javac/lambda/TargetType21.java

Thu, 30 Jan 2014 11:09:01 -0800

author
sogoel
date
Thu, 30 Jan 2014 11:09:01 -0800
changeset 2255
b2e4c5ca111f
parent 2000
4a6acc42c3a1
child 2525
2eb010b6cb22
permissions
-rw-r--r--

8027175: Existing regression tests in tl/langtools and tl/jdk need to be updated for @bug keyword
Reviewed-by: jjg, ksrini
Contributed-by: matherey.nunez@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 candidates with cyclic type-inference are removed from the
mcimadamore@1415 6 * set of applicable methods
mcimadamore@1415 7 * @compile/fail/ref=TargetType21.out -XDrawDiagnostics TargetType21.java
mcimadamore@1415 8 */
mcimadamore@1415 9
mcimadamore@1415 10 class TargetType21 {
mcimadamore@1415 11 interface SAM1 {
mcimadamore@1415 12 String m1(Integer n) throws Exception;
mcimadamore@1415 13 }
mcimadamore@1415 14
mcimadamore@1415 15 interface SAM2 {
mcimadamore@1415 16 void m2(Integer n);
mcimadamore@1415 17 }
mcimadamore@1415 18
mcimadamore@1415 19 interface SAM3<R,A> {
mcimadamore@1415 20 R m3(A n);
mcimadamore@1415 21 }
mcimadamore@1415 22
mcimadamore@1415 23 void call(SAM1 sam) { }
mcimadamore@1415 24 void call(SAM2 sam) { }
mcimadamore@1415 25 <R,A> void call(SAM3<R,A> sam) { }
mcimadamore@1415 26
mcimadamore@1415 27 void test() {
mcimadamore@1480 28 call(x -> { throw new Exception(); }); //ambiguous
vromero@2000 29 call((Integer x) -> { System.out.println(""); }); //ok (only one is void)
vromero@2000 30 call((Integer x) -> { return (Object) null; }); //ok (only one returns Object)
mcimadamore@1510 31 call(x -> { System.out.println(""); }); //ambiguous
vromero@2000 32 call(x -> { return (Object) null; }); //ambiguous
mcimadamore@1510 33 call(x -> { return null; }); //ambiguous
mcimadamore@1415 34 }
mcimadamore@1415 35 }

mercurial