test/tools/javac/lambda/T8024947/PotentiallyAmbiguousWarningTest.java

Thu, 26 Mar 2015 11:34:50 +0100

author
jlahoda
date
Thu, 26 Mar 2015 11:34:50 +0100
changeset 2734
ba758e1ffa69
parent 0
959103a6100f
permissions
-rw-r--r--

8054220: Debugger doesn't show variables *outside* lambda
8058227: Debugger has no access to outer variables inside Lambda
Summary: Put local variables captured by lambda into the lambda method's LocalVariableTable.
Reviewed-by: mcimadamore, rfield

     1 /*
     2  * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /*
    25  * @test
    26  * @bug 8024947
    27  * @summary javac should issue the potentially ambiguous overload warning only
    28  * where the problem appears
    29  * @compile/fail/ref=PotentiallyAmbiguousWarningTest.out -XDrawDiagnostics -Werror -Xlint:overloads PotentiallyAmbiguousWarningTest.java
    30  * @compile PotentiallyAmbiguousWarningTest.java
    31  */
    33 import java.util.function.*;
    35 public interface PotentiallyAmbiguousWarningTest {
    37     //a warning should be fired
    38     interface I1 {
    39         void foo(Consumer<Integer> c);
    40         void foo(IntConsumer c);
    41     }
    43     //a warning should be fired
    44     class C1 {
    45         void foo(Consumer<Integer> c) { }
    46         void foo(IntConsumer c) { }
    47     }
    49     interface I2 {
    50         void foo(Consumer<Integer> c);
    51     }
    53     //a warning should be fired, J1 is provoking the issue
    54     interface J1 extends I2 {
    55         void foo(IntConsumer c);
    56     }
    58     //no warning here, the issue is introduced in I1
    59     interface I3 extends I1 {}
    61     //no warning here, the issue is introduced in I1. I4 is just overriding an existing method
    62     interface I4 extends I1 {
    63         void foo(IntConsumer c);
    64     }
    66     class C2 {
    67         void foo(Consumer<Integer> c) { }
    68     }
    70     //a warning should be fired, D1 is provoking the issue
    71     class D1 extends C2 {
    72         void foo(IntConsumer c) { }
    73     }
    75     //a warning should be fired, C3 is provoking the issue
    76     class C3 implements I2 {
    77         public void foo(Consumer<Integer> c) { }
    78         public void foo(IntConsumer c) { }
    79     }
    81     //no warning here, the issue is introduced in C1
    82     class C4 extends C1 {}
    84     //no warning here, the issue is introduced in C1. C5 is just overriding an existing method
    85     class C5 extends C1 {
    86         void foo(IntConsumer c) {}
    87     }
    89     interface I5<T> {
    90         void foo(T c);
    91     }
    93     //a warning should be fired, J2 is provoking the issue
    94     interface J2 extends I5<IntConsumer> {
    95         void foo(Consumer<Integer> c);
    96     }
    97 }

mercurial