test/tools/javac/lambda/MostSpecific13.java

changeset 2395
9c577131ffa6
parent 0
959103a6100f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/MostSpecific13.java	Wed May 14 15:41:28 2014 -0600
     1.3 @@ -0,0 +1,21 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8034223
     1.7 + * @summary Most-specific testing with inference variables in function parameter types
     1.8 + * @compile/fail/ref=MostSpecific13.out -XDrawDiagnostics MostSpecific13.java
     1.9 + */
    1.10 +class MostSpecific13 {
    1.11 +
    1.12 +    interface UnaryOp<T> { T apply(T arg); }
    1.13 +    interface IntegerToNumber { Number apply(Integer arg); }
    1.14 +
    1.15 +    <T> void m(UnaryOp<T> f) {}
    1.16 +    void m(IntegerToNumber f) {}
    1.17 +
    1.18 +    void test() {
    1.19 +        m((Integer i) -> i); // error
    1.20 +        m(this::id); // error
    1.21 +    }
    1.22 +
    1.23 +    Integer id(Integer arg) { return arg; }
    1.24 +}
    1.25 \ No newline at end of file

mercurial