File: TargetType24.java

package info (click to toggle)
libnb-javaparser-java 7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 35,940 kB
  • ctags: 55,696
  • sloc: java: 264,137; xml: 2,781; sh: 1,135; makefile: 425
file content (39 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * @test /nodynamiccopyright/
 * @bug 8003280
 * @summary Add lambda tests
 *  check case of nested method calls with lambda expression
 * @compile/fail/ref=TargetType24.out -XDrawDiagnostics TargetType24.java
 */

class TargetType24 {

    interface F<A, B> {
        B f(A a);
    }

    interface FSub<A, B> extends F<A,B> { }

    static class Array<A> {
        boolean forAll(final F<A, Boolean> f) {
            return false;
        }

        String forAll(final FSub<A, String> f) {
            return "";
        }

        String forAll2(final FSub<A, String> f) {
            return "";
        }
    }

    void test(Array<String> as, final Array<Character> ac) {
        final boolean b1 = as.forAll(s -> ac.forAll(c -> false)); //ok
        final String s1 = as.forAll2(s -> ac.forAll2(c -> "")); //ok
        final boolean b2 = as.forAll(s -> ac.forAll(c -> "" )); //fail
        final String s2 = as.forAll2(s -> ac.forAll2(c -> false)); //fail
        final boolean b3 = as.forAll((F<String, Boolean>)s -> ac.forAll((F<Character, Boolean>)c -> "")); //fail
        final String s3 = as.forAll((FSub<String, String>)s -> ac.forAll((FSub<Character, String>)c -> false)); //fail
    }
}