Menu ▾ ▴

#33 incorrect outer instance (5)

open
nobody
5
2002-09-09
2002-09-09
No

The Pizza compiler fails to compile the following javac
regression test.

/**
* @test @(#)WhichImplicitThis5.java 1.3 02/09/04
* @bug 4717593
* @summary Hiding of fields not fully supported
*
* @compile WhichImplicitThis5.java
* @run main WhichImplicitThis5
*/

public class WhichImplicitThis5 {
static int init;
public int i = ++init;
class One extends WhichImplicitThis5 {
private Object i; // hide enclosing i
}
class Two extends One {
// has no i member
Two() {
WhichImplicitThis5.this.super();
}
int j = i; // i from enclosing scope
int k = ((WhichImplicitThis5) this).i; // get
hidden i
Object l = super.i;
}
public static void main(String[] args) {
Two t = new WhichImplicitThis5().new Two();
if (t.j != 1 || t.k != 2 || t.l != null)
throw new Error();
}
}

Discussion


Log in to post a comment.