Open
Description
following example in scala 2.12.4:
https://docs.scala-lang.org/overviews/macros/bundles.html
- the following compiles fine:
import scala.language.experimental.macros
import scala.reflect.macros.whitebox.Context
object Macros {
def mono : Unit = macro MacrosImpl.mono
def poly[ T ] : String = macro MacrosImpl.poly[ T ]
}
class MacrosImpl( val c : Context ) {
import c.universe._
def mono : c.Tree = q"${println( 1 )}"
def poly[ T : c.WeakTypeTag ] : c.Expr[ String ] = c.Expr[ String ]( q"${}" )
}
- but after renaming
val c : Context
->val ccc : Context
compilation fails:
import scala.language.experimental.macros
import scala.reflect.macros.whitebox.Context
object Macros {
// error: bundle implementation has incompatible shape: required: : MacrosImpl.this.<none>.Expr[Unit] or
def mono : Unit = macro MacrosImpl.mono
// error: bundle implementations cannot have implicit parameters other than WeakTypeTag evidences
def poly[ T ] : String = macro MacrosImpl.poly[ T ]
}
class MacrosImpl( val ccc : Context ) {
import ccc.universe._
def mono : ccc.Tree = q"${println( 1 )}"
def poly[ T : ccc.WeakTypeTag ] : ccc.Expr[ String ] = ccc.Expr[ String ]( q"${}" )
}
so, c
must stand for something really important? :-)