<div class="gmail_quote">On Sat, Jul 14, 2012 at 1:36 PM, Guillaume Chatelet <span dir="ltr"><<a href="mailto:chatelet.guillaume@gmail.com" target="_blank">chatelet.guillaume@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 07/13/12 21:41, Andrei Alexandrescu wrote:<br>
> On 7/13/12 3:36 PM, Gor Gyolchanyan wrote:<br>
>> The initial question was: why does DMD 2.059 reject this if this makes<br>
>> sense?<br>
>> It's not even a new feature. It's a (possibly) new (and apparently<br>
>> sensible) use case of an existing feature.<br>
><br>
> I think the simple answer is there was no provision for it. The feature<br>
> copies the Java feature, and I don't think Java has something like what<br>
> you defined.<br>
><br>
> Andrei<br>
><br>
<br>
</div></div>class Fruit {<br>
    class Seed {<br>
    }<br>
}<br>
<br>
class Apple extends Fruit {<br>
    class AppleSeed extends Fruit.Seed {<br>
        Apple getOuter() {<br>
            return Apple.this;<br>
        }<br>
    }<br>
}<br>
<br>
class Main {<br>
    public static void main(String[] args) {<br>
        final Apple apple = new Apple();<br>
        final Apple.AppleSeed appleSeed = apple.new AppleSeed();<br>
        assert (appleSeed instanceof Fruit.Seed);<br>
        assert (apple == appleSeed.getOuter());<br>
        assert (appleSeed.getOuter() instanceof Apple);<br>
        assert (appleSeed.getOuter() instanceof Fruit);<br>
    }<br>
}<br>
<br>
This is valid Java code actually and I agree with Gor I would have<br>
expected it to work with D.<br>
<span class="HOEnZb"><font color="#888888"><br>
Guillaume<br>
</font></span></blockquote></div><br>I didn't even know this worked in Java. This means, that nested classed in D can't translate nested classed in Java after all.<br clear="all"><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>