Re: object.getClass is still an error in annotation
Oliver Ruebenacker <[email protected]>
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <CAA=X4OAM9P_g=wg2AsN8KE=C+WnFS10SP5mhyadY+=TDfjvJFg@mail.gmail.com> |
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.