File: Neg12.java

package info (click to toggle)
libnb-javaparser-java 9%2B2018-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 65,172 kB
  • sloc: java: 440,096; xml: 6,359; sh: 865; makefile: 314
file content (33 lines) | stat: -rw-r--r-- 898 bytes parent folder | download | duplicates (21)
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
/*
 * @test /nodynamiccopyright/
 * @bug 8062373
 *
 * @summary  Test diamond + anonymous classes with non-denotable types
 * @author mcimadamore
 * @compile/fail/ref=Neg12.out Neg12.java -XDrawDiagnostics
 *
 */

 class Neg12 {
    static class Foo<X> {
        Foo(X x) {  }
    }

    static class DoubleFoo<X,Y> {
        DoubleFoo(X x,Y y) {  }
    }

    static class TripleFoo<X,Y,Z> {
        TripleFoo(X x,Y y,Z z) {  }
    }

    Foo<? extends Integer> fi = new Foo<>(1);
    Foo<?> fw = new Foo<>(fi) {}; // Error.
    Foo<?> fw1 = new Foo<>(fi); // OK.
    Foo<? extends Double> fd = new Foo<>(3.0);
    DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd) {}; // Error.
    DoubleFoo<?,?> dw1 = new DoubleFoo<>(fi,fd); // OK.
    Foo<String> fs = new Foo<>("one");
    TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs) {}; // Error.
    TripleFoo<?,?,?> tw1 = new TripleFoo<>(fi,fd,fs); // OK.
 }