test/langtools/tools/javac/generics/diamond/neg/Neg13.java
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29776
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     1
/*
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     2
 * @test /nodynamiccopyright/
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     3
 * @bug 8062373
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     4
 *
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     5
 * @summary  Test diamond + anonymous classes with abstract super type
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     6
 * @author sadayapalam
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     7
 * @compile/fail/ref=Neg13.out Neg13.java -XDrawDiagnostics
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     8
 *
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     9
 */
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    10
class Neg13 {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    11
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    12
    static abstract class A<T> {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    13
        abstract void foo();
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    14
    }
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    15
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    16
    static void foo(A<String> as) {}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    17
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    18
    public static void main(String[] args) {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    19
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    20
        // Method invocation context - good <>(){}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    21
        foo(new A<>() {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    22
            public void foo() {}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    23
        });
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    24
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    25
        // Assignment context - good <>(){}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    26
        A<?> aq = new A<>() {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    27
            public void foo() {}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    28
        };
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    29
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    30
        // When the anonymous type subtypes an abstract class but is missing definitions for
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    31
        // abstract methods, expect no overload resolution error, but an attribution error
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    32
        // while attributing anonymous class body.
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    33
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    34
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    35
        // Method invocation context - bad <>(){}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    36
        foo(new A<>() {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    37
        });
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    38
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    39
        // Assignment invocation context - bad <>(){}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    40
        aq = new A<>() {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    41
        };
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    42
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    43
        // Method invocation context - bad <>()
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    44
        foo(new A<>());
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    45
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    46
        // Assignment invocation context - bad <>()
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    47
        aq = new A<>();
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    48
    }
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    49
}