[Macros] Passing context instance reference to another class
29 views
Skip to first unread message
Alexander Myltsev
unread,
May 11, 2013, 4:02:04 AM5/11/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to scala-l...@googlegroups.com
Hi!
I have code:
object Parser { type ParserContext = Context { type PrefixType = Parser }
def ruleImpl(c: ParserContext)(r: c.Expr[Rule]): c.Expr[Boolean] = { val opTreeContext = new OpTreeContext(c) val opTree = opTreeContext.parse(r.tree) // Compilation error (see below): Parser.scala: type mismatch; opTree.render } }
class OpTreeContext(c: Parser.ParserContext) { import c.universe._
def parse(tree: c.Tree): Expression = ??? }
Compiler is not happy with error: [error] Parser.scala: type mismatch; [error] found : c.universe.Tree [error] required: opTreeContext.c.Tree [error] (which expands to) opTreeContext.c.universe.Tree [error] val opTree = opTreeContext.parse(r.tree) [error] ^
Why type of `c` in OpTreeContext differs from type of `r.tree` in `ruleImpl`? And how to pass instance reference of Parser.ParserContext to another class?
Regards, Alexander
Johannes Rudolph
unread,
May 11, 2013, 5:09:30 AM5/11/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You probably need a type parameter on OpTreeContext for the context.
Johannes
> --
> 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 scala-languag...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>