[Issue 8389] Classes, nested in the same base class cannot be derived from.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jul 14 05:09:38 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8389
Guillaume Chatelet <chatelet.guillaume at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |chatelet.guillaume at gmail.co
| |m
--- Comment #1 from Guillaume Chatelet <chatelet.guillaume at gmail.com> 2012-07-14 05:09:35 PDT ---
Indeed. The following is valid Java code and I would have expected it to work
with D too as D took the Java way for OOP.
class Fruit {
class Seed {
}
}
class Apple extends Fruit {
class AppleSeed extends Fruit.Seed {
Apple getOuter() {
return Apple.this;
}
}
}
class Main {
public static void main(String[] args) {
final Apple apple = new Apple();
final Apple.AppleSeed appleSeed = apple.new AppleSeed();
assert (appleSeed instanceof Fruit.Seed);
assert (apple == appleSeed.getOuter());
assert (appleSeed.getOuter() instanceof Apple);
assert (appleSeed.getOuter() instanceof Fruit);
}
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list