test/tools/javac/lambda/TargetType45.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/tools/javac/lambda/TargetType45.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,29 @@
     1.4 +/*
     1.5 + * @test /nodynamiccopyright/
     1.6 + * @bug 8003280
     1.7 + * @summary Add lambda tests
     1.8 + *  compiler crashes during flow analysis as it fails to report diagnostics during attribution
     1.9 + * @compile TargetType45.java
    1.10 + */
    1.11 +class TargetType45 {
    1.12 +
    1.13 +    interface Predicate<X> {
    1.14 +        boolean apply(X x);
    1.15 +    }
    1.16 +
    1.17 +    interface Mapper<X, Y> {
    1.18 +        Y apply(X x);
    1.19 +    }
    1.20 +
    1.21 +    class Foo<X> {
    1.22 +        Foo<X> filter(Predicate<? super X> p) { return null; }
    1.23 +    }
    1.24 +
    1.25 +    static <U, V> Predicate<U> compose(Predicate<? super V> pi, Mapper<? super U, ? extends V> m) { return null; }
    1.26 +
    1.27 +    static Predicate<Integer> isOdd = i -> i % 2 != 0;
    1.28 +
    1.29 +    void top10Counties(Foo<String> foos) {
    1.30 +        foos.filter(compose(isOdd, (String e) -> e.length()));
    1.31 +    }
    1.32 +}

mercurial