Re: object.getClass is still an error in annotation
Oliver Ruebenacker <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CAA=X4ODfBvERZEVoYQ9-RMMf1a7=Mj_RkOsja-NU25oesAbNCw@mail.gmail.com> |
How is the use of O.type related to the message subject and the issue referenced? On Wed, Mar 25, 2015 at 4:11 PM, Rodrigo Cano <[email protected]> wrote: > Thats exactly why he is using .type and not getClass, annotations exists > during compile time, not runtime (the information can be retained, but it > all must exists during compile time, its completely static). > > On Wed, Mar 25, 2015 at 5:08 PM, Oliver Ruebenacker <[email protected]> > wrote: > >> Right! >> >> Still, O.getClass (a method called at run time) and O.type (a constant >> evaluated at compile time) are two different things. >> >> On Wed, Mar 25, 2015 at 4:02 PM, Rodrigo Cano <[email protected]> wrote: >> >>> @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. >>> >> >> >> >> -- >> 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. > -- 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.