langtools/test/tools/javac/lambda/8016177/T8016177a.java
author sadayapalam
Thu, 12 Feb 2015 10:16:19 +0530
changeset 28891 dc7d89f2e25c
parent 19914 d86271bd430a
permissions -rw-r--r--
8069545: javac shouldn't check nested stuck lambdas during overload resolution Summary: Nested lambdas should not be considered while overload resolution is in progress Reviewed-by: mcimadamore Contributed-by: vicente.romero@oracle.com, srikanth.adayapalam@oracle.com

/*
 * @test /nodynamiccopyright/
 * @bug 8016177 8016178
 * @summary structural most specific and stuckness
 * @compile/fail/ref=T8016177a.out -XDrawDiagnostics T8016177a.java
 */
import java.util.List;

class T8016177a {

    interface ToIntFunction<X> {
        int m(X x);
    }

    interface Function<X, Y> {
        Y m(X x);
    }

    <T,R> void m1(List<T> s, Function<T,R> f) { }
    <T,R> void m1(List<T> s, ToIntFunction<T> f) { }

    <T,R> List<R> m2(List<T> s, Function<T,R> f) { return null; }
    <T,R> List<R> m2(List<T> s, ToIntFunction<T> f) { return null; }

    <T,R> List<T> m3(List<T> s, Function<T,R> f) { return null; }
    <T,R> List<R> m3(List<T> s, ToIntFunction<T> f) { return null; }

    <T,R> List<T> m4(List<T> s, Function<T,R> f) { return null; }
    <T,R> List<T> m4(List<T> s, ToIntFunction<T> f) { return null; }

    <T,R> List<R> m5(List<T> s, Function<T,R> f) { return null; }
    <T,R> List<T> m5(List<T> s, ToIntFunction<T> f) { return null; }

    <T extends R,R> List<R> m6(List<T> s, Function<T,R> f) { return null; }
    <T extends R,R> List<T> m6(List<T> s, ToIntFunction<T> f) { return null; }

    void test(List<String> ss) {
         m1(ss, s->s.length()); //ambiguous
         m2(ss, s->s.length()); //ambiguous
         m3(ss, s->s.length()); //ambiguous
         m4(ss, s->s.length()); //ambiguous
         m5(ss, s->s.length()); //ambiguous
         m6(ss, s->s.length()); //ambiguous
    }
}