Re: object.getClass is still an error in annotation

Rodrigo Cano <[email protected]>
Newsgroups gmane.comp.lang.scala
Message-ID <CAM5b94gvhtFhcYfCVEDLEMn8TrrmmHVtMj_pRqH_wN7vE4Q3qw@mail.gmail.com>
@Oliver you are writing that statement in the wrong position, you can only
use <Singleton>.type in a place were a type is expected:

scala> object O
defined object O

scala> val theO: O.type = O
theO: O.type = O$@39ed3c8d


On Wed, Mar 25, 2015 at 4:47 PM, Oliver Ruebenacker <[email protected]>
wrote:

>
>      Hello,
>
>   Isn't the problem with O.type, rather than with object.getClass?
>
> scala> object O
> defined object O
>
> scala> O.type
> <console>:1: error: identifier expected but 'type' found.
>        O.type
>          ^
>
>      Best, Oliver
>
> On Wed, Mar 25, 2015 at 3:26 PM, Simon Schäfer <[email protected]> wrote:
>
>>  scala> object O
>> defined object O
>>
>> scala> classOf[O.type]
>> <console>:9: error: class type required but O.type found
>>               classOf[O.type]
>>                        ^
>>
>> It is broken. Therefore
>>
>> scala> :paste
>> // Entering paste mode (ctrl-D to finish)
>>
>> @pickling.directSubclasses(Array(classOf[O1.type]))
>> sealed abstract class C(val a: Int)
>> object O1 extends C(1)
>>
>> // Exiting paste mode, now interpreting.
>>
>> <console>:7: error: class type required but O1.type found
>>        @pickling.directSubclasses(Array(classOf[O1.type]))
>>                                                   ^
>>
>> is also broken. There is another thing broken:
>>
>> scala> :paste
>> // Entering paste mode (ctrl-D to finish)
>>
>> @pickling.directSubclasses(Array(O1T))
>> sealed abstract class C(val a: Int)
>> object O1 extends C(1)
>> final val O1T = O1.getClass
>>
>> // Exiting paste mode, now interpreting.
>>
>> <console>:7: error: annotation argument needs to be a constant; found:
>> this.O1T
>>        @pickling.directSubclasses(Array(O1T))
>>                                         ^
>>
>> One workaround is:
>>
>> scala> :paste
>> // Entering paste mode (ctrl-D to finish)
>>
>> @pickling.directSubclasses(Array(classOf[O1]))
>> sealed abstract class C(val a: Int)
>> case class O1() extends C(1)
>>
>> // Exiting paste mode, now interpreting.
>>
>> defined class C
>> defined class O1
>>
>> Not that awesome. Does anyone know another workaround? I don't even ask
>> if anyone has the time to fix these - I don't know - 10 year old bugs (one
>> ticket is https://issues.scala-lang.org/browse/SI-2453).
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "scala-language" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Oliver Ruebenacker
> Solutions Architect at Altisource Labs <http://www.altisourcelabs.com/>
> Be always grateful, but never satisfied.
>
> --
> You received this message because you are subscribed to the Google Groups
> "scala-language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.