subclass from inner class

15 views
Skip to first unread message

Chris Cannam

unread,
Mar 1, 2012, 3:25:03 PM3/1/12
to yeti-lang
Is it possible to construct a Java class in Yeti which extends a Java
nested interface?

i.e. inheriting from the B in

public class A {
public static interface B { }
}


Chris

chrisichris

unread,
Mar 2, 2012, 2:30:09 AM3/2/12
to yeti-lang
Naming Java inner-classes is with the plain class-name as javac makes
ist using $ as separater. In your example A$B.

So to extend interface B in yeti:

class Foo extends A$B
...
end;

Chris

Chris Cannam

unread,
Mar 2, 2012, 5:33:20 AM3/2/12
to yeti...@googlegroups.com
On 2 March 2012 07:30, chrisichris <christ...@googlemail.com> wrote:
> So to extend interface B in yeti:
>
> class Foo extends A$B

Thanks... I had tried that, but it hadn't worked in my context and so
I didn't persist with it.

It turns out that Yeti won't find the contained class or interface if
the containing one is in a different package, unless you name the
package explicitly when inheriting.

That is, if I have in Java

package p;


public class A {
public static interface B { }
}

then in Yeti I can do

import p: A;
class C extends p.A$B end;

but not

import p: A;
class C extends A$B end;

("Unknown class: A$B")

even though

import p: A;
class C extends A end;

works as expected.


Chris

chrisichris

unread,
Mar 2, 2012, 7:09:22 AM3/2/12
to yeti-lang
I have not tried it, but I think you have to :

import p:A$B;

class C extends A$B ...

Chris

On 2 Mrz., 11:33, Chris Cannam <can...@all-day-breakfast.com> wrote:

Chris Cannam

unread,
Mar 2, 2012, 11:00:41 AM3/2/12
to yeti...@googlegroups.com
On 2 March 2012 12:09, chrisichris <christ...@googlemail.com> wrote:
> I have not tried it, but I think you have to :
>
> import p:A$B;

Doh! Obvious as it seems in hindsight, I never thought of that. Thanks!


Chris

Reply all
Reply to author
Forward
0 new messages