test/langtools/tools/javac/generics/diamond/neg/Neg17.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
 * @summary Test that the anonymous class constructor appears to returns a Foo<T>, when it actually returns a Anon$1. (status as of now - may change in future)
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     5
 * @compile/fail/ref=Neg17.out Neg17.java -XDrawDiagnostics
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     6
 */
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     7
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
     8
import java.util.Collections;
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
abstract class Neg17<T> {
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
   abstract void m();
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    13
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    14
   public static void main(String[] args) {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    15
       Collections.singletonList(new Neg17<>() { void m() {} }).get(0).m(); // good.
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    16
       Collections.singletonList(new Neg17<>() {
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    17
                 void m() {}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    18
                 private void n() {}
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    19
           }).get(0).n(); // bad unknown method n()
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    20
   }
984a79b71cfe 8062373: Project Coin: diamond and anonymous classes
sadayapalam
parents:
diff changeset
    21
}