langtools/test/tools/javac/nested/5009484/X.java
author jlahoda
Thu, 09 Oct 2014 10:08:52 +0200
changeset 26993 513b2cae81c3
parent 25310 a2e7f254f886
permissions -rw-r--r--
8057652: Request to improve error messages for labeled declarations Summary: Parse labeled statements as block statements to improve error recovery for labeled declarations; related cleanup. Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
25310
a2e7f254f886 8046770: .out files for assert, boxing, and overload tests in tools/javac dir
sogoel
parents: 5520
diff changeset
     2
 * @test    /nodynamiccopyright/
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * @bug     5009484
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 * @summary Compiler fails to resolve appropriate type for outer member
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * @author  Philippe P Mulet
25310
a2e7f254f886 8046770: .out files for assert, boxing, and overload tests in tools/javac dir
sogoel
parents: 5520
diff changeset
     6
 * @compile/fail/ref=X.out -XDrawDiagnostics  X.java
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
public class X<T> {
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
   private T t;
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
   X(T t) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
       this.t = t;
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
   }
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
   public static void main(String[] args) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
       new X<String>("OUTER").bar();
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
   }
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
   void bar() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
       new X<X>(this) {     // #1
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
           void run() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
               new Object() {  // #2
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
                   void run() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
                       X x = t;        // #3 <--- which t is bound ?
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
                   System.out.println(x);
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
                   }
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
               }.run();
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
           }
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
       }.run();
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
   }
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
}