This page is no longer maintained — Please continue to the home page at www.scala-lang.org

working with inner classes

4 replies
xylo
Joined: 2009-08-04,
User offline. Last seen 50 weeks 2 days ago.

Hello,

yesterday I upgraded the Scala compiler to the latest svn version and now I got some problems with nested classes.

Until now I used the following form to encapsulate an inner class:

class Outer // used for instances
object Outer {
class Inner
}

Thereby I could easily import the class Inner in other Java and Scala classes via
import Outer.Inner;

But with the latest svn version of the Scala compiler this is not possible anymore. In Java classes the import of Outer.Inner fails. I'm not
sure if this is a bug or just not designed for this usage.

The alternative as described in the Scala tour about "Inner Classes" (http://www.scala-lang.org/node/115) is IMO not really a good
alternative, because you cannot import the Inner directly via
import Outer#Inner;
in a Java class (compiler error). That means you can only import Outer and have to write Outer#Inner wherever you want to use Inner.

What do you think? Should Outer.Inner also work or is Outer#Inner the only valid solution?

Regards,
Stefan

Iulian Dragos
Joined: 2008-12-18,
User offline. Last seen 42 years 45 weeks ago.
Re: working with inner classes

This is the result of a change I did a couple of days ago, fixing
ticket http://lampsvn.epfl.ch/trac/scala/ticket/1572 I might have been
overly optimistic. I'll see if I can make both proguard and Java-Scala
references work.

iulian

On Thu, Sep 3, 2009 at 11:58 AM, Stefan Endrullis wrote:
> Hello,
>
> yesterday I upgraded the Scala compiler to the latest svn version and now I got some problems with nested classes.
>
> Until now I used the following form to encapsulate an inner class:
>
> class Outer // used for instances
> object Outer {
>  class Inner
> }
>
> Thereby I could easily import the class Inner in other Java and Scala classes via
>  import Outer.Inner;
>
> But with the latest svn version of the Scala compiler this is not possible anymore. In Java classes the import of Outer.Inner fails. I'm not
> sure if this is a bug or just not designed for this usage.
>
> The alternative as described in the Scala tour about "Inner Classes" (http://www.scala-lang.org/node/115) is IMO not really a good
> alternative, because you cannot import the Inner directly via
>  import Outer#Inner;
> in a Java class (compiler error). That means you can only import Outer and have to write Outer#Inner wherever you want to use Inner.
>
> What do you think? Should Outer.Inner also work or is Outer#Inner the only valid solution?
>
> Regards,
> Stefan
>
>

xylo
Joined: 2009-08-04,
User offline. Last seen 50 weeks 2 days ago.
Re: working with inner classes

OK. Thank you.

Stefan

Iulian Dragos schrieb:
> This is the result of a change I did a couple of days ago, fixing
> ticket http://lampsvn.epfl.ch/trac/scala/ticket/1572 I might have been
> overly optimistic. I'll see if I can make both proguard and Java-Scala
> references work.
>
> iulian
>
> On Thu, Sep 3, 2009 at 11:58 AM, Stefan Endrullis wrote:
>> Hello,
>>
>> yesterday I upgraded the Scala compiler to the latest svn version and now I got some problems with nested classes.
>>
>> Until now I used the following form to encapsulate an inner class:
>>
>> class Outer // used for instances
>> object Outer {
>> class Inner
>> }
>>
>> Thereby I could easily import the class Inner in other Java and Scala classes via
>> import Outer.Inner;
>>
>> But with the latest svn version of the Scala compiler this is not possible anymore. In Java classes the import of Outer.Inner fails. I'm not
>> sure if this is a bug or just not designed for this usage.
>>
>> The alternative as described in the Scala tour about "Inner Classes" (http://www.scala-lang.org/node/115) is IMO not really a good
>> alternative, because you cannot import the Inner directly via
>> import Outer#Inner;
>> in a Java class (compiler error). That means you can only import Outer and have to write Outer#Inner wherever you want to use Inner.
>>
>> What do you think? Should Outer.Inner also work or is Outer#Inner the only valid solution?
>>
>> Regards,
>> Stefan
>>
>>
>
>
>

Iulian Dragos
Joined: 2008-12-18,
User offline. Last seen 42 years 45 weeks ago.
Re: working with inner classes

Should work again now.

On Thu, Sep 3, 2009 at 4:51 PM, Stefan Endrullis wrote:
> OK. Thank you.
>
> Stefan
>
> Iulian Dragos schrieb:
>> This is the result of a change I did a couple of days ago, fixing
>> ticket http://lampsvn.epfl.ch/trac/scala/ticket/1572 I might have been
>> overly optimistic. I'll see if I can make both proguard and Java-Scala
>> references work.
>>
>> iulian
>>
>> On Thu, Sep 3, 2009 at 11:58 AM, Stefan Endrullis wrote:
>>> Hello,
>>>
>>> yesterday I upgraded the Scala compiler to the latest svn version and now I got some problems with nested classes.
>>>
>>> Until now I used the following form to encapsulate an inner class:
>>>
>>> class Outer // used for instances
>>> object Outer {
>>>  class Inner
>>> }
>>>
>>> Thereby I could easily import the class Inner in other Java and Scala classes via
>>>  import Outer.Inner;
>>>
>>> But with the latest svn version of the Scala compiler this is not possible anymore. In Java classes the import of Outer.Inner fails. I'm not
>>> sure if this is a bug or just not designed for this usage.
>>>
>>> The alternative as described in the Scala tour about "Inner Classes" (http://www.scala-lang.org/node/115) is IMO not really a good
>>> alternative, because you cannot import the Inner directly via
>>>  import Outer#Inner;
>>> in a Java class (compiler error). That means you can only import Outer and have to write Outer#Inner wherever you want to use Inner.
>>>
>>> What do you think? Should Outer.Inner also work or is Outer#Inner the only valid solution?
>>>
>>> Regards,
>>> Stefan
>>>
>>>
>>
>>
>>
>
>

xylo
Joined: 2009-08-04,
User offline. Last seen 50 weeks 2 days ago.
Re: working with inner classes

Yes, it works again! Thank you very much.

Stefan

Iulian Dragos schrieb:
> Should work again now.
>
> On Thu, Sep 3, 2009 at 4:51 PM, Stefan Endrullis wrote:
>> OK. Thank you.
>>
>> Stefan
>>
>> Iulian Dragos schrieb:
>>> This is the result of a change I did a couple of days ago, fixing
>>> ticket http://lampsvn.epfl.ch/trac/scala/ticket/1572 I might have been
>>> overly optimistic. I'll see if I can make both proguard and Java-Scala
>>> references work.
>>>
>>> iulian
>>>
>>> On Thu, Sep 3, 2009 at 11:58 AM, Stefan Endrullis wrote:
>>>> Hello,
>>>>
>>>> yesterday I upgraded the Scala compiler to the latest svn version and now I got some problems with nested classes.
>>>>
>>>> Until now I used the following form to encapsulate an inner class:
>>>>
>>>> class Outer // used for instances
>>>> object Outer {
>>>> class Inner
>>>> }
>>>>
>>>> Thereby I could easily import the class Inner in other Java and Scala classes via
>>>> import Outer.Inner;
>>>>
>>>> But with the latest svn version of the Scala compiler this is not possible anymore. In Java classes the import of Outer.Inner fails. I'm not
>>>> sure if this is a bug or just not designed for this usage.
>>>>
>>>> The alternative as described in the Scala tour about "Inner Classes" (http://www.scala-lang.org/node/115) is IMO not really a good
>>>> alternative, because you cannot import the Inner directly via
>>>> import Outer#Inner;
>>>> in a Java class (compiler error). That means you can only import Outer and have to write Outer#Inner wherever you want to use Inner.
>>>>
>>>> What do you think? Should Outer.Inner also work or is Outer#Inner the only valid solution?
>>>>
>>>> Regards,
>>>> Stefan
>>>>
>>>>
>>>
>>>
>>
>
>
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland