Menu ▾ ▴

#30 incorrect outer instance (2)

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

The Pizza compiler fails the following javac regression
test

/**
* @test @(#)WhichImplicitThis2.java 1.1 02/06/04
* @bug 4635044
* @summary Invalid error when implicitly referencing
enclosing type
*
* @compile WhichImplicitThis2.java
* @run main WhichImplicitThis2
*/

/** Check that hiding prevents enclosing class
selection. */
public class WhichImplicitThis2 {
boolean isT() { return true; }
class Middle {
boolean enclIsT() { return
WhichImplicitThis2.this.isT(); }
}
class X extends WhichImplicitThis2 {
boolean isT() { return false; }
class Middle {} // hide WhichImplicitThis2.Middle
boolean check() {
return /*WhichImplicitThis2.this.*/new
WhichImplicitThis2.Middle().enclIsT();
}
}
public static void main(String[] args) {
WhichImplicitThis2 t = new WhichImplicitThis2();
X x = t.new X();
if (!x.check()) throw new Error();
}
}

Discussion


Log in to post a comment.