Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inherited macro implementation not found #6650

Closed
scabug opened this issue Nov 11, 2012 · 2 comments
Closed

inherited macro implementation not found #6650

scabug opened this issue Nov 11, 2012 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Nov 11, 2012

scala> import reflect.macros.Context
import reflect.macros.Context

scala> abstract class MacroBase {
     |   def macroImpl[T: c.WeakTypeTag](c: Context)(body: c.Expr[T]): c.Expr[Any] = c.universe.reify(body.splice)
     | }
defined class MacroBase

scala> object Macro extends MacroBase {
     |   def macroDecl[T](body: T) = macro macroImpl[T]
     | }
defined module Macro

scala> Macro.macroDecl(0)
error: macro implementation not found: macroDecl (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)

By contrast, this works:

scala> import reflect.macros.Context
import reflect.macros.Context

scala> abstract class MacroBase {
     |   def macroImpl[T: c.WeakTypeTag](c: Context)(body: c.Expr[T]): c.Expr[Any] = c.universe.reify(body.splice)
     | }
defined class MacroBase

scala> object Macro extends MacroBase {
     |   def macroDecl[T](body: T) = macro macroImpl[T]
     |   override def macroImpl[T: c.WeakTypeTag](c: Context)(body: c.Expr[T]): c.Expr[Any] = super.macroImpl[T](c)(body)
     | }
defined module Macro

scala> Macro.macroDecl(0)
res2: Int = 0
@scabug
Copy link
Author

scabug commented Nov 11, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6650?orig=1
Reporter: @retronym
Affected Versions: 2.10.0-RC2

@scabug
Copy link
Author

scabug commented Nov 11, 2012

@xeno-by said:
#5753

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants