test/tools/javac/diags/examples/BadArgTypesInLambda.java

Mon, 08 Apr 2013 15:57:10 +0100

author
mcimadamore
date
Mon, 08 Apr 2013 15:57:10 +0100
changeset 1677
94a202228ec2
child 1759
05ec778794d0
permissions
-rw-r--r--

8009131: Overload: javac should discard methods that lead to errors in lambdas with implicit parameter types
Summary: Lambdas that have errors in their bodies should make enclosing overload resolution fail
Reviewed-by: jjg

mcimadamore@1677 1 /*
mcimadamore@1677 2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
mcimadamore@1677 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@1677 4 *
mcimadamore@1677 5 * This code is free software; you can redistribute it and/or modify it
mcimadamore@1677 6 * under the terms of the GNU General Public License version 2 only, as
mcimadamore@1677 7 * published by the Free Software Foundation.
mcimadamore@1677 8 *
mcimadamore@1677 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@1677 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@1677 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@1677 12 * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@1677 13 * accompanied this code).
mcimadamore@1677 14 *
mcimadamore@1677 15 * You should have received a copy of the GNU General Public License version
mcimadamore@1677 16 * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@1677 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@1677 18 *
mcimadamore@1677 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mcimadamore@1677 20 * or visit www.oracle.com if you need additional information or have any
mcimadamore@1677 21 * questions.
mcimadamore@1677 22 */
mcimadamore@1677 23
mcimadamore@1677 24 // key: compiler.err.cant.apply.symbol
mcimadamore@1677 25 // key: compiler.misc.no.conforming.assignment.exists
mcimadamore@1677 26 // key: compiler.misc.bad.arg.types.in.lambda
mcimadamore@1677 27
mcimadamore@1677 28 class BadArgTypesInLambda {
mcimadamore@1677 29 interface SAM {
mcimadamore@1677 30 void m(Integer i);
mcimadamore@1677 31 }
mcimadamore@1677 32
mcimadamore@1677 33 void g(SAM s) { }
mcimadamore@1677 34
mcimadamore@1677 35 void test() {
mcimadamore@1677 36 g(x->{ String s = x; });
mcimadamore@1677 37 }
mcimadamore@1677 38 }

mercurial