test/langtools/tools/javac/generics/diamond/neg/Neg04.java
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 29776 langtools/test/tools/javac/generics/diamond/neg/Neg04.java@984a79b71cfe
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5321
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
     1
/*
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
29776
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
     3
 * @bug 6939620 7020044 8062373
5321
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
     4
 *
8635
383a416a2bdf 7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents: 5327
diff changeset
     5
 * @summary  Check that diamond fails when inference violates declared bounds
383a416a2bdf 7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents: 5327
diff changeset
     6
 *           (test with local class, qualified/simple type expressions)
5321
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
     7
 * @author mcimadamore
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
     8
 * @compile/fail/ref=Neg04.out Neg04.java -XDrawDiagnostics
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
     9
 *
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    10
 */
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    11
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    12
class Neg04 {
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    13
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    14
    void test() {
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    15
        class Foo<V extends Number> {
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    16
            Foo(V x) {}
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    17
            <Z> Foo(V x, Z z) {}
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    18
        }
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    19
        Foo<String> n1 = new Foo<>("");
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    20
        Foo<? extends String> n2 = new Foo<>("");
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    21
        Foo<?> n3 = new Foo<>("");
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    22
        Foo<? super String> n4 = new Foo<>("");
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    23
8635
383a416a2bdf 7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents: 5327
diff changeset
    24
        Foo<String> n5 = new Foo<>("", "");
383a416a2bdf 7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents: 5327
diff changeset
    25
        Foo<? extends String> n6 = new Foo<>("", "");
383a416a2bdf 7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents: 5327
diff changeset
    26
        Foo<?> n7 = new Foo<>("", "");
383a416a2bdf 7020044: Project Coin: diamond erroneous allowed on some anonymous inner classes
mcimadamore
parents: 5327
diff changeset
    27
        Foo<? super String> n8 = new Foo<>("", "");
29776
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    28
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    29
        Foo<String> n9 = new Foo<>(""){};
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    30
        Foo<? extends String> n10 = new Foo<>(""){};
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    31
        Foo<?> n11 = new Foo<>(""){};
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    32
        Foo<? super String> n12 = new Foo<>(""){};
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    33
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    34
        Foo<String> n13 = new Foo<>("", ""){};
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    35
        Foo<? extends String> n14 = new Foo<>("", ""){};
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    36
        Foo<?> n15 = new Foo<>("", ""){};
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents: 8635
diff changeset
    37
        Foo<? super String> n16 = new Foo<>("", ""){};
5321
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    38
    }
c8efe769cb3b 6939620: Switch to 'complex' diamond inference scheme
mcimadamore
parents:
diff changeset
    39
}