Skip to content

Nested macro that has Nothing type parameter causes "macro has not been expanded" #9889

Open
@scabug

Description

@scabug
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_77).
Type in expressions for evaluation. Or try :help.

scala> object NestedMacro {
     |   import scala.reflect.macros.whitebox
     |   import scala.language.experimental.macros
     |   final case class RichOption[A](underlying: Option[A]) {
     |     def getThis: RichOption[A] = macro MacroBundle.getThis_impl
     |   }
     |   def wrapper(body: Any): Unit = macro MacroBundle.wrapper_impl
     |   final class MacroBundle(val c: whitebox.Context) {
     |     import c.universe._
     |     def getThis_impl: Tree = {
     |       val q"$x.$y" = c.macroApplication
     |       x
     |     }
     |     def wrapper_impl(body: Tree): Tree = {
     |       q"()"
     |     }
     |   }
     | }
defined object NestedMacro

scala> NestedMacro.wrapper(NestedMacro.RichOption(Some(1)).getThis) // Compiles

scala> NestedMacro.RichOption(None).getThis // Compiles
res1: NestedMacro.RichOption[A] = RichOption(None)

scala> NestedMacro.wrapper(NestedMacro.RichOption(None).getThis) // Does not comiple
<console>:13: error: macro has not been expanded
       NestedMacro.wrapper(NestedMacro.RichOption(None).getThis) // Does not comiple
                   ^

scala> NestedMacro.RichOption(???).getThis // Compiles
scala.NotImplementedError: an implementation is missing
  at scala.Predef$.$qmark$qmark$qmark(Predef.scala:230)
  ... 32 elided

scala> NestedMacro.wrapper(NestedMacro.RichOption(???).getThis) // Does not comiple
<console>:13: error: macro has not been expanded
       NestedMacro.wrapper(NestedMacro.RichOption(???).getThis) // Does not comiple
                   ^

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions