scala - "too few argument lists for macro invocation" -


given following code:

case class jetdim(dimension: int) {   require(dimension > 0) }  object jetdim {   def build(dimension: int): int = macro jetdimmacro.apply } 

and macro calls:

def apply(dimension: int): int = macro applyimpl  def applyimpl(c: context)(dimension: c.expr[int]): c.expr[int] = ... 

i'm getting compile-time error:

[error]  few argument lists macro invocation [error]  def build(dimension: int): int = macro jetdimmacro.apply 

why?

the macro keyword takes method should have context parameter first parameter list (and many expr arguments in subsequent lists). in jetdim you're giving macro method has macro implementation. isn't valid syntax—you can't "nest" macro this. you'll need either call jetdimmacro.apply directly (as normal method call) in jetdim.build, or use macro jetdimmacro.applyimpl (which more want).


Comments