- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
working with inner classes
Thu, 2009-09-03, 10:58
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
Thu, 2009-09-03, 15:57
#2
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
>>
>>
>
>
>
Thu, 2009-09-03, 16:27
#3
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
>>>
>>>
>>
>>
>>
>
>
Thu, 2009-09-03, 17:47
#4
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
>>>>
>>>>
>>>
>>>
>>
>
>
>
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
>
>