Reputation: 39366
I can successfully write
import scala.reflect.macros.blackbox
object WhyDeprecated {
def macroImpl[T : context.WeakTypeTag](context: blackbox.Context):
context.Expr[String] =
{
import context.universe._
reify {
context.literal("Hello").splice
}
}
}
Though, Context#literal
is deprecated:
Deprecated (Since version 2.11.0) Use quasiquotes instead
However, quasiquotes do not provide the same type:
context.literal("Hello").splice : context.Expr[String]
q""" "Hello" """ : Universe#Tree
Is there a non-deprecated replacement for Context#literal
which provides an Expr[T]
rather than a Tree
?
Upvotes: 1
Views: 105
Reputation: 53348
Use context.Expr(q""" "Hello" """)
to retrieve an Expr
from a tree.
Upvotes: 2