diff options
58 files changed, 186 insertions, 140 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 4765c301dd..d1045757a5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -111,7 +111,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { * with synthetic content that carries the payload described in `MacroImplBinding`. * * For example, for a pair of macro definition and macro implementation: - * def impl(c: scala.reflect.macros.Context): c.Expr[Unit] = c.literalUnit; + * def impl(c: scala.reflect.macros.Context): c.Expr[Unit] = ??? * def foo: Unit = macro impl * * We will have the following annotation added on the macro definition `foo`: diff --git a/src/reflect/scala/reflect/macros/ExprUtils.scala b/src/reflect/scala/reflect/macros/ExprUtils.scala index af11bd6efc..76a8392b9c 100644 --- a/src/reflect/scala/reflect/macros/ExprUtils.scala +++ b/src/reflect/scala/reflect/macros/ExprUtils.scala @@ -12,41 +12,54 @@ trait ExprUtils { self: Context => /** Shorthand for `Literal(Constant(null))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literalNull: Expr[Null] /** Shorthand for `Literal(Constant(()))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literalUnit: Expr[Unit] /** Shorthand for `Literal(Constant(true))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literalTrue: Expr[Boolean] /** Shorthand for `Literal(Constant(false))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literalFalse: Expr[Boolean] /** Shorthand for `Literal(Constant(x: Boolean))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: Boolean): Expr[Boolean] /** Shorthand for `Literal(Constant(x: Byte))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: Byte): Expr[Byte] /** Shorthand for `Literal(Constant(x: Short))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: Short): Expr[Short] /** Shorthand for `Literal(Constant(x: Int))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: Int): Expr[Int] /** Shorthand for `Literal(Constant(x: Long))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: Long): Expr[Long] /** Shorthand for `Literal(Constant(x: Float))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: Float): Expr[Float] /** Shorthand for `Literal(Constant(x: Double))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: Double): Expr[Double] /** Shorthand for `Literal(Constant(x: String))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: String): Expr[String] /** Shorthand for `Literal(Constant(x: Char))` in the underlying `universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def literal(x: Char): Expr[Char] } diff --git a/src/reflect/scala/reflect/macros/Parsers.scala b/src/reflect/scala/reflect/macros/Parsers.scala index 3b25309614..4232b05f8c 100644 --- a/src/reflect/scala/reflect/macros/Parsers.scala +++ b/src/reflect/scala/reflect/macros/Parsers.scala @@ -8,6 +8,7 @@ package macros * A slice of [[scala.reflect.macros.Context the Scala macros context]] that * exposes functions to parse strings with Scala code into trees. */ +@deprecated("Use quasiquotes instead", "2.11.0") trait Parsers { self: Context => @@ -15,9 +16,11 @@ trait Parsers { * Only works for expressions, i.e. parsing a package declaration will fail. * @throws [[scala.reflect.macros.ParseException]] */ + @deprecated("Use quasiquotes instead", "2.11.0") def parse(code: String): Tree } /** Indicates an error during [[scala.reflect.macros.Parsers#parse]]. */ + @deprecated("Use quasiquotes instead", "2.11.0") case class ParseException(pos: scala.reflect.api.Position, msg: String) extends Exception(msg) diff --git a/src/reflect/scala/reflect/macros/TreeBuilder.scala b/src/reflect/scala/reflect/macros/TreeBuilder.scala index 427b4f70d1..7f57274347 100644 --- a/src/reflect/scala/reflect/macros/TreeBuilder.scala +++ b/src/reflect/scala/reflect/macros/TreeBuilder.scala @@ -8,6 +8,7 @@ package macros * A helper available in [[scala.reflect.macros.Universe]] that defines shorthands for the * most common tree-creating functions. */ +@deprecated("Use quasiquotes instead", "2.11.0") abstract class TreeBuilder { val global: Universe @@ -17,6 +18,7 @@ abstract class TreeBuilder { * The type must be suitable for this. For example, it * must not be a TypeRef pointing to an abstract type variable. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkAttributedQualifier(tpe: Type): Tree /** Builds a reference to value whose type is given stable prefix. @@ -25,27 +27,35 @@ abstract class TreeBuilder { * termSym as the Ident's symbol. In that case, termSym must * not be NoSymbol. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkAttributedQualifier(tpe: Type, termSym: Symbol): Tree /** Builds a typed reference to given symbol with given stable prefix. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkAttributedRef(pre: Type, sym: Symbol): RefTree /** Builds a typed reference to given symbol. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkAttributedRef(sym: Symbol): RefTree /** Builds an untyped reference to given symbol. Requires the symbol to be static. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkUnattributedRef(sym: Symbol): RefTree /** Builds an untyped reference to symbol with given name. Requires the symbol to be static. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkUnattributedRef(fullName: Name): RefTree /** Builds a typed This reference to given symbol. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkAttributedThis(sym: Symbol): This /** Builds a typed Ident with an underlying symbol. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkAttributedIdent(sym: Symbol): RefTree /** Builds a typed Select with an underlying symbol. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkAttributedSelect(qual: Tree, sym: Symbol): RefTree /** A creator for method calls, e.g. fn[T1, T2, ...](v1, v2, ...) @@ -57,22 +67,31 @@ abstract class TreeBuilder { * @param args value arguments * @return the newly created trees. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkMethodCall(receiver: Symbol, methodName: Name, targs: List[Type], args: List[Tree]): Tree + @deprecated("Use quasiquotes instead", "2.11.0") def mkMethodCall(method: Symbol, targs: List[Type], args: List[Tree]): Tree + @deprecated("Use quasiquotes instead", "2.11.0") def mkMethodCall(method: Symbol, args: List[Tree]): Tree + @deprecated("Use quasiquotes instead", "2.11.0") def mkMethodCall(target: Tree, args: List[Tree]): Tree + @deprecated("Use quasiquotes instead", "2.11.0") def mkMethodCall(receiver: Symbol, methodName: Name, args: List[Tree]): Tree + @deprecated("Use quasiquotes instead", "2.11.0") def mkMethodCall(receiver: Tree, method: Symbol, targs: List[Type], args: List[Tree]): Tree + @deprecated("Use quasiquotes instead", "2.11.0") def mkMethodCall(target: Tree, targs: List[Type], args: List[Tree]): Tree + @deprecated("Use quasiquotes instead", "2.11.0") def mkNullaryCall(method: Symbol, targs: List[Type]): Tree /** A tree that refers to the runtime reflexive universe, `scala.reflect.runtime.universe`. */ + @deprecated("Use quasiquotes instead", "2.11.0") def mkRuntimeUniverseRef: Tree } diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala index d1d90f53c9..297bac2999 100644 --- a/src/reflect/scala/reflect/macros/Universe.scala +++ b/src/reflect/scala/reflect/macros/Universe.scala @@ -20,6 +20,7 @@ abstract class Universe extends scala.reflect.api.Universe { /** A factory that encapsulates common tree-building functions. * @group Macros */ + @deprecated("Use quasiquotes instead", "2.11.0") val treeBuild: TreeBuilder { val global: Universe.this.type } /** The API of reflection artifacts that support [[scala.reflect.macros.Attachments]]. diff --git a/test/files/neg/macro-basic-mamdmi.check b/test/files/neg/macro-basic-mamdmi.check index 9328fbd51c..61df5131cc 100644 --- a/test/files/neg/macro-basic-mamdmi.check +++ b/test/files/neg/macro-basic-mamdmi.check @@ -1,4 +1,4 @@ -Impls_Macros_Test_1.scala:36: error: macro implementation not found: quux +Impls_Macros_Test_1.scala:33: error: macro implementation not found: quux (the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them) println(foo(2) + Macros.bar(2) * new Macros().quux(4)) ^ diff --git a/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala b/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala index f9e0ca5077..97780ef503 100644 --- a/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala +++ b/test/files/neg/macro-basic-mamdmi/Impls_Macros_Test_1.scala @@ -3,20 +3,17 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) - c.Expr[Int](body) + c.Expr[Int](q"$x + 1") } def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) - c.Expr[Int](body) + c.Expr[Int](q"$x + 2") } def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) - c.Expr[Int](body) + c.Expr[Int](q"$x + 3") } } diff --git a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala index 59acaede65..3983f590dc 100644 --- a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala +++ b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala @@ -15,7 +15,7 @@ object Complex { val recur = c.inferImplicitValue(trecur, silent = true) if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") } - c.literalNull + c.Expr[Null](q"null") } implicit object ComplexString extends Complex[String] diff --git a/test/files/neg/macro-invalidimpl/Impls_1.scala b/test/files/neg/macro-invalidimpl/Impls_1.scala index cf78ecc65a..9f48ab7ad9 100644 --- a/test/files/neg/macro-invalidimpl/Impls_1.scala +++ b/test/files/neg/macro-invalidimpl/Impls_1.scala @@ -22,8 +22,7 @@ object Impls5 { object Impls6 { def fooNullary(c: Context) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) - c.Expr[Unit](body) + c.Expr[Unit](q"""Predef.println("it works")""") } def fooEmpty(c: Context)() = fooNullary(c) diff --git a/test/files/neg/macro-invalidshape/Macros_Test_2.scala b/test/files/neg/macro-invalidshape/Macros_Test_2.scala index cf37e14d8e..819844b9f1 100644 --- a/test/files/neg/macro-invalidshape/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidshape/Macros_Test_2.scala @@ -3,7 +3,7 @@ object Macros { def foo2(x: Any) = macro Impls.foo(null)(null) def foo3(x: Any) = macro {2; Impls.foo} { - def impl(c: scala.reflect.macros.Context) = c.literalUnit + def impl(c: scala.reflect.macros.Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo = macro impl foo } diff --git a/test/files/neg/macro-invalidsig/Impls_1.scala b/test/files/neg/macro-invalidsig/Impls_1.scala index e7d6c18f8d..d16ed26386 100644 --- a/test/files/neg/macro-invalidsig/Impls_1.scala +++ b/test/files/neg/macro-invalidsig/Impls_1.scala @@ -2,10 +2,7 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Impls1 { - def foo[U: c.WeakTypeTag: Numeric](c: Context) = { - import c.universe._ - Literal(Constant(42)) - } + def foo[U: c.WeakTypeTag: Numeric](c: Context) = { import c.universe._; q"42" } } object Impls2 { @@ -28,12 +25,11 @@ object Impls6 { def foo[T, U: c.WeakTypeTag](c: Context)(implicit x: c.Expr[Int]) = { import c.{prefix => prefix} import c.universe._ - val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("U is: " + implicitly[c.WeakTypeTag[U]].tpe))))), - Literal(Constant(()))) - c.Expr[Unit](body) + c.Expr[Unit](q""" + println("invoking foo_targs...") + println("type of prefix is: " + ${prefix.staticType.toString}) + println("U is: " + ${implicitly[c.WeakTypeTag[U]].tpe.toString}) + """) } } @@ -71,18 +67,20 @@ object Impls14 { object Impls15 { def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + import c.universe._ println(implicitly[c.WeakTypeTag[T]]) println(implicitly[c.WeakTypeTag[U]]) println(V) - c.literalUnit + c.Expr[Unit](q"()") } } object Impls16 { def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: Context)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + import c.universe._ println(implicitly[c.WeakTypeTag[T]]) println(implicitly[c.WeakTypeTag[U]]) println(V) - c.literalUnit + c.Expr[Unit](q"()") } }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala b/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala index 6ee71a3628..74c163596a 100644 --- a/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala +++ b/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala @@ -1,5 +1,5 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U <: String](c: Ctx) = c.literalUnit + def foo[U <: String](c: Ctx) = { import c.universe._; c.Expr[Unit](q"()") } } diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala index 498bd4f18d..11b6a8c3b0 100644 --- a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala +++ b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala @@ -3,7 +3,6 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx) = { import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) - c.Expr[Unit](body) + c.Expr[Unit](q"""println("it works")""") } }
\ No newline at end of file diff --git a/test/files/neg/macro-invalidusage-presuper/Impls_1.scala b/test/files/neg/macro-invalidusage-presuper/Impls_1.scala index b39a037c47..c4b57233c9 100644 --- a/test/files/neg/macro-invalidusage-presuper/Impls_1.scala +++ b/test/files/neg/macro-invalidusage-presuper/Impls_1.scala @@ -1,5 +1,5 @@ import scala.reflect.macros.Context object Impls { - def impl(c: Context) = c.literalUnit + def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } }
\ No newline at end of file diff --git a/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala b/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala index 69ef57d18d..64a9299ee6 100644 --- a/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala +++ b/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala @@ -4,8 +4,7 @@ object Impls { def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ - val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) - c.Expr[Unit](body) + c.Expr[Unit](q"println($tag, ${prefix.toString}, $x)") } def fooBString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBString", x) diff --git a/test/files/neg/macro-without-xmacros-a/Impls_1.scala b/test/files/neg/macro-without-xmacros-a/Impls_1.scala index c6677c4fde..868616aace 100644 --- a/test/files/neg/macro-without-xmacros-a/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala @@ -3,16 +3,16 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))) + c.Expr(q"$x + 1") } def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))) + c.Expr(q"$x + 2") } def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))) + c.Expr(q"$x + 3") } }
\ No newline at end of file diff --git a/test/files/neg/macro-without-xmacros-b/Impls_1.scala b/test/files/neg/macro-without-xmacros-b/Impls_1.scala index c6677c4fde..868616aace 100644 --- a/test/files/neg/macro-without-xmacros-b/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala @@ -3,16 +3,16 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1))))) + c.Expr(q"$x + 1") } def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2))))) + c.Expr(q"$x + 2") } def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ - c.Expr(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3))))) + c.Expr(q"$x + 3") } }
\ No newline at end of file diff --git a/test/files/neg/t7157/Impls_Macros_1.scala b/test/files/neg/t7157/Impls_Macros_1.scala index 09f423fbab..9069d26e6e 100644 --- a/test/files/neg/t7157/Impls_Macros_1.scala +++ b/test/files/neg/t7157/Impls_Macros_1.scala @@ -2,30 +2,30 @@ import scala.reflect.macros.Context import language.experimental.macros object Macros { - def impl1_0_0(c: Context)() = c.literalUnit - def impl1_1_1(c: Context)(x: c.Expr[Int]) = c.literalUnit - def impl1_2_2(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = c.literalUnit + def impl1_0_0(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") } + def impl1_1_1(c: Context)(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } + def impl1_2_2(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } def m1_0_0() = macro impl1_0_0 def m1_1_1(x: Int) = macro impl1_1_1 def m1_2_2(x: Int, y: Int) = macro impl1_2_2 - def impl1_0_inf(c: Context)(x: c.Expr[Int]*) = c.literalUnit - def impl1_1_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int]*) = c.literalUnit - def impl1_2_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = c.literalUnit + def impl1_0_inf(c: Context)(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") } + def impl1_1_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") } + def impl1_2_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") } def m1_0_inf(x: Int*) = macro impl1_0_inf def m1_1_inf(x: Int, y: Int*) = macro impl1_1_inf def m1_2_inf(x: Int, y: Int, z: Int*) = macro impl1_2_inf - def impl2_0_0(c: Context)()() = c.literalUnit - def impl2_1_1(c: Context)()(x: c.Expr[Int]) = c.literalUnit - def impl2_2_2(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]) = c.literalUnit + def impl2_0_0(c: Context)()() = { import c.universe._; c.Expr[Unit](q"()") } + def impl2_1_1(c: Context)()(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } + def impl2_2_2(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } def m2_0_0()() = macro impl2_0_0 def m2_1_1()(x: Int) = macro impl2_1_1 def m2_2_2()(x: Int, y: Int) = macro impl2_2_2 - def impl2_0_inf(c: Context)()(x: c.Expr[Int]*) = c.literalUnit - def impl2_1_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]*) = c.literalUnit - def impl2_2_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = c.literalUnit + def impl2_0_inf(c: Context)()(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") } + def impl2_1_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") } + def impl2_2_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"()") } def m2_0_inf()(x: Int*) = macro impl2_0_inf def m2_1_inf()(x: Int, y: Int*) = macro impl2_1_inf def m2_2_inf()(x: Int, y: Int, z: Int*) = macro impl2_2_inf diff --git a/test/files/pos/annotated-treecopy/Impls_Macros_1.scala b/test/files/pos/annotated-treecopy/Impls_Macros_1.scala index ecf8916c46..9b7af0c3b8 100644 --- a/test/files/pos/annotated-treecopy/Impls_Macros_1.scala +++ b/test/files/pos/annotated-treecopy/Impls_Macros_1.scala @@ -38,10 +38,10 @@ object Macros { val reifiedExpr = c.Expr[scala.reflect.runtime.universe.Expr[T => U]](reifiedTree) val template = c.universe.reify(new (T => U) with TypedFunction { - override def toString = c.literal(tp+" => "+ttag.tpe+" { "+b1.toString+" } ").splice // DEBUG + override def toString = c.Expr[String](q"""${tp+" => "+ttag.tpe+" { "+b1.toString+" } "}""").splice // DEBUG def tree = reifiedExpr.splice.tree - val typeIn = c.literal(tp.toString).splice - val typeOut = c.literal(ttag.tpe.toString).splice + val typeIn = c.Expr[String](q"${tp.toString}").splice + val typeOut = c.Expr[String](q"${ttag.tpe.toString}").splice def apply(_arg: T): U = c.Expr[U](b1)(ttag.asInstanceOf[c.WeakTypeTag[U]]).splice }) val untyped = c.resetLocalAttrs(template.tree) diff --git a/test/files/pos/t5692a/Macros_1.scala b/test/files/pos/t5692a/Macros_1.scala index 06b5a3de36..e530713bb0 100644 --- a/test/files/pos/t5692a/Macros_1.scala +++ b/test/files/pos/t5692a/Macros_1.scala @@ -1,6 +1,6 @@ import scala.reflect.macros.Context object Macros { - def impl[T](c: Context) = c.literalUnit + def impl[T](c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo[T] = macro impl[T] }
\ No newline at end of file diff --git a/test/files/pos/t5692b/Macros_1.scala b/test/files/pos/t5692b/Macros_1.scala index b28d19f903..45c672cfce 100644 --- a/test/files/pos/t5692b/Macros_1.scala +++ b/test/files/pos/t5692b/Macros_1.scala @@ -1,6 +1,6 @@ import scala.reflect.macros.Context object Macros { - def impl[T, U](c: Context) = c.literalUnit + def impl[T, U](c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo[T, U] = macro impl[T, U] }
\ No newline at end of file diff --git a/test/files/pos/t7461/Macros_1.scala b/test/files/pos/t7461/Macros_1.scala index 353dec66d7..8621650f77 100644 --- a/test/files/pos/t7461/Macros_1.scala +++ b/test/files/pos/t7461/Macros_1.scala @@ -6,7 +6,7 @@ object Macros { import c.universe._ val wut = c.typeCheck(Select(Literal(Constant(10)), newTermName("$minus")), silent = true) // println(showRaw(wut, printIds = true, printTypes = true)) - c.literalUnit + c.Expr[Unit](q"()") } def foo = macro impl diff --git a/test/files/pos/t7649.scala b/test/files/pos/t7649.scala index a1b02f63f1..ff3c626fca 100644 --- a/test/files/pos/t7649.scala +++ b/test/files/pos/t7649.scala @@ -4,7 +4,7 @@ object Test { reify { // The lookup of the implicit WeakTypeTag[Any] // was triggering an unpositioned tree. - c.Expr[Any](Literal(Constant(0))).splice + c.Expr[Any](q"0").splice } import scala.reflect.ClassTag diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check index b9c809f037..c11c48dc55 100644 --- a/test/files/run/macro-bundle-repl.check +++ b/test/files/run/macro-bundle-repl.check @@ -7,13 +7,13 @@ import scala.language.experimental.macros scala> import scala.reflect.macros.Macro import scala.reflect.macros.Macro -scala> trait Bar extends Macro { def impl = c.literalUnit };def bar = macro Bar.impl +scala> trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl defined trait Bar defined term macro bar: Unit scala> bar -scala> trait Foo extends Macro { def impl = c.literalUnit } +scala> trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } } defined trait Foo scala> def foo = macro Foo.impl diff --git a/test/files/run/macro-bundle-repl.scala b/test/files/run/macro-bundle-repl.scala index 50783c8cba..3171aaacc2 100644 --- a/test/files/run/macro-bundle-repl.scala +++ b/test/files/run/macro-bundle-repl.scala @@ -4,9 +4,9 @@ object Test extends ReplTest { def code = """ import scala.language.experimental.macros import scala.reflect.macros.Macro -trait Bar extends Macro { def impl = c.literalUnit };def bar = macro Bar.impl +trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl bar -trait Foo extends Macro { def impl = c.literalUnit } +trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } } def foo = macro Foo.impl foo """ diff --git a/test/files/run/macro-bundle-static/Impls_Macros_1.scala b/test/files/run/macro-bundle-static/Impls_Macros_1.scala index 831dac6df5..e81fd0dbd6 100644 --- a/test/files/run/macro-bundle-static/Impls_Macros_1.scala +++ b/test/files/run/macro-bundle-static/Impls_Macros_1.scala @@ -4,8 +4,8 @@ import scala.language.experimental.macros object Enclosing { trait Impl extends Macro { - def mono = c.literalUnit - def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString) + def mono = { import c.universe._; c.Expr[Unit](q"()") } + def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") } def weird = macro mono } } @@ -18,8 +18,8 @@ object Macros { package pkg { object Enclosing { trait Impl extends Macro { - def mono = c.literalTrue - def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString + c.weakTypeOf[T].toString) + def mono = { import c.universe._; c.Expr[Boolean](q"true") } + def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") } def weird = macro mono } } diff --git a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala index 676935682e..8c7df2cdc5 100644 --- a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala +++ b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala @@ -2,8 +2,8 @@ import scala.reflect.macros.Context import scala.reflect.macros.Macro trait Impl extends Macro { - def mono = c.literalUnit - def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString) + def mono = { import c.universe._; c.Expr[Unit](q"()") } + def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") } def weird = macro mono } @@ -14,8 +14,8 @@ object Macros { package pkg { trait Impl extends Macro { - def mono = c.literalTrue - def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString + c.weakTypeOf[T].toString) + def mono = { import c.universe._; c.Expr[Boolean](q"true") } + def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") } def weird = macro mono } diff --git a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala index bc4a9fded7..53511ebc72 100644 --- a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala +++ b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala @@ -15,7 +15,7 @@ object Complex { val recur = c.inferImplicitValue(trecur, silent = true) if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") } - c.literalNull + c.Expr[Null](Literal(Constant(null))) } implicit object ComplexString extends Complex[String] diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala index cd54028676..68f1920cdd 100644 --- a/test/files/run/macro-enclosures/Impls_Macros_1.scala +++ b/test/files/run/macro-enclosures/Impls_Macros_1.scala @@ -1,13 +1,16 @@ import scala.reflect.macros.Context object Macros { - def impl(c: Context) = c.universe.reify { - println("enclosingPackage = " + c.literal(c.enclosingPackage.toString).splice) - println("enclosingClass = " + c.literal(c.enclosingClass.toString).splice) - println("enclosingImpl = " + c.literal(c.enclosingImpl.toString).splice) - println("enclosingTemplate = " + c.literal(c.enclosingTemplate.toString).splice) - println("enclosingMethod = " + c.literal(c.enclosingMethod.toString).splice) - println("enclosingDef = " + c.literal(c.enclosingDef.toString).splice) + def impl(c: Context) = { + import c.universe._ + reify { + println("enclosingPackage = " + c.Expr[String](Literal(Constant(c.enclosingPackage.toString))).splice) + println("enclosingClass = " + c.Expr[String](Literal(Constant(c.enclosingClass.toString))).splice) + println("enclosingImpl = " + c.Expr[String](Literal(Constant(c.enclosingImpl.toString))).splice) + println("enclosingTemplate = " + c.Expr[String](Literal(Constant(c.enclosingTemplate.toString))).splice) + println("enclosingMethod = " + c.Expr[String](Literal(Constant(c.enclosingMethod.toString))).splice) + println("enclosingDef = " + c.Expr[String](Literal(Constant(c.enclosingDef.toString))).splice) + } } def foo = macro impl diff --git a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala index f9103aaf8f..d63f034e9b 100644 --- a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala @@ -1,12 +1,12 @@ import scala.reflect.macros.Context object Impls1 { - def foo[U <: String](c: Context): c.Expr[Unit] = c.literalUnit + def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") } } class C class D extends C object Impls2 { - def foo[U <: C](c: Context): c.Expr[Unit] = c.literalUnit + def foo[U <: C](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") } } diff --git a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala index e92396d1b4..a98c4abe78 100644 --- a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala @@ -5,8 +5,7 @@ object Impls1 { def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) - c.Expr[Unit](body) + c.Expr[Unit](q"println(${U.toString})") } } @@ -16,18 +15,18 @@ object Impls2 { val T = implicitly[c.WeakTypeTag[T]] val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) - c.Expr[Unit](body) + c.Expr[Unit](q"""println(${T.toString} + " " + ${U.toString})""") } } object Impls345 { def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ - c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(())))) + c.Expr(q""" + println(${T.toString}) + println(${implicitly[c.WeakTypeTag[U]].toString}) + println(${V.toString}) + """) } } diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index 95d746980e..043675ec00 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -6,13 +6,12 @@ object Impls { import c.{prefix => prefix} import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("U is: " + U.tpe))))), - Literal(Constant(()))) - c.Expr[Unit](body) + c.Expr[Unit](q""" + println("invoking foo_targs...") + println("type of prefix is: " + ${prefix.staticType.toString}) + println("type of prefix tree is: " + ${prefix.tree.tpe.toString}) + println("U is: " + ${U.tpe.toString}) + """) } } diff --git a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala index 738c88bbc8..5f3bbac719 100644 --- a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala @@ -3,10 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = { import unconventionalName.universe._ - val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo..."))))), - Literal(Constant(()))) - unconventionalName.Expr[Unit](body) + unconventionalName.Expr[Unit](q"""println("invoking foo...")""") } } diff --git a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala index 9b8dafaa97..24eacb36de 100644 --- a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala +++ b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala @@ -1,5 +1,5 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U <: String](c: Ctx): c.Expr[Unit] = c.literalUnit + def foo[U <: String](c: Ctx): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") } } diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala index 50a1782431..884d7f8825 100644 --- a/test/files/run/macro-openmacros/Impls_Macros_1.scala +++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala @@ -14,9 +14,9 @@ object Macros { } import c.universe._ - val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), TermName("foo"))) else c.literalUnit + val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), TermName("foo"))) else c.Expr[Unit](Literal(Constant(()))) c.universe.reify { - println(c.literal(normalizePaths(c.enclosingMacros.toString)).splice) + println(c.Expr[String](Literal(Constant(normalizePaths(c.enclosingMacros.toString)))).splice) next.splice } } diff --git a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala index 5330d0e32b..f454fc430a 100644 --- a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala @@ -2,9 +2,9 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { + import c.universe._ val x1 = c.Expr[Int](c.resetAllAttrs(x.tree)) -// was: c.literal(x1.splice) - c.literal(c.eval(x1)) + c.Expr[Int](Literal(Constant(c.eval(x1)))) } } diff --git a/test/files/run/macro-settings/Impls_Macros_1.scala b/test/files/run/macro-settings/Impls_Macros_1.scala index 83d80a5bff..9257784cf2 100644 --- a/test/files/run/macro-settings/Impls_Macros_1.scala +++ b/test/files/run/macro-settings/Impls_Macros_1.scala @@ -1,8 +1,11 @@ import scala.reflect.macros.Context object Impls { - def impl(c: Context) = c.universe.reify { - println(c.literal(c.settings.toString).splice) + def impl(c: Context) = { + import c.universe._ + reify { + println(c.Expr[String](Literal(Constant(c.settings.toString))).splice) + } } } diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala index 8d7d3b5d3d..1b914ac797 100644 --- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala @@ -11,7 +11,8 @@ object Macros { val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point - c.universe.reify { SourceLocation1(outer.splice, c.literal(fileName).splice, c.literal(line).splice, c.literal(charOffset).splice) } + def literal[T](x: T) = c.Expr[T](Literal(Constant(x))) + c.universe.reify { SourceLocation1(outer.splice, literal(fileName).splice, literal(line).splice, literal(charOffset).splice) } } implicit def sourceLocation: SourceLocation1 = macro impl diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala index 4c165ed1b8..95e19c4fd1 100644 --- a/test/files/run/macro-sip19/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19/Impls_Macros_1.scala @@ -7,7 +7,8 @@ object Macros { val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point - c.universe.reify { SourceLocation(c.literal(fileName).splice, c.literal(line).splice, c.literal(charOffset).splice) } + def literal[T](x: T) = c.Expr[T](Literal(Constant(x))) + c.universe.reify { SourceLocation(literal(fileName).splice, literal(line).splice, literal(charOffset).splice) } } implicit def sourceLocation: SourceLocation = macro impl diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check index ff96a34426..c61fe7f2cf 100644 --- a/test/files/run/macro-system-properties.check +++ b/test/files/run/macro-system-properties.check @@ -8,7 +8,7 @@ import reflect.macros.Context scala> object GrabContext { def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) // System.properties lets you stash true globals (unlike statics which are classloader scoped) - def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } + def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } def grab() = macro impl } defined object GrabContext diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala index e182defc81..9dcd044dbd 100644 --- a/test/files/run/macro-system-properties.scala +++ b/test/files/run/macro-system-properties.scala @@ -7,7 +7,7 @@ object Test extends ReplTest { object GrabContext { def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) // System.properties lets you stash true globals (unlike statics which are classloader scoped) - def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } + def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } def grab() = macro impl } object Test { class C(implicit a: Any) { GrabContext.grab } } diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala index dbeb7efbc0..cd37c269b5 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala @@ -6,7 +6,7 @@ object Macros { val tree1 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false) - c.literal(ttree1.toString) + c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_implicits_enabled = macro impl_with_implicits_enabled @@ -17,10 +17,10 @@ object Macros { try { val tree2 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withImplicitViewsDisabled = true) - c.literal(ttree2.toString) + c.Expr[String](Literal(Constant(ttree2.toString))) } catch { case ex: Throwable => - c.literal(ex.toString) + c.Expr[String](Literal(Constant(ex.toString))) } } diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index ff535fea8d..2532cfd2b9 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -7,7 +7,7 @@ object Macros { val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) val tree1 = Apply(Select(ru, TermName("reify")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) - c.literal(ttree1.toString) + c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_macros_enabled = macro impl_with_macros_enabled @@ -23,7 +23,7 @@ object Macros { val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) - c.literal(ttree2.toString) + c.Expr[String](Literal(Constant(ttree2.toString))) } def foo_with_macros_disabled = macro impl_with_macros_disabled diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala index a96e0c53b6..7b22793df9 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -7,7 +7,7 @@ object Macros { val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) val tree1 = Apply(Select(ru, TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) - c.literal(ttree1.toString) + c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_macros_enabled = macro impl_with_macros_enabled @@ -23,7 +23,7 @@ object Macros { val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) - c.literal(ttree2.toString) + c.Expr[String](Literal(Constant(ttree2.toString))) } def foo_with_macros_disabled = macro impl_with_macros_disabled diff --git a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala index bcbd12817b..6695a297ea 100644 --- a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala @@ -2,14 +2,20 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.universe.reify { - println("A = " + c.literal(implicitly[c.WeakTypeTag[A]].toString).splice) - x.splice :: xs.splice + def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = { + import c.universe._ + reify { + println("A = " + c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[A]].toString))).splice) + x.splice :: xs.splice + } } - def nil_impl[B: c.WeakTypeTag](c: Context): c.Expr[List[B]] = c.universe.reify { - println("B = " + c.literal(implicitly[c.WeakTypeTag[B]].toString).splice) - Nil + def nil_impl[B: c.WeakTypeTag](c: Context): c.Expr[List[B]] = { + import c.universe._ + reify { + println("B = " + c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[B]].toString))).splice) + Nil + } } def cons[A](x: A, xs: List[A]): List[A] = macro cons_impl[A] diff --git a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala index 0244273b6f..85877b3f13 100644 --- a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala @@ -2,7 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.universe.reify { println(c.literal(implicitly[c.WeakTypeTag[T]].toString).splice) } + def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = { + import c.universe._ + reify { println(c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[T]].toString))).splice) } + } def foo[T](foo: T) = macro impl[T] }
\ No newline at end of file diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check index 2a143a1777..63bafe401b 100644 --- a/test/files/run/repl-term-macros.check +++ b/test/files/run/repl-term-macros.check @@ -9,7 +9,7 @@ import language.experimental.macros scala> -scala> def impl1(c: Context) = c.literalUnit +scala> def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } impl1: (c: scala.reflect.macros.Context)c.Expr[Unit] scala> def foo1 = macro impl1 @@ -19,7 +19,7 @@ scala> foo1 scala> -scala> def impl2(c: Context)() = c.literalUnit +scala> def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") } impl2: (c: scala.reflect.macros.Context)()c.Expr[Unit] scala> def foo2() = macro impl2 @@ -29,7 +29,7 @@ scala> foo2() scala> -scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = c.literalUnit +scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } impl3: (c: scala.reflect.macros.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit] scala> def foo3(x: Int)(y: Int) = macro impl3 diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala index f826259be9..125e397b22 100644 --- a/test/files/run/repl-term-macros.scala +++ b/test/files/run/repl-term-macros.scala @@ -5,15 +5,15 @@ object Test extends ReplTest { import scala.reflect.macros.Context import language.experimental.macros -def impl1(c: Context) = c.literalUnit +def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo1 = macro impl1 foo1 -def impl2(c: Context)() = c.literalUnit +def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") } def foo2() = macro impl2 foo2() -def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = c.literalUnit +def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } def foo3(x: Int)(y: Int) = macro impl3 foo3(2)(3) """ diff --git a/test/files/run/t5894.scala b/test/files/run/t5894.scala index abeec32365..5deda34489 100644 --- a/test/files/run/t5894.scala +++ b/test/files/run/t5894.scala @@ -4,7 +4,7 @@ class Test object Test { def foo = macro fooImpl - def fooImpl(c: reflect.macros.Context) = c.literalUnit + def fooImpl(c: reflect.macros.Context) = { import c.universe._; c.Expr[Unit](q"()") } def main(args: Array[String]) { try { diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala index 97076eb102..741379cf34 100644 --- a/test/files/run/t5923a/Macros_1.scala +++ b/test/files/run/t5923a/Macros_1.scala @@ -46,7 +46,7 @@ object Macros { if (sym.isParameter && !sym.isSkolem) TypeTag.Nothing.asInstanceOf[TypeTag[T]] else ttag0 } - reify(C[T](c.literal(weakTypeOf[T].toString).splice)) + reify(C[T](c.Expr[String](Literal(Constant(weakTypeOf[T].toString))).splice)) } } }
\ No newline at end of file diff --git a/test/files/run/t5940.scala b/test/files/run/t5940.scala index 147ff38256..9c8f702c68 100644 --- a/test/files/run/t5940.scala +++ b/test/files/run/t5940.scala @@ -7,12 +7,12 @@ object Test extends DirectTest { import scala.reflect.macros.Context object Impls { - def impl(c: Context) = c.literalUnit + def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } } object Macros { //import Impls._ - def impl(c: Context) = c.literalUnit + def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo = macro impl } """ diff --git a/test/files/run/t6199-toolbox.scala b/test/files/run/t6199-toolbox.scala index 89015f5878..6ba5e50f66 100644 --- a/test/files/run/t6199-toolbox.scala +++ b/test/files/run/t6199-toolbox.scala @@ -4,5 +4,5 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() - println(tb.eval(Literal(Constant(())))) + println(tb.eval(q"()")) }
\ No newline at end of file diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check index 5070b67e46..c9d4713aa8 100644 --- a/test/files/run/t6381.check +++ b/test/files/run/t6381.check @@ -4,8 +4,10 @@ Type :help for more information. scala> import language.experimental.macros import language.experimental.macros -scala> def pos_impl(c: reflect.macros.Context): c.Expr[String] = - c.literal(c.enclosingPosition.getClass.toString) +scala> def pos_impl(c: reflect.macros.Context): c.Expr[String] = { + import c.universe._ + c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString))) +} pos_impl: (c: scala.reflect.macros.Context)c.Expr[String] scala> def pos = macro pos_impl diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala index 859ec3cb30..4c2a40fe87 100644 --- a/test/files/run/t6381.scala +++ b/test/files/run/t6381.scala @@ -3,8 +3,10 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ |import language.experimental.macros - |def pos_impl(c: reflect.macros.Context): c.Expr[String] = - | c.literal(c.enclosingPosition.getClass.toString) + |def pos_impl(c: reflect.macros.Context): c.Expr[String] = { + | import c.universe._ + | c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString))) + |} |def pos = macro pos_impl |pos |""".stripMargin.trim diff --git a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala index 94fd99018e..477829f200 100644 --- a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala +++ b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala @@ -3,9 +3,10 @@ import scala.reflect.macros.Context object Macros { def impl(c: Context) = { + import c.universe._ val decls = c.typeOf[ScalaClassWithCheckedExceptions_1[_]].declarations.toList val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) - c.universe.reify(println(c.literal(s).splice)) + reify(println(c.Expr[String](Literal(Constant(s))).splice)) } def foo = macro impl diff --git a/test/files/run/t7008/Impls_Macros_2.scala b/test/files/run/t7008/Impls_Macros_2.scala index 7a17314085..63c3f9d696 100644 --- a/test/files/run/t7008/Impls_Macros_2.scala +++ b/test/files/run/t7008/Impls_Macros_2.scala @@ -3,9 +3,10 @@ import scala.reflect.macros.Context object Macros { def impl(c: Context) = { + import c.universe._ val decls = c.typeOf[JavaClassWithCheckedExceptions_1[_]].declarations.toList val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) - c.universe.reify(println(c.literal(s).splice)) + reify(println(c.Expr[String](Literal(Constant(s))).splice)) } def foo = macro impl diff --git a/test/files/run/t7047/Impls_Macros_1.scala b/test/files/run/t7047/Impls_Macros_1.scala index 2992e3efe4..a5d55c3a42 100644 --- a/test/files/run/t7047/Impls_Macros_1.scala +++ b/test/files/run/t7047/Impls_Macros_1.scala @@ -12,7 +12,7 @@ object Macros { } catch { case _: Exception => } - c.literalNull + c.Expr[Null](Literal(Constant(null))) } def foo = macro impl diff --git a/test/files/run/t7375b/Macros_1.scala b/test/files/run/t7375b/Macros_1.scala index 70e79cc2b4..7a307805db 100644 --- a/test/files/run/t7375b/Macros_1.scala +++ b/test/files/run/t7375b/Macros_1.scala @@ -11,7 +11,7 @@ object Macros { def foo = macro impl def impl(c: Context) = { import c.universe._ - def test[T: c.TypeTag] = reify(println(c.literal(c.reifyRuntimeClass(c.typeOf[T]).toString).splice)).tree + def test[T: c.TypeTag] = reify(println(c.Expr[String](Literal(Constant(c.reifyRuntimeClass(c.typeOf[T]).toString))).splice)).tree def tests = Block(List(test[C1], test[C2], test[F1], test[F2]), Literal(Constant(()))) c.Expr[Unit](tests) } |