What is this "CASEACCESSOR" modifier reported by showRaw(reify(expr)) ?

106 views
Skip to first unread message

Rob Nikander

unread,
May 13, 2013, 1:34:39 PM5/13/13
to scala-user
Hi,

It seems like the reflection function showRaw is reporting a modifier
that doesn't exist. I'm trying to write a macro that generates a case
class definition, among other things. To see what the AST should look
like, I open a scala prompt and run:

scala> import scala.reflect.runtime.universe._
scala> reify( { case class Foo(name: String, id: Long, count:
Int) } )
res2: ...
scala> showRaw(res2)
res3: String = Expr(Block(List(ClassDef(Modifiers(CASE),
newTypeName("Foo"), List(),
Template(List(Ident(scala.Product),
Ident(scala.Serializable)), emptyValDef,
List(ValDef(Modifiers(CASEACCESSOR | PARAMACCESSOR),
newTermName("name"), ...

But there is nothing called CASEACCESSOR or PARAMACCESSOR in:

http://www.scala-lang.org/api/2.10.1/index.html#scala.reflect.api.FlagSets$FlagValues

How do I build this tree? Any ideas? Thank you,

Rob

Eugene Burmako

unread,
May 13, 2013, 1:42:49 PM5/13/13
to Rob Nikander, scala-user
Currently the situation with flags in the reflection API is quite dire. You need to use `scala.reflect.internal.Flags.CASEACCESSOR` and `PARAMACCESSOR` and then cast them to FlagSet. Maybe we'll be able to improve on that in 2.11.0.



--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Rob Nikander

unread,
May 13, 2013, 3:25:49 PM5/13/13
to scala-user
Thanks, that works.

On May 13, 1:42 pm, Eugene Burmako <eugene.burm...@epfl.ch> wrote:
> Currently the situation with flags in the reflection API is quite dire. You
> need to use `scala.reflect.internal.Flags.CASEACCESSOR` and `PARAMACCESSOR`
> and then cast them to FlagSet. Maybe we'll be able to improve on that in
> 2.11.0.
>
> On 13 May 2013 19:34, Rob Nikander <rob.nikan...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > It seems like the reflection function showRaw is reporting a modifier
> > that doesn't exist. I'm trying to write a macro that generates a case
> > class definition, among other things. To see what the AST should look
> > like, I open a scala prompt and run:
>
> >     scala> import scala.reflect.runtime.universe._
> >     scala> reify( { case class Foo(name: String, id: Long, count:
> > Int) } )
> >     res2: ...
> >     scala> showRaw(res2)
> >     res3: String = Expr(Block(List(ClassDef(Modifiers(CASE),
> > newTypeName("Foo"), List(),
> >         Template(List(Ident(scala.Product),
> > Ident(scala.Serializable)), emptyValDef,
> >         List(ValDef(Modifiers(CASEACCESSOR | PARAMACCESSOR),
> > newTermName("name"), ...
>
> > But there is nothing called CASEACCESSOR or PARAMACCESSOR in:
>
> >http://www.scala-lang.org/api/2.10.1/index.html#scala.reflect.api.Fla...

Léonard Schneider

unread,
May 29, 2013, 3:32:37 PM5/29/13
to scala...@googlegroups.com, Rob Nikander
Hi Eugene,

I came across this issue on 2.11 and fortunately found this thread. Is it tracked in some issue on JIRA?

BR,

Leo

Eugene Burmako

unread,
May 29, 2013, 4:51:52 PM5/29/13
to Léonard Schneider, scala-user, Rob Nikander
Reply all
Reply to author
Forward
0 new messages