From 5cc8f83c681ded7367dc5112f6f9042e9526facf Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 11 Jan 2014 23:41:31 +0100 Subject: *boxContext => *box.Context , *boxMacro => *box.Macro Performs the following renamings: * scala.reflect.macros.BlackboxContext to scala.reflect.macros.blackbox.Context * scala.reflect.macros.BlackboxMacro to scala.reflect.macros.blackbox.Macro * scala.reflect.macros.WhiteboxContext to scala.reflect.macros.whitebox.Context * scala.reflect.macros.WhiteboxMacro to scala.reflect.macros.whitebox.Macro https://groups.google.com/forum/#!topic/scala-internals/MX40-dM28rk --- test/files/neg/macro-abort/Macros_1.scala | 4 +- .../macro-basic-mamdmi/Impls_Macros_Test_1.scala | 8 +-- .../Macros_1.scala | 4 +- .../neg/macro-blackbox-extractor/Macros_1.scala | 4 +- .../Macros_1.scala | 4 +- .../macro-blackbox-structural/Impls_Macros_1.scala | 2 +- test/files/neg/macro-bundle-abstract.check | 2 +- test/files/neg/macro-bundle-abstract.scala | 4 +- test/files/neg/macro-bundle-class.check | 2 +- test/files/neg/macro-bundle-class.scala | 5 +- test/files/neg/macro-bundle-mixbox.check | 2 +- test/files/neg/macro-bundle-mixbox.scala | 3 +- test/files/neg/macro-bundle-object.check | 4 +- test/files/neg/macro-bundle-object.scala | 6 +-- test/files/neg/macro-bundle-polymorphic.check | 6 +-- test/files/neg/macro-bundle-polymorphic.scala | 4 +- test/files/neg/macro-bundle-trait.check | 2 +- test/files/neg/macro-bundle-trait.scala | 7 ++- test/files/neg/macro-cyclic/Impls_Macros_1.scala | 4 +- .../Impls_Macros_1.scala | 4 +- test/files/neg/macro-exception/Macros_1.scala | 4 +- .../Impls_Macros_1.scala | 4 +- .../macro-incompatible-macro-engine/Macros_2.scala | 4 +- test/files/neg/macro-invalidimpl.check | 20 ++++---- test/files/neg/macro-invalidimpl/Impls_1.scala | 20 ++++---- .../neg/macro-invalidimpl/Macros_Test_2.scala | 4 +- test/files/neg/macro-invalidret.check | 12 ++--- test/files/neg/macro-invalidret/Impls_1.scala | 12 ++--- test/files/neg/macro-invalidshape/Impls_1.scala | 4 +- .../neg/macro-invalidshape/Macros_Test_2.scala | 2 +- .../neg/macro-invalidsig-params-badtype.check | 6 +-- .../Impls_Macros_1.scala | 4 +- test/files/neg/macro-invalidsig.check | 58 +++++++++++----------- test/files/neg/macro-invalidsig/Impls_1.scala | 30 +++++------ .../neg/macro-invalidusage-badargs/Impls_1.scala | 4 +- .../neg/macro-invalidusage-badbounds/Impls_1.scala | 4 +- .../neg/macro-invalidusage-badtargs/Impls_1.scala | 4 +- .../Impls_1.scala | 4 +- .../Impls_Macros_1.scala | 4 +- .../neg/macro-invalidusage-presuper/Impls_1.scala | 4 +- test/files/neg/macro-noexpand/Impls_1.scala | 4 +- test/files/neg/macro-nontypeablebody/Impls_1.scala | 4 +- .../Impls_Macros_1.scala | 4 +- .../Impls_Macros_1.scala | 4 +- .../Impls_1.scala | 12 ++--- test/files/neg/macro-quasiquotes/Macros_1.scala | 4 +- .../neg/macro-reify-splice-splice/Macros_1.scala | 4 +- .../neg/macro-without-xmacros-a/Impls_1.scala | 8 +-- .../neg/macro-without-xmacros-b/Impls_1.scala | 8 +-- test/files/neg/t5689.check | 6 +-- test/files/neg/t5689.scala | 4 +- test/files/neg/t5753/Impls_Macros_1.scala | 4 +- test/files/neg/t5753/Test_2.scala | 2 +- test/files/neg/t5903a/Macros_1.scala | 4 +- test/files/neg/t5903b/Macros_1.scala | 4 +- test/files/neg/t5903c/Macros_1.scala | 4 +- test/files/neg/t5903d/Macros_1.scala | 4 +- test/files/neg/t5903e/Macros_1.scala | 4 +- test/files/neg/t6123-explaintypes-macros.check | 6 +-- .../neg/t6123-explaintypes-macros/BadMac_2.scala | 4 +- .../neg/t6123-explaintypes-macros/Macros.scala | 4 +- test/files/neg/t6539/Macro_1.scala | 4 +- test/files/neg/t7157/Impls_Macros_1.scala | 26 +++++----- test/files/neg/t8104/Macros_1.scala | 4 +- 64 files changed, 212 insertions(+), 213 deletions(-) (limited to 'test/files/neg') diff --git a/test/files/neg/macro-abort/Macros_1.scala b/test/files/neg/macro-abort/Macros_1.scala index 577e640089..2077e99ad7 100644 --- a/test/files/neg/macro-abort/Macros_1.scala +++ b/test/files/neg/macro-abort/Macros_1.scala @@ -1,8 +1,8 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { c.abort(c.enclosingPosition, "aborted") } def abort = macro impl 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 ae34815d37..325bb7276f 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 @@ -1,17 +1,17 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def foo(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr[Int](q"$x + 1") } - def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def bar(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr[Int](q"$x + 2") } - def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def quux(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr[Int](q"$x + 3") } diff --git a/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala b/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala index a00d195005..3cfbdf45e9 100644 --- a/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala +++ b/test/files/neg/macro-blackbox-dynamic-materialization/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import scala.language.experimental.macros trait Foo[T] @@ -15,7 +15,7 @@ object Foo extends LowPriority { } object Macros { - def impl[T: c.WeakTypeTag](c: BlackboxContext) = { + def impl[T: c.WeakTypeTag](c: Context) = { import c.universe._ val tpe = weakTypeOf[T] if (tpe.members.exists(_.typeSignature =:= typeOf[Int])) diff --git a/test/files/neg/macro-blackbox-extractor/Macros_1.scala b/test/files/neg/macro-blackbox-extractor/Macros_1.scala index f0bfe53aa2..64b6270b74 100644 --- a/test/files/neg/macro-blackbox-extractor/Macros_1.scala +++ b/test/files/neg/macro-blackbox-extractor/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros object Extractor { @@ -6,7 +6,7 @@ object Extractor { } object Macros { - def unapplyImpl(c: BlackboxContext)(x: c.Tree) = { + def unapplyImpl(c: Context)(x: c.Tree) = { import c.universe._ q""" new { diff --git a/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala b/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala index 6bddef4b9d..a6f7de23bb 100644 --- a/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala +++ b/test/files/neg/macro-blackbox-fundep-materialization/Macros_1.scala @@ -1,5 +1,5 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context trait Iso[T, U] { def to(t : T) : U @@ -8,7 +8,7 @@ trait Iso[T, U] { object Iso { implicit def materializeIso[T, U]: Iso[T, U] = macro impl[T, U] - def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: BlackboxContext): c.Expr[Iso[T, U]] = { + def impl[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context): c.Expr[Iso[T, U]] = { import c.universe._ import definitions._ import Flag._ diff --git a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala index f5e85d57ea..a86a26d2c0 100644 --- a/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala +++ b/test/files/neg/macro-blackbox-structural/Impls_Macros_1.scala @@ -1,7 +1,7 @@ import scala.language.experimental.macros object Macros { - def impl(c: scala.reflect.macros.BlackboxContext) = { + def impl(c: scala.reflect.macros.blackbox.Context) = { import c.universe._ q""" trait Foo { diff --git a/test/files/neg/macro-bundle-abstract.check b/test/files/neg/macro-bundle-abstract.check index 8ef59106b8..8766e2a436 100644 --- a/test/files/neg/macro-bundle-abstract.check +++ b/test/files/neg/macro-bundle-abstract.check @@ -1,4 +1,4 @@ macro-bundle-abstract.scala:4: error: class Bundle$Bundle needs to be abstract, since method deferred in trait Bundle of type => Int is not defined -trait Bundle extends BlackboxMacro { +trait Bundle extends Macro { ^ one error found diff --git a/test/files/neg/macro-bundle-abstract.scala b/test/files/neg/macro-bundle-abstract.scala index f7778d03be..4ed2f4f7e5 100644 --- a/test/files/neg/macro-bundle-abstract.scala +++ b/test/files/neg/macro-bundle-abstract.scala @@ -1,7 +1,7 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxMacro +import scala.reflect.macros.blackbox.Macro -trait Bundle extends BlackboxMacro { +trait Bundle extends Macro { def deferred: Int def impl = ??? } diff --git a/test/files/neg/macro-bundle-class.check b/test/files/neg/macro-bundle-class.check index 7108c15b8d..95ba45b169 100644 --- a/test/files/neg/macro-bundle-class.check +++ b/test/files/neg/macro-bundle-class.check @@ -1,4 +1,4 @@ -macro-bundle-class.scala:10: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member +macro-bundle-class.scala:9: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member def foo = macro Bundle.impl ^ one error found diff --git a/test/files/neg/macro-bundle-class.scala b/test/files/neg/macro-bundle-class.scala index 024e2dbaaa..40a7ae0625 100644 --- a/test/files/neg/macro-bundle-class.scala +++ b/test/files/neg/macro-bundle-class.scala @@ -1,8 +1,7 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxMacro -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox._ -class Bundle(val c: BlackboxContext) extends BlackboxMacro { +class Bundle(val c: Context) extends Macro { def impl = ??? } diff --git a/test/files/neg/macro-bundle-mixbox.check b/test/files/neg/macro-bundle-mixbox.check index c3136d9369..38aad273ea 100644 --- a/test/files/neg/macro-bundle-mixbox.check +++ b/test/files/neg/macro-bundle-mixbox.check @@ -1,4 +1,4 @@ -macro-bundle-mixbox.scala:9: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member +macro-bundle-mixbox.scala:10: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member def foo = macro Bundle.impl ^ one error found diff --git a/test/files/neg/macro-bundle-mixbox.scala b/test/files/neg/macro-bundle-mixbox.scala index 1e36f3d94c..17120aaf07 100644 --- a/test/files/neg/macro-bundle-mixbox.scala +++ b/test/files/neg/macro-bundle-mixbox.scala @@ -1,5 +1,6 @@ import scala.language.experimental.macros -import scala.reflect.macros.{BlackboxMacro, WhiteboxMacro} +import scala.reflect.macros.blackbox.{Macro => BlackboxMacro} +import scala.reflect.macros.whitebox.{Macro => WhiteboxMacro} trait Bundle extends BlackboxMacro with WhiteboxMacro { def impl = ??? diff --git a/test/files/neg/macro-bundle-object.check b/test/files/neg/macro-bundle-object.check index 78e7119fa7..b8800105f5 100644 --- a/test/files/neg/macro-bundle-object.check +++ b/test/files/neg/macro-bundle-object.check @@ -1,6 +1,6 @@ macro-bundle-object.scala:10: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree + required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context): c.Tree found : : Nothing number of parameter sections differ def foo = macro Bundle.impl diff --git a/test/files/neg/macro-bundle-object.scala b/test/files/neg/macro-bundle-object.scala index 105c81f1f5..02278e7165 100644 --- a/test/files/neg/macro-bundle-object.scala +++ b/test/files/neg/macro-bundle-object.scala @@ -1,8 +1,8 @@ import scala.language.experimental.macros -import scala.reflect.macros.{BlackboxMacro, BlackboxContext} +import scala.reflect.macros.blackbox._ -object Bundle extends BlackboxMacro { - val c: BlackboxContext = ??? +object Bundle extends Macro { + val c: Context = ??? def impl = ??? } diff --git a/test/files/neg/macro-bundle-polymorphic.check b/test/files/neg/macro-bundle-polymorphic.check index e024fcde93..8eedce7e87 100644 --- a/test/files/neg/macro-bundle-polymorphic.check +++ b/test/files/neg/macro-bundle-polymorphic.check @@ -1,10 +1,10 @@ -macro-bundle-polymorphic.scala:9: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member +macro-bundle-polymorphic.scala:9: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member def foo = macro Bundle.impl ^ -macro-bundle-polymorphic.scala:10: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member +macro-bundle-polymorphic.scala:10: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member def foo = macro Bundle[Int].impl ^ -macro-bundle-polymorphic.scala:11: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member +macro-bundle-polymorphic.scala:11: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member def foo = macro Bundle[Int, Nothing].impl ^ three errors found diff --git a/test/files/neg/macro-bundle-polymorphic.scala b/test/files/neg/macro-bundle-polymorphic.scala index faf1e2e9e5..b636b6bd6a 100644 --- a/test/files/neg/macro-bundle-polymorphic.scala +++ b/test/files/neg/macro-bundle-polymorphic.scala @@ -1,7 +1,7 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxMacro +import scala.reflect.macros.blackbox.Macro -trait Bundle[T] extends BlackboxMacro { +trait Bundle[T] extends Macro { def impl = ??? } diff --git a/test/files/neg/macro-bundle-trait.check b/test/files/neg/macro-bundle-trait.check index 3cb7985013..d7363fc361 100644 --- a/test/files/neg/macro-bundle-trait.check +++ b/test/files/neg/macro-bundle-trait.check @@ -1,4 +1,4 @@ -macro-bundle-trait.scala:11: error: macro bundles must be monomorphic traits extending either BlackboxMacro or WhiteboxMacro and not implementing their `val c: BlackboxContext/WhiteboxContext` member +macro-bundle-trait.scala:10: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member def foo = macro Bundle.impl ^ one error found diff --git a/test/files/neg/macro-bundle-trait.scala b/test/files/neg/macro-bundle-trait.scala index 62ade49953..0d01459f7e 100644 --- a/test/files/neg/macro-bundle-trait.scala +++ b/test/files/neg/macro-bundle-trait.scala @@ -1,9 +1,8 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxMacro -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox._ -trait Bundle extends BlackboxMacro { - val c: BlackboxContext = ??? +trait Bundle extends Macro { + val c: Context = ??? def impl = ??? } diff --git a/test/files/neg/macro-cyclic/Impls_Macros_1.scala b/test/files/neg/macro-cyclic/Impls_Macros_1.scala index ba08345bcc..ad6890144d 100644 --- a/test/files/neg/macro-cyclic/Impls_Macros_1.scala +++ b/test/files/neg/macro-cyclic/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { c.universe.reify { implicitly[SourceLocation] } } 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 9fb374800b..186c285871 100644 --- a/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala +++ b/test/files/neg/macro-divergence-controlled/Impls_Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import language.experimental.macros trait Complex[T] @@ -6,7 +6,7 @@ trait Complex[T] class Foo(val foo: Foo) object Complex { - def impl[T: c.WeakTypeTag](c: WhiteboxContext): c.Expr[Complex[T]] = { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { import c.universe._ val tpe = weakTypeOf[T] for (f <- tpe.declarations.collect{case f: TermSymbol if f.isParamAccessor && !f.isMethod => f}) { diff --git a/test/files/neg/macro-exception/Macros_1.scala b/test/files/neg/macro-exception/Macros_1.scala index 7bd8415e4f..3d6109dc9d 100644 --- a/test/files/neg/macro-exception/Macros_1.scala +++ b/test/files/neg/macro-exception/Macros_1.scala @@ -1,8 +1,8 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { throw new Exception() } def exception = macro impl diff --git a/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala b/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala index 1bd808d55d..a97dfd4ddf 100644 --- a/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala +++ b/test/files/neg/macro-false-deprecation-warning/Impls_Macros_1.scala @@ -1,11 +1,11 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Helper { def unapplySeq[T](x: List[T]): Option[Seq[T]] = } object Macros { - def impl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[List[T]]) = { + def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[List[T]]) = { c.universe.reify(Helper.unapplySeq(x.splice)) } diff --git a/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala b/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala index ad57a3cb36..39708eee49 100644 --- a/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala +++ b/test/files/neg/macro-incompatible-macro-engine/Macros_2.scala @@ -1,7 +1,7 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c: BlackboxContext) = c.universe.Literal(c.universe.Constant(())) + def impl(c: Context) = c.universe.Literal(c.universe.Constant(())) def foo: Unit = macro impl } \ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl.check b/test/files/neg/macro-invalidimpl.check index 5eff401bef..ea7d71c667 100644 --- a/test/files/neg/macro-invalidimpl.check +++ b/test/files/neg/macro-invalidimpl.check @@ -19,28 +19,28 @@ macro [].[[]] def foo(x: Any) = macro Impls4.foo ^ Macros_Test_2.scala:26: error: ambiguous reference to overloaded definition, -both method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any], y: c.Expr[Any])Nothing -and method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any])Nothing +both method foo in object Impls5 of type (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing +and method foo in object Impls5 of type (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any])Nothing match expected type ? def foo(x: Any) = macro Impls5.foo ^ Macros_Test_2.scala:27: error: ambiguous reference to overloaded definition, -both method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any], y: c.Expr[Any])Nothing -and method foo in object Impls5 of type (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any])Nothing +both method foo in object Impls5 of type (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any], y: c.Expr[Any])Nothing +and method foo in object Impls5 of type (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any])Nothing match expected type ? def foo(x: Any, y: Any) = macro Impls5.foo ^ Macros_Test_2.scala:31: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Unit] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(): c.Expr[Unit] + required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Unit] + or : (c: scala.reflect.macros.blackbox.Context): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(): c.Expr[Unit] number of parameter sections differ def foo1 = macro Impls6.fooEmpty ^ Macros_Test_2.scala:32: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(): c.Expr[Unit] - or : (c: scala.reflect.macros.BlackboxContext)(): c.Tree - found : (c: scala.reflect.macros.BlackboxContext): c.Expr[Unit] + required: (c: scala.reflect.macros.blackbox.Context)(): c.Expr[Unit] + or : (c: scala.reflect.macros.blackbox.Context)(): c.Tree + found : (c: scala.reflect.macros.blackbox.Context): c.Expr[Unit] number of parameter sections differ def bar1() = macro Impls6.fooNullary ^ diff --git a/test/files/neg/macro-invalidimpl/Impls_1.scala b/test/files/neg/macro-invalidimpl/Impls_1.scala index b85ac9ee43..a1c885a4bf 100644 --- a/test/files/neg/macro-invalidimpl/Impls_1.scala +++ b/test/files/neg/macro-invalidimpl/Impls_1.scala @@ -1,39 +1,39 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context class Impls1 { - def foo(c: BlackboxContext)(x: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any]) = ??? } object Impls2 { - def foo(c: BlackboxContext)(x: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any]) = ??? } trait MacroHelpers { object Impls4 { - def foo(c: BlackboxContext)(x: c.Expr[Any]) = x + def foo(c: Context)(x: c.Expr[Any]) = x } } object Impls5 { - def foo(c: BlackboxContext)(x: c.Expr[Any]) = ??? - def foo(c: BlackboxContext)(x: c.Expr[Any], y: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any], y: c.Expr[Any]) = ??? } object Impls6 { - def fooNullary(c: BlackboxContext) = { + def fooNullary(c: Context) = { import c.universe._ c.Expr[Unit](q"""Predef.println("it works")""") } - def fooEmpty(c: BlackboxContext)() = fooNullary(c) + def fooEmpty(c: Context)() = fooNullary(c) } object Impls7 { - def foo[U <: Int](c: BlackboxContext) = ??? + def foo[U <: Int](c: Context) = ??? } package foo { object Impls8 { - private[foo] def impl(c: BlackboxContext) = ??? + private[foo] def impl(c: Context) = ??? } } \ No newline at end of file diff --git a/test/files/neg/macro-invalidimpl/Macros_Test_2.scala b/test/files/neg/macro-invalidimpl/Macros_Test_2.scala index 0df7d2e0c5..6760d99959 100644 --- a/test/files/neg/macro-invalidimpl/Macros_Test_2.scala +++ b/test/files/neg/macro-invalidimpl/Macros_Test_2.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros1 { val impls = new Impls1 @@ -12,7 +12,7 @@ object Macros2 { class Macros3 { object Impls3 { - def foo(c: BlackboxContext)(x: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any]) = ??? } def foo(x: Any) = macro Impls3.foo diff --git a/test/files/neg/macro-invalidret.check b/test/files/neg/macro-invalidret.check index 6c5baf76b4..99f29e57ce 100644 --- a/test/files/neg/macro-invalidret.check +++ b/test/files/neg/macro-invalidret.check @@ -1,14 +1,14 @@ Macros_Test_2.scala:2: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree - found : (c: scala.reflect.macros.BlackboxContext): Int + required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Any] + or : (c: scala.reflect.macros.blackbox.Context): c.Tree + found : (c: scala.reflect.macros.blackbox.Context): Int type mismatch for return type: Int does not conform to c.Expr[Any] def foo1 = macro Impls.foo1 ^ Macros_Test_2.scala:3: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Any] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree - found : (c: scala.reflect.macros.BlackboxContext): reflect.runtime.universe.Literal + required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Any] + or : (c: scala.reflect.macros.blackbox.Context): c.Tree + found : (c: scala.reflect.macros.blackbox.Context): reflect.runtime.universe.Literal type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any] def foo2 = macro Impls.foo2 ^ diff --git a/test/files/neg/macro-invalidret/Impls_1.scala b/test/files/neg/macro-invalidret/Impls_1.scala index b32463899e..434aeef10f 100644 --- a/test/files/neg/macro-invalidret/Impls_1.scala +++ b/test/files/neg/macro-invalidret/Impls_1.scala @@ -1,10 +1,10 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import scala.reflect.runtime.{universe => ru} object Impls { - def foo1(c: BlackboxContext) = 2 - def foo2(c: BlackboxContext) = ru.Literal(ru.Constant(42)) - def foo3(c: BlackboxContext) = ??? - def foo5(c: BlackboxContext) = c.universe.Literal(c.universe.Constant(42)) - def foo6(c: BlackboxContext) = c.Expr[Int](c.universe.Literal(c.universe.Constant(42))) + def foo1(c: Context) = 2 + def foo2(c: Context) = ru.Literal(ru.Constant(42)) + def foo3(c: Context) = ??? + def foo5(c: Context) = c.universe.Literal(c.universe.Constant(42)) + def foo6(c: Context) = c.Expr[Int](c.universe.Literal(c.universe.Constant(42))) } diff --git a/test/files/neg/macro-invalidshape/Impls_1.scala b/test/files/neg/macro-invalidshape/Impls_1.scala index 3d5da9a2ed..acc6b52b7b 100644 --- a/test/files/neg/macro-invalidshape/Impls_1.scala +++ b/test/files/neg/macro-invalidshape/Impls_1.scala @@ -1,5 +1,5 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any]) = ??? } diff --git a/test/files/neg/macro-invalidshape/Macros_Test_2.scala b/test/files/neg/macro-invalidshape/Macros_Test_2.scala index 8f643ab281..160bbf5f53 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.BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } + def impl(c: scala.reflect.macros.blackbox.Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo = macro impl foo } diff --git a/test/files/neg/macro-invalidsig-params-badtype.check b/test/files/neg/macro-invalidsig-params-badtype.check index d6b5c5521d..159754c72e 100644 --- a/test/files/neg/macro-invalidsig-params-badtype.check +++ b/test/files/neg/macro-invalidsig-params-badtype.check @@ -1,7 +1,7 @@ Impls_Macros_1.scala:8: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(x: Int): Nothing + required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int]): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(x: Int): Nothing type mismatch for parameter x: c.Expr[Int] does not conform to Int def foo(x: Int) = macro Impls.foo ^ diff --git a/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala b/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala index 5f468424bd..e549cc9576 100644 --- a/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidsig-params-badtype/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx)(x: Int) = ??? + def foo(c: Context)(x: Int) = ??? } object Macros { diff --git a/test/files/neg/macro-invalidsig.check b/test/files/neg/macro-invalidsig.check index 5ff4ed18cb..8898ffc3de 100644 --- a/test/files/neg/macro-invalidsig.check +++ b/test/files/neg/macro-invalidsig.check @@ -2,30 +2,30 @@ Macros_Test_2.scala:2: error: macro implementations cannot have implicit paramet def foo[U]: Int = macro Impls1.foo[U] ^ Macros_Test_2.scala:6: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree + required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context): c.Tree found : : Nothing number of parameter sections differ def foo = macro Impls2.foo ^ Macros_Test_2.scala:10: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree + required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context): c.Tree found : (c: scala.reflect.api.Universe): Nothing -type mismatch for parameter c: scala.reflect.macros.BlackboxContext does not conform to scala.reflect.api.Universe +type mismatch for parameter c: scala.reflect.macros.blackbox.Context does not conform to scala.reflect.api.Universe def foo = macro Impls3.foo ^ Macros_Test_2.scala:14: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree - found : (cs: scala.reflect.macros.BlackboxContext*): Nothing + required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context): c.Tree + found : (cs: scala.reflect.macros.blackbox.Context*): Nothing types incompatible for parameter cs: corresponding is not a vararg parameter def foo = macro Impls4.foo ^ Macros_Test_2.scala:18: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Any]): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree - found : (c: scala.reflect.macros.BlackboxContext): Nothing + required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Any]): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree): c.Tree + found : (c: scala.reflect.macros.blackbox.Context): Nothing number of parameter sections differ def foo(x: Any) = macro Impls5.foo ^ @@ -33,37 +33,37 @@ Macros_Test_2.scala:22: error: macro implementations cannot have implicit parame def foo[U](x: Int) = macro Impls6.foo[T, U] ^ Macros_Test_2.scala:26: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): Nothing + required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int]): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int], y: c.Expr[Int]): Nothing parameter lists have different length, found extra parameter y: c.Expr[Int] def foo(x: Int) = macro Impls7.foo ^ Macros_Test_2.scala:30: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int]): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(x: c.universe.Symbol): Nothing + required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int]): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(x: c.universe.Symbol): Nothing type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Symbol def foo(x: Int) = macro Impls8.foo ^ Macros_Test_2.scala:34: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(xs: c.Expr[Int]*): Nothing + required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree, y: c.Tree): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(xs: c.Expr[Int]*): Nothing parameter lists have different length, required extra parameter y: c.Expr[Int] def foo(x: Int, y: Int) = macro Impls9.foo ^ Macros_Test_2.scala:38: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext)(x: c.Tree, y: c.Tree): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(y: c.Expr[Int], x: c.Expr[Int]): Nothing + required: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context)(x: c.Tree, y: c.Tree): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(y: c.Expr[Int], x: c.Expr[Int]): Nothing parameter names differ: x != y def foo(x: Int, y: Int) = macro Impls10.foo ^ Macros_Test_2.scala:42: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext): c.Expr[Nothing] - or : (c: scala.reflect.macros.BlackboxContext): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(U: c.universe.Type): Nothing + required: (c: scala.reflect.macros.blackbox.Context): c.Expr[Nothing] + or : (c: scala.reflect.macros.blackbox.Context): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(U: c.universe.Type): Nothing number of parameter sections differ def foo[U] = macro Impls11.foo[U] ^ @@ -73,13 +73,13 @@ Macros_Test_2.scala:46: error: type arguments [U] do not conform to method foo's Macros_Test_2.scala:50: error: type arguments [U] do not conform to method foo's type parameter bounds [U <: String] def foo[U <: Int] = macro Impls13.foo[U] ^ -Macros_Test_2.scala:54: error: macro implementation reference has too few type arguments for method foo: [U](c: scala.reflect.macros.BlackboxContext)(implicit evidence$4: c.WeakTypeTag[U])Nothing +Macros_Test_2.scala:54: error: macro implementation reference has too few type arguments for method foo: [U](c: scala.reflect.macros.blackbox.Context)(implicit evidence$4: c.WeakTypeTag[U])Nothing def foo = macro Impls14.foo ^ -Macros_Test_2.scala:59: error: macro implementation reference has too few type arguments for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] +Macros_Test_2.scala:59: error: macro implementation reference has too few type arguments for method foo: [T, U, V](c: scala.reflect.macros.blackbox.Context)(implicit evidence$5: c.WeakTypeTag[T], implicit evidence$6: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] def foo15[V]: Unit = macro Impls15.foo ^ -Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.BlackboxContext)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] +Macros_Test_2.scala:60: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.blackbox.Context)(implicit evidence$7: c.WeakTypeTag[T], implicit evidence$8: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] def foo16[V]: Unit = macro Impls16.foo[V] ^ 16 errors found diff --git a/test/files/neg/macro-invalidsig/Impls_1.scala b/test/files/neg/macro-invalidsig/Impls_1.scala index 7c98160925..b0a3912380 100644 --- a/test/files/neg/macro-invalidsig/Impls_1.scala +++ b/test/files/neg/macro-invalidsig/Impls_1.scala @@ -1,8 +1,8 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Impls1 { - def foo[U: c.WeakTypeTag: Numeric](c: BlackboxContext) = { import c.universe._; q"42" } + def foo[U: c.WeakTypeTag: Numeric](c: Context) = { import c.universe._; q"42" } } object Impls2 { @@ -14,15 +14,15 @@ object Impls3 { } object Impls4 { - def foo(cs: BlackboxContext*) = ??? + def foo(cs: Context*) = ??? } object Impls5 { - def foo(c: BlackboxContext) = ??? + def foo(c: Context) = ??? } object Impls6 { - def foo[T, U: c.WeakTypeTag](c: BlackboxContext)(implicit x: c.Expr[Int]) = { + def foo[T, U: c.WeakTypeTag](c: Context)(implicit x: c.Expr[Int]) = { import c.{prefix => prefix} import c.universe._ c.Expr[Unit](q""" @@ -34,39 +34,39 @@ object Impls6 { } object Impls7 { - def foo(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]) = ??? + def foo(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = ??? } object Impls8 { - def foo(c: BlackboxContext)(x: c.universe.Symbol) = ??? + def foo(c: Context)(x: c.universe.Symbol) = ??? } object Impls9 { - def foo(c: BlackboxContext)(xs: c.Expr[Int]*) = ??? + def foo(c: Context)(xs: c.Expr[Int]*) = ??? } object Impls10 { - def foo(c: BlackboxContext)(y: c.Expr[Int], x: c.Expr[Int]) = ??? + def foo(c: Context)(y: c.Expr[Int], x: c.Expr[Int]) = ??? } object Impls11 { - def foo[U](c: BlackboxContext)(U: c.universe.Type) = ??? + def foo[U](c: Context)(U: c.universe.Type) = ??? } object Impls12 { - def foo[U <: String](c: BlackboxContext) = ??? + def foo[U <: String](c: Context) = ??? } object Impls13 { - def foo[U <: String](c: BlackboxContext) = ??? + def foo[U <: String](c: Context) = ??? } object Impls14 { - def foo[U: c.WeakTypeTag](c: BlackboxContext) = ??? + def foo[U: c.WeakTypeTag](c: Context) = ??? } object Impls15 { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: BlackboxContext)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + 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]]) @@ -76,7 +76,7 @@ object Impls15 { } object Impls16 { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag, V](c: BlackboxContext)(implicit V: c.WeakTypeTag[V]): c.Expr[Unit] = { + 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]]) diff --git a/test/files/neg/macro-invalidusage-badargs/Impls_1.scala b/test/files/neg/macro-invalidusage-badargs/Impls_1.scala index 678cb53929..8765cfbd5f 100644 --- a/test/files/neg/macro-invalidusage-badargs/Impls_1.scala +++ b/test/files/neg/macro-invalidusage-badargs/Impls_1.scala @@ -1,5 +1,5 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = x + def foo(c: Context)(x: c.Expr[Int]) = x } diff --git a/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala b/test/files/neg/macro-invalidusage-badbounds/Impls_1.scala index 393f7de976..1769da91e1 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.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo[U <: String](c: Ctx) = { import c.universe._; c.Expr[Unit](q"()") } + def foo[U <: String](c: Context) = { import c.universe._; c.Expr[Unit](q"()") } } diff --git a/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala b/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala index 678cb53929..8765cfbd5f 100644 --- a/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala +++ b/test/files/neg/macro-invalidusage-badtargs/Impls_1.scala @@ -1,5 +1,5 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = x + def foo(c: Context)(x: c.Expr[Int]) = x } diff --git a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala index 15894efb68..776f8bf71c 100644 --- a/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala +++ b/test/files/neg/macro-invalidusage-methodvaluesyntax/Impls_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx) = { + def foo(c: Context) = { import c.universe._ c.Expr[Unit](q"""println("it works")""") } diff --git a/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala b/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala index 44e508a1c6..b6b9611743 100644 --- a/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala +++ b/test/files/neg/macro-invalidusage-nontypeable/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx) = { + def foo(c: Context) = { import c.universe._ val body = Ident(TermName("IDoNotExist")) c.Expr[Int](body) diff --git a/test/files/neg/macro-invalidusage-presuper/Impls_1.scala b/test/files/neg/macro-invalidusage-presuper/Impls_1.scala index 02c87b5a81..ea98f01fa4 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.BlackboxContext +import scala.reflect.macros.blackbox.Context object Impls { - def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } + def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } } \ No newline at end of file diff --git a/test/files/neg/macro-noexpand/Impls_1.scala b/test/files/neg/macro-noexpand/Impls_1.scala index 3d5da9a2ed..acc6b52b7b 100644 --- a/test/files/neg/macro-noexpand/Impls_1.scala +++ b/test/files/neg/macro-noexpand/Impls_1.scala @@ -1,5 +1,5 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any]) = ??? } diff --git a/test/files/neg/macro-nontypeablebody/Impls_1.scala b/test/files/neg/macro-nontypeablebody/Impls_1.scala index 3d5da9a2ed..acc6b52b7b 100644 --- a/test/files/neg/macro-nontypeablebody/Impls_1.scala +++ b/test/files/neg/macro-nontypeablebody/Impls_1.scala @@ -1,5 +1,5 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = ??? + def foo(c: Context)(x: c.Expr[Any]) = ??? } diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala b/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala index 9c05db83e3..916b454463 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-a/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def impl(c: Ctx)(x: c.Expr[Int]) = x + def impl(c: Context)(x: c.Expr[Int]) = x } trait Foo { diff --git a/test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala b/test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala index c98279b2b8..17827abf7a 100644 --- a/test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala +++ b/test/files/neg/macro-override-macro-overrides-abstract-method-b/Impls_Macros_1.scala @@ -1,8 +1,8 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros trait T { def t(): Unit } trait A { def t(): Unit = () } -object Macro { def t(c: BlackboxContext)(): c.Expr[Unit] = c.universe.reify(()) } +object Macro { def t(c: Context)(): c.Expr[Unit] = c.universe.reify(()) } trait C extends T { self: A => override def t(): Unit = macro Macro.t } 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 f2d3f67ccc..f3917e3093 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 @@ -1,14 +1,14 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { + def impl(c: Context)(tag: String, x: c.Expr[_]) = { import c.{prefix => prefix} import c.universe._ c.Expr[Unit](q"println($tag, ${prefix.toString}, $x)") } - def fooBString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBString", x) - def fooBInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBInt", x) - def fooDInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooDInt", x) - def fooZString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooZString", x) + def fooBString(c: Context)(x: c.Expr[_]) = impl(c)("fooBString", x) + def fooBInt(c: Context)(x: c.Expr[_]) = impl(c)("fooBInt", x) + def fooDInt(c: Context)(x: c.Expr[_]) = impl(c)("fooDInt", x) + def fooZString(c: Context)(x: c.Expr[_]) = impl(c)("fooZString", x) } \ No newline at end of file diff --git a/test/files/neg/macro-quasiquotes/Macros_1.scala b/test/files/neg/macro-quasiquotes/Macros_1.scala index 098e4b3b92..7bfdbaeef9 100644 --- a/test/files/neg/macro-quasiquotes/Macros_1.scala +++ b/test/files/neg/macro-quasiquotes/Macros_1.scala @@ -1,7 +1,7 @@ import language.experimental.macros -import scala.reflect.macros.BlackboxMacro +import scala.reflect.macros.blackbox.Macro -trait Impls extends BlackboxMacro { +trait Impls extends Macro { import c.universe._ def impl1(x: Expr[Int]) = q"println(x)" def impl2(x: Tree) = q"println(x)" diff --git a/test/files/neg/macro-reify-splice-splice/Macros_1.scala b/test/files/neg/macro-reify-splice-splice/Macros_1.scala index 691f22ad07..306e78ad97 100644 --- a/test/files/neg/macro-reify-splice-splice/Macros_1.scala +++ b/test/files/neg/macro-reify-splice-splice/Macros_1.scala @@ -1,10 +1,10 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Macros { def foo = macro Impls.foo object Impls { - def foo(c: Ctx) = c.universe.reify { + def foo(c: Context) = c.universe.reify { { c.universe.reify(c.universe.reify("hello world")) }.splice.splice } } 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 6b73a96184..035913f3e3 100644 --- a/test/files/neg/macro-without-xmacros-a/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-a/Impls_1.scala @@ -1,17 +1,17 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def foo_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr(q"$x + 1") } - def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def bar_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr(q"$x + 2") } - def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def quux_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr(q"$x + 3") } 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 6b73a96184..035913f3e3 100644 --- a/test/files/neg/macro-without-xmacros-b/Impls_1.scala +++ b/test/files/neg/macro-without-xmacros-b/Impls_1.scala @@ -1,17 +1,17 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def foo_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr(q"$x + 1") } - def bar_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def bar_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr(q"$x + 2") } - def quux_impl(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + def quux_impl(c: Context)(x: c.Expr[Int]): c.Expr[Int] = { import c.universe._ c.Expr(q"$x + 3") } diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check index 9271f709ca..7d4f7fb63a 100644 --- a/test/files/neg/t5689.check +++ b/test/files/neg/t5689.check @@ -1,7 +1,7 @@ t5689.scala:4: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(i: c.Expr[Double]): c.Expr[String] - or : (c: scala.reflect.macros.BlackboxContext)(i: c.Tree): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(i: c.Expr[Double]): c.Expr[Int] + required: (c: scala.reflect.macros.blackbox.Context)(i: c.Expr[Double]): c.Expr[String] + or : (c: scala.reflect.macros.blackbox.Context)(i: c.Tree): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(i: c.Expr[Double]): c.Expr[Int] type mismatch for return type: c.Expr[Int] does not conform to c.Expr[String] def returnsString(i: Double): String = macro returnsIntImpl ^ diff --git a/test/files/neg/t5689.scala b/test/files/neg/t5689.scala index d0e468849d..d757a55417 100644 --- a/test/files/neg/t5689.scala +++ b/test/files/neg/t5689.scala @@ -1,6 +1,6 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { def returnsString(i: Double): String = macro returnsIntImpl - def returnsIntImpl(c: BlackboxContext)(i: c.Expr[Double]): c.Expr[Int] = ??? + def returnsIntImpl(c: Context)(i: c.Expr[Double]): c.Expr[Int] = ??? } diff --git a/test/files/neg/t5753/Impls_Macros_1.scala b/test/files/neg/t5753/Impls_Macros_1.scala index 0e81e21c77..9872c69171 100644 --- a/test/files/neg/t5753/Impls_Macros_1.scala +++ b/test/files/neg/t5753/Impls_Macros_1.scala @@ -1,6 +1,6 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context trait Impls { - def impl(c: Ctx)(x: c.Expr[Any]) = x + def impl(c: Context)(x: c.Expr[Any]) = x } diff --git a/test/files/neg/t5753/Test_2.scala b/test/files/neg/t5753/Test_2.scala index 150850a0eb..d52ed65c60 100644 --- a/test/files/neg/t5753/Test_2.scala +++ b/test/files/neg/t5753/Test_2.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Macros extends Impls { def foo(x: Any): Any = macro impl diff --git a/test/files/neg/t5903a/Macros_1.scala b/test/files/neg/t5903a/Macros_1.scala index ce1b035260..5d084ceed5 100644 --- a/test/files/neg/t5903a/Macros_1.scala +++ b/test/files/neg/t5903a/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import language.experimental.macros trait Tree @@ -13,7 +13,7 @@ object NewQuasiquotes { } object QuasiquoteMacros { - def unapplyImpl(c: WhiteboxContext)(t: c.Tree) = { + def unapplyImpl(c: Context)(t: c.Tree) = { import c.universe._ q""" new { diff --git a/test/files/neg/t5903b/Macros_1.scala b/test/files/neg/t5903b/Macros_1.scala index dfe9d8d489..6ce49c0228 100644 --- a/test/files/neg/t5903b/Macros_1.scala +++ b/test/files/neg/t5903b/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros object Interpolation { @@ -10,7 +10,7 @@ object Interpolation { } object Macros { - def unapplyImpl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Tree) = { + def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { import c.universe._ q""" new { diff --git a/test/files/neg/t5903c/Macros_1.scala b/test/files/neg/t5903c/Macros_1.scala index d13c3c2ec2..4792f00454 100644 --- a/test/files/neg/t5903c/Macros_1.scala +++ b/test/files/neg/t5903c/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros object Interpolation { @@ -10,7 +10,7 @@ object Interpolation { } object Macros { - def unapplyImpl[T: c.WeakTypeTag](c: BlackboxContext)(x: c.Tree) = { + def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { import c.universe._ if (!(c.weakTypeOf[Int] =:= c.weakTypeOf[T])) c.abort(c.enclosingPosition, s"${c.weakTypeOf[T]} is not supported") else { diff --git a/test/files/neg/t5903d/Macros_1.scala b/test/files/neg/t5903d/Macros_1.scala index 2d26e998a1..3500c2a782 100644 --- a/test/files/neg/t5903d/Macros_1.scala +++ b/test/files/neg/t5903d/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros object Interpolation { @@ -10,7 +10,7 @@ object Interpolation { } object Macros { - def unapplyImpl(c: BlackboxContext)(x: c.Tree) = { + def unapplyImpl(c: Context)(x: c.Tree) = { import c.universe._ q""" class Match(x: Int) { diff --git a/test/files/neg/t5903e/Macros_1.scala b/test/files/neg/t5903e/Macros_1.scala index 5bdc25b832..a64ff7e0b9 100644 --- a/test/files/neg/t5903e/Macros_1.scala +++ b/test/files/neg/t5903e/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import language.experimental.macros object Interpolation { @@ -10,7 +10,7 @@ object Interpolation { } object Macros { - def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = { + def unapplyImpl(c: Context)(x: c.Tree) = { import c.universe._ q""" new { diff --git a/test/files/neg/t6123-explaintypes-macros.check b/test/files/neg/t6123-explaintypes-macros.check index ef545fcc32..2c86f3c9cc 100644 --- a/test/files/neg/t6123-explaintypes-macros.check +++ b/test/files/neg/t6123-explaintypes-macros.check @@ -1,9 +1,9 @@ c.universe.Expr[Any]* <: c.universe.Expr[String]*? false BadMac_2.scala:6: error: macro implementation has incompatible shape: - required: (c: scala.reflect.macros.BlackboxContext)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] - or : (c: scala.reflect.macros.BlackboxContext)(format: c.Tree, params: Tree*): c.Tree - found : (c: scala.reflect.macros.BlackboxContext)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] + required: (c: scala.reflect.macros.blackbox.Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] + or : (c: scala.reflect.macros.blackbox.Context)(format: c.Tree, params: Tree*): c.Tree + found : (c: scala.reflect.macros.blackbox.Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] type mismatch for parameter params: c.Expr[Any]* does not conform to c.Expr[String]* def printf(format: String, params: Any*): Unit = macro printf_impl ^ diff --git a/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala b/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala index 456e753893..75ded4ef7d 100644 --- a/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala +++ b/test/files/neg/t6123-explaintypes-macros/BadMac_2.scala @@ -1,8 +1,8 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context // explain some macro types to me object BadMac { def printf(format: String, params: Any*): Unit = macro printf_impl - def printf_impl(c: BlackboxContext)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] = ??? + def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[String]*): c.Expr[Unit] = ??? } diff --git a/test/files/neg/t6123-explaintypes-macros/Macros.scala b/test/files/neg/t6123-explaintypes-macros/Macros.scala index cdcea34272..f2238b39a7 100644 --- a/test/files/neg/t6123-explaintypes-macros/Macros.scala +++ b/test/files/neg/t6123-explaintypes-macros/Macros.scala @@ -1,9 +1,9 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { def printf(format: String, params: Any*): Unit = macro printf_impl - def printf_impl(c: BlackboxContext)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ??? + def printf_impl(c: Context)(format: c.Expr[String], params: c.Expr[Any]*): c.Expr[Unit] = ??? } // something trivial to run diff --git a/test/files/neg/t6539/Macro_1.scala b/test/files/neg/t6539/Macro_1.scala index 454489752c..60db669c46 100644 --- a/test/files/neg/t6539/Macro_1.scala +++ b/test/files/neg/t6539/Macro_1.scala @@ -1,9 +1,9 @@ import language.experimental.macros -import reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object M { def m(a: Any, b: Any): Any = macro mImpl - def mImpl(c: BlackboxContext)(a: c.Expr[Any], b: c.Expr[Any]) = c.universe.reify(println(a.splice)) + def mImpl(c: Context)(a: c.Expr[Any], b: c.Expr[Any]) = c.universe.reify(println(a.splice)) @reflect.internal.annotations.compileTimeOnly("cto may only be used as an argument to " + "m") def cto = 0 diff --git a/test/files/neg/t7157/Impls_Macros_1.scala b/test/files/neg/t7157/Impls_Macros_1.scala index 16cb001422..31d4d786d0 100644 --- a/test/files/neg/t7157/Impls_Macros_1.scala +++ b/test/files/neg/t7157/Impls_Macros_1.scala @@ -1,31 +1,31 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros object Macros { - def impl1_0_0(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } - def impl1_1_1(c: BlackboxContext)(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } - def impl1_2_2(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl1_0_0(c: Context)() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl1_1_1(c: Context)(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl1_2_2(c: Context)(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } 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: BlackboxContext)(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } - def impl1_1_inf(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } - def impl1_2_inf(c: BlackboxContext)(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl1_0_inf(c: Context)(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl1_1_inf(c: Context)(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + 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"""println("hello world")""") } 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: BlackboxContext)()() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } - def impl2_1_1(c: BlackboxContext)()(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } - def impl2_2_2(c: BlackboxContext)()(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl2_0_0(c: Context)()() = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl2_1_1(c: Context)()(x: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl2_2_2(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } 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: BlackboxContext)()(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } - def impl2_1_inf(c: BlackboxContext)()(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } - def impl2_2_inf(c: BlackboxContext)()(x: c.Expr[Int], y: c.Expr[Int], z: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl2_0_inf(c: Context)()(x: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def impl2_1_inf(c: Context)()(x: c.Expr[Int], y: c.Expr[Int]*) = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + 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"""println("hello world")""") } 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/neg/t8104/Macros_1.scala b/test/files/neg/t8104/Macros_1.scala index 21d81a3687..2ad4bc5a99 100644 --- a/test/files/neg/t8104/Macros_1.scala +++ b/test/files/neg/t8104/Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context object Macros { - def impl[T](c: WhiteboxContext)(implicit T: c.WeakTypeTag[T]) = { + def impl[T](c: Context)(implicit T: c.WeakTypeTag[T]) = { import c.universe._ import definitions._ val fields = T.tpe.declarations.toList.collect{ case x: TermSymbol if x.isVal && x.isCaseAccessor => x } -- cgit v1.2.3 From 3a689f5c426436aea716567625fd6167e57bef92 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sun, 12 Jan 2014 00:17:25 +0100 Subject: changes bundles to be classes, not traits extending Macro Adjusts bundle notation to read `class Bundle(val c: Context)` instead of `class Bundle extends Macro`. This avoids calling compileLate in the macro compiler and associated tooling problems. --- .../scala/reflect/macros/compiler/Errors.scala | 2 +- .../scala/reflect/macros/compiler/Resolvers.scala | 35 +++-------------- .../scala/reflect/macros/compiler/Validators.scala | 6 +-- .../macros/runtime/JavaReflectionRuntimes.scala | 4 +- src/compiler/scala/tools/nsc/Global.scala | 19 ---------- .../scala/reflect/internal/Definitions.scala | 44 ++++++++++------------ .../scala/reflect/macros/blackbox/Macro.scala | 40 -------------------- .../scala/reflect/macros/whitebox/Macro.scala | 40 -------------------- .../scala/reflect/runtime/JavaUniverseForce.scala | 2 - test/files/neg/macro-bundle-abstract.check | 6 +-- test/files/neg/macro-bundle-abstract.scala | 4 +- test/files/neg/macro-bundle-class.check | 4 -- test/files/neg/macro-bundle-class.scala | 10 ----- test/files/neg/macro-bundle-mixbox.check | 4 -- test/files/neg/macro-bundle-mixbox.scala | 11 ------ test/files/neg/macro-bundle-noncontext.check | 4 ++ test/files/neg/macro-bundle-noncontext.scala | 9 +++++ test/files/neg/macro-bundle-nonmacro.check | 4 -- test/files/neg/macro-bundle-nonmacro.scala | 9 ----- test/files/neg/macro-bundle-object.scala | 4 +- test/files/neg/macro-bundle-polymorphic.check | 10 ----- test/files/neg/macro-bundle-polymorphic.scala | 12 ------ test/files/neg/macro-bundle-trait.check | 2 +- test/files/neg/macro-bundle-trait.scala | 4 +- test/files/neg/macro-quasiquotes/Macros_1.scala | 4 +- test/files/run/macro-bundle-repl.check | 12 +++--- test/files/run/macro-bundle-repl.scala | 6 +-- .../run/macro-bundle-static/Impls_Macros_1.scala | 6 +-- test/files/run/macro-bundle-static/Test_2.scala | 4 +- .../run/macro-bundle-toplevel/Impls_Macros_1.scala | 6 +-- test/files/run/macro-bundle-toplevel/Test_2.scala | 4 +- test/files/run/macro-bundle-whitebox.check | 6 +++ .../run/macro-bundle-whitebox/Impls_Macros_1.scala | 26 +++++++++++++ test/files/run/macro-bundle-whitebox/Test_2.scala | 8 ++++ test/files/run/macro-quasiquotes/Macros_1.scala | 4 +- 35 files changed, 116 insertions(+), 259 deletions(-) delete mode 100644 src/reflect/scala/reflect/macros/blackbox/Macro.scala delete mode 100644 src/reflect/scala/reflect/macros/whitebox/Macro.scala delete mode 100644 test/files/neg/macro-bundle-class.check delete mode 100644 test/files/neg/macro-bundle-class.scala delete mode 100644 test/files/neg/macro-bundle-mixbox.check delete mode 100644 test/files/neg/macro-bundle-mixbox.scala create mode 100644 test/files/neg/macro-bundle-noncontext.check create mode 100644 test/files/neg/macro-bundle-noncontext.scala delete mode 100644 test/files/neg/macro-bundle-nonmacro.check delete mode 100644 test/files/neg/macro-bundle-nonmacro.scala delete mode 100644 test/files/neg/macro-bundle-polymorphic.check delete mode 100644 test/files/neg/macro-bundle-polymorphic.scala create mode 100644 test/files/run/macro-bundle-whitebox.check create mode 100644 test/files/run/macro-bundle-whitebox/Impls_Macros_1.scala create mode 100644 test/files/run/macro-bundle-whitebox/Test_2.scala (limited to 'test/files/neg') diff --git a/src/compiler/scala/reflect/macros/compiler/Errors.scala b/src/compiler/scala/reflect/macros/compiler/Errors.scala index a408a6ec62..6b6d4248aa 100644 --- a/src/compiler/scala/reflect/macros/compiler/Errors.scala +++ b/src/compiler/scala/reflect/macros/compiler/Errors.scala @@ -51,7 +51,7 @@ trait Errors extends Traces { def MacroBundleNonStaticError() = bundleRefError("macro bundles must be static") - def MacroBundleWrongShapeError() = bundleRefError("macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member") + def MacroBundleWrongShapeError() = bundleRefError("macro bundles must be concrete classes having a single `val c: Context` parameter") // compatibility errors diff --git a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala index 05daf852ef..d35f1c32a9 100644 --- a/src/compiler/scala/reflect/macros/compiler/Resolvers.scala +++ b/src/compiler/scala/reflect/macros/compiler/Resolvers.scala @@ -40,36 +40,11 @@ trait Resolvers { } val untypedImplRef = typer.silent(_.typedTypeConstructor(maybeBundleRef)) match { - case SilentResultValue(result) if mightBeMacroBundleType(result.tpe) => - val bundleProto = result.tpe.typeSymbol - val bundlePkg = bundleProto.enclosingPackageClass - if (!isMacroBundleProtoType(bundleProto.tpe)) MacroBundleWrongShapeError() - if (!bundleProto.owner.isStaticOwner) MacroBundleNonStaticError() - - // synthesize the bundle, i.e. given a static `trait Foo extends *box.Macro { def expand = ... } ` - // create a top-level definition `class Foo$Bundle(val c: *box.Context) extends Foo` in a package next to `Foo` - val bundlePid = gen.mkUnattributedRef(bundlePkg) - val bundlePrefix = - if (bundlePkg == EmptyPackageClass) bundleProto.fullName('$') - else bundleProto.fullName('$').substring(bundlePkg.fullName('$').length + 1) - val bundleName = TypeName(bundlePrefix + tpnme.MACRO_BUNDLE_SUFFIX) - val existingBundle = bundleProto.enclosingPackageClass.info.decl(bundleName) - if (!currentRun.compiles(existingBundle)) { - val contextType = if (isBlackboxMacroBundleType(bundleProto.tpe)) BlackboxContextClass.tpe else WhiteboxContextClass.tpe - def mkContextValDef(flags: Long) = ValDef(Modifiers(flags), nme.c, TypeTree(contextType), EmptyTree) - val contextField = mkContextValDef(PARAMACCESSOR) - val contextParam = mkContextValDef(PARAM | PARAMACCESSOR) - val bundleCtor = DefDef(Modifiers(), nme.CONSTRUCTOR, Nil, List(List(contextParam)), TypeTree(), Block(List(pendingSuperCall), Literal(Constant(())))) - val bundleParent = gen.mkAppliedTypeTree(Ident(bundleProto), bundleProto.typeParams.map(sym => Ident(sym.name))) - val bundleTemplate = Template(List(bundleParent), noSelfType, List(contextField, bundleCtor)) - val bundle = atPos(bundleProto.pos)(ClassDef(NoMods, bundleName, bundleProto.typeParams.map(TypeDef(_)), bundleTemplate)) - currentRun.compileLate(bundleName + ".scala", PackageDef(bundlePid, List(bundle))) - } - - // synthesize the macro impl reference, which is going to look like: - // `new FooBundle(???).macroName` plus the optional type arguments - val bundleInstance = New(Select(bundlePid, bundleName), List(List(Ident(Predef_???)))) - atPos(macroDdef.rhs.pos)(gen.mkTypeApply(Select(bundleInstance, methName), targs)) + case SilentResultValue(result) if looksLikeMacroBundleType(result.tpe) => + val bundle = result.tpe.typeSymbol + if (!isMacroBundleType(bundle.tpe)) MacroBundleWrongShapeError() + if (!bundle.owner.isStaticOwner) MacroBundleNonStaticError() + atPos(macroDdef.rhs.pos)(gen.mkTypeApply(Select(New(bundle, Ident(Predef_???)), methName), targs)) case _ => macroDdef.rhs } diff --git a/src/compiler/scala/reflect/macros/compiler/Validators.scala b/src/compiler/scala/reflect/macros/compiler/Validators.scala index 95cb0f7466..02c1f7c431 100644 --- a/src/compiler/scala/reflect/macros/compiler/Validators.scala +++ b/src/compiler/scala/reflect/macros/compiler/Validators.scala @@ -26,9 +26,9 @@ trait Validators { if (macroImpl.isOverloaded) MacroImplOverloadedError() val implicitParams = aparamss.flatten filter (_.isImplicit) if (implicitParams.nonEmpty) MacroImplNonTagImplicitParameters(implicitParams) - val declaredInStaticObject = isImplMethod && (macroImplOwner.isStaticOwner || macroImplOwner.moduleClass.isStaticOwner) - val declaredInTopLevelClass = isImplBundle && macroImplOwner.owner.isPackageClass - if (!declaredInStaticObject && !declaredInTopLevelClass) MacroImplReferenceWrongShapeError() + val effectiveOwner = if (isImplMethod) macroImplOwner else macroImplOwner.owner + val declaredInStaticObject = effectiveOwner.isStaticOwner || effectiveOwner.moduleClass.isStaticOwner + if (!declaredInStaticObject) MacroImplReferenceWrongShapeError() } private def checkMacroDefMacroImplCorrespondence() = { diff --git a/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala index 450cb4d9ea..8ad38ff5f0 100644 --- a/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala +++ b/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala @@ -2,7 +2,7 @@ package scala.reflect.macros package runtime import scala.reflect.runtime.ReflectionUtils -import scala.reflect.macros.{Context => ApiContext} +import scala.reflect.macros.blackbox.{Context => ApiContext} trait JavaReflectionRuntimes { self: scala.tools.nsc.typechecker.Analyzer => @@ -19,7 +19,7 @@ trait JavaReflectionRuntimes { macroLogVerbose(s"successfully loaded macro impl as ($implClass, $implMeth)") args => { val implObj = - if (isBundle) implClass.getConstructor(classOf[ApiContext]).newInstance(args.c) + if (isBundle) implClass.getConstructors().head.newInstance(args.c) else ReflectionUtils.staticSingletonInstance(implClass) val implArgs = if (isBundle) args.others else args.c +: args.others implMeth.invoke(implObj, implArgs.asInstanceOf[Seq[AnyRef]]: _*) diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 5f079a428b..5492e563dd 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -1710,25 +1710,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) } } - /** Create and compile a synthetic compilation unit from the provided tree. - * - * This needs to create a virtual file underlying the compilation unit in order to appease SBT. - * However this file cannot have a randomly generated name, because then SBT 0.13 goes into a vicious loop - * as described on the mailing list: https://groups.google.com/forum/#!msg/scala-user/r1SgSoVfs0U/Wv4av0LOKukJ - * Therefore I have introduced an additional parameter that makes everyone specify meaningful file names. - */ - def compileLate(virtualFileName: String, code: PackageDef) { - // compatibility with SBT - // on the one hand, we need to specify some jfile here, otherwise sbt crashes with an NPE (SI-6870) - // on the other hand, we can't specify the obvious enclosingUnit, because then sbt somehow fails to run tests using type macros - val fakeJfile = new java.io.File(virtualFileName) - val virtualFile = new VirtualFile(virtualFileName) { override def file = fakeJfile } - val sourceFile = new BatchSourceFile(virtualFile, code.toString) - val unit = new CompilationUnit(sourceFile) - unit.body = code - compileLate(unit) - } - /** Reset package class to state at typer (not sure what this * is needed for?) */ diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 133442bdb5..03826a3011 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -482,10 +482,6 @@ trait Definitions extends api.StandardDefinitions { lazy val TypeCreatorClass = getClassIfDefined("scala.reflect.api.TypeCreator") // defined in scala-reflect.jar, so we need to be careful lazy val TreeCreatorClass = getClassIfDefined("scala.reflect.api.TreeCreator") // defined in scala-reflect.jar, so we need to be careful - lazy val BlackboxMacroClass = getClassIfDefined("scala.reflect.macros.blackbox.Macro") // defined in scala-reflect.jar, so we need to be careful - def BlackboxMacroContextValue = BlackboxMacroClass.map(sym => getMemberValue(sym, nme.c)) - lazy val WhiteboxMacroClass = getClassIfDefined("scala.reflect.macros.whitebox.Macro") // defined in scala-reflect.jar, so we need to be careful - def WhiteboxMacroContextValue = WhiteboxMacroClass.map(sym => getMemberValue(sym, nme.c)) lazy val BlackboxContextClass = getClassIfDefined("scala.reflect.macros.blackbox.Context") // defined in scala-reflect.jar, so we need to be careful lazy val WhiteboxContextClass = getClassIfDefined("scala.reflect.macros.whitebox.Context") // defined in scala-reflect.jar, so we need to be careful def MacroContextPrefix = BlackboxContextClass.map(sym => getMemberMethod(sym, nme.prefix)) @@ -603,32 +599,30 @@ trait Definitions extends api.StandardDefinitions { def isWhiteboxContextType(tp: Type) = isMacroContextType(tp) && (tp <:< WhiteboxContextClass.tpe) - def mightBeMacroBundleType(tp: Type) = - tp.baseClasses.contains(WhiteboxMacroClass) || - tp.baseClasses.contains(BlackboxMacroClass) - - def isMacroBundleType(tp: Type) = tp.baseClasses match { - case _ :: proto :: _ if isMacroBundleProtoType(proto.tpe) => true - case _ => false + private def macroBundleParamInfo(tp: Type) = { + val ctor = tp.erasure.typeSymbol.primaryConstructor + ctor.paramss match { + case List(List(c)) => + val sym = c.info.typeSymbol + val isContextCompatible = sym.isNonBottomSubClass(BlackboxContextClass) || sym.isNonBottomSubClass(WhiteboxContextClass) + if (isContextCompatible) c.info else NoType + case _ => + NoType + } } - def isBlackboxMacroBundleType(tp: Type) = - isMacroBundleType(tp) && (tp <:< BlackboxMacroClass.tpe) && !(tp <:< WhiteboxMacroClass.tpe) + def looksLikeMacroBundleType(tp: Type) = + macroBundleParamInfo(tp) != NoType - def isMacroBundleProtoType(tp: Type) = { - val sym = tp.typeSymbol - val isNonTrivial = tp != ErrorType && tp != NothingTpe && tp != NullTpe - def subclasses(sym: Symbol) = sym != NoSymbol && tp.baseClasses.contains(sym) - val isMacroCompatible = subclasses(BlackboxMacroClass) ^ subclasses(WhiteboxMacroClass) - val isBundlePrototype = sym != BlackboxMacroClass && sym != WhiteboxMacroClass && sym.isTrait && { - val c = sym.info.member(nme.c) - def overrides(sym: Symbol) = c.overrideChain.contains(sym) - val cIsOk = (overrides(BlackboxMacroContextValue) || overrides(WhiteboxMacroContextValue)) && c.isDeferred - cIsOk && sym.isMonomorphicType - } - isNonTrivial && isMacroCompatible && isBundlePrototype + def isMacroBundleType(tp: Type) = { + val isContextCompatible = macroBundleParamInfo(tp) != NoType + val nonAbstract = !tp.erasure.typeSymbol.isAbstractClass + isContextCompatible && nonAbstract } + def isBlackboxMacroBundleType(tp: Type) = + isMacroBundleType(tp) && (macroBundleParamInfo(tp) <:< BlackboxContextClass.tpe) + def isIterableType(tp: Type) = tp <:< classExistentialType(IterableClass) // These "direct" calls perform no dealiasing. They are most needed when diff --git a/src/reflect/scala/reflect/macros/blackbox/Macro.scala b/src/reflect/scala/reflect/macros/blackbox/Macro.scala deleted file mode 100644 index e51aca6896..0000000000 --- a/src/reflect/scala/reflect/macros/blackbox/Macro.scala +++ /dev/null @@ -1,40 +0,0 @@ -package scala -package reflect -package macros -package blackbox - -/** - * EXPERIMENTAL - * - * Traditionally macro implementations are defined as methods, - * but this trait provides an alternative way of encoding macro impls as - * bundles, traits which extend `scala.reflect.macros.blackbox.Macro` or`scala.reflect.macros.whitebox.Macro` . - * - * Instead of: - * - * import scala.reflect.macros.blackbox._ - * def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[Int]) = ... - * - * One can write: - * - * import scala.reflect.macros.blackbox._ - * trait Impl extends Macro { - * def apply[T: c.WeakTypeTag](x: c.Expr[Int]) = ... - * } - * - * Without changing anything else at all. - * - * This language feature is useful in itself in cases when macro implementations - * are complex and need to be modularized. State of the art technique of addressing this need is quite heavyweight: - * http://docs.scala-lang.org/overviews/macros/overview.html#writing_bigger_macros. - * - * @see `scala.reflect.macros.whitebox.Macro` - */ -trait Macro { - /** The context to be used by the macro implementation. - * - * Vanilla macro implementations have to carry it in their signatures, however when a macro is a full-fledged module, - * it can define the context next to the implementation, makes implementation signature more lightweight. - */ - val c: Context -} diff --git a/src/reflect/scala/reflect/macros/whitebox/Macro.scala b/src/reflect/scala/reflect/macros/whitebox/Macro.scala deleted file mode 100644 index af8539268e..0000000000 --- a/src/reflect/scala/reflect/macros/whitebox/Macro.scala +++ /dev/null @@ -1,40 +0,0 @@ -package scala -package reflect -package macros -package whitebox - -/** - * EXPERIMENTAL - * - * Traditionally macro implementations are defined as methods, - * but this trait provides an alternative way of encoding macro impls as - * bundles, traits which extend `scala.reflect.macros.blackbox.Macro` or`scala.reflect.macros.whitebox.Macro` . - * - * Instead of: - * - * import scala.reflect.macros.whitebox._ - * def impl[T: c.WeakTypeTag](c: Context)(x: c.Expr[Int]) = ... - * - * One can write: - * - * import scala.reflect.macros.whitebox._ - * trait Impl extends Macro { - * def apply[T: c.WeakTypeTag](x: c.Expr[Int]) = ... - * } - * - * Without changing anything else at all. - * - * This language feature is useful in itself in cases when macro implementations - * are complex and need to be modularized. State of the art technique of addressing this need is quite heavyweight: - * http://docs.scala-lang.org/overviews/macros/overview.html#writing_bigger_macros. - * - * @see `scala.reflect.macros.blackbox.Macro` - */ -trait Macro { - /** The context to be used by the macro implementation. - * - * Vanilla macro implementations have to carry it in their signatures, however when a macro is a full-fledged module, - * it can define the context next to the implementation, makes implementation signature more lightweight. - */ - val c: Context -} diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala index c87995275f..7ba8a0a295 100644 --- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala +++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala @@ -319,8 +319,6 @@ trait JavaUniverseForce { self: runtime.JavaUniverse => definitions.MirrorClass definitions.TypeCreatorClass definitions.TreeCreatorClass - definitions.BlackboxMacroClass - definitions.WhiteboxMacroClass definitions.BlackboxContextClass definitions.WhiteboxContextClass definitions.MacroImplAnnotation diff --git a/test/files/neg/macro-bundle-abstract.check b/test/files/neg/macro-bundle-abstract.check index 8766e2a436..010d0768c9 100644 --- a/test/files/neg/macro-bundle-abstract.check +++ b/test/files/neg/macro-bundle-abstract.check @@ -1,4 +1,4 @@ -macro-bundle-abstract.scala:4: error: class Bundle$Bundle needs to be abstract, since method deferred in trait Bundle of type => Int is not defined -trait Bundle extends Macro { - ^ +macro-bundle-abstract.scala:10: error: macro bundles must be concrete classes having a single `val c: Context` parameter + def foo = macro Bundle.impl + ^ one error found diff --git a/test/files/neg/macro-bundle-abstract.scala b/test/files/neg/macro-bundle-abstract.scala index 4ed2f4f7e5..0afeaafc01 100644 --- a/test/files/neg/macro-bundle-abstract.scala +++ b/test/files/neg/macro-bundle-abstract.scala @@ -1,7 +1,7 @@ import scala.language.experimental.macros -import scala.reflect.macros.blackbox.Macro +import scala.reflect.macros.blackbox.Context -trait Bundle extends Macro { +abstract class Bundle(c: Context) { def deferred: Int def impl = ??? } diff --git a/test/files/neg/macro-bundle-class.check b/test/files/neg/macro-bundle-class.check deleted file mode 100644 index 95ba45b169..0000000000 --- a/test/files/neg/macro-bundle-class.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-bundle-class.scala:9: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member - def foo = macro Bundle.impl - ^ -one error found diff --git a/test/files/neg/macro-bundle-class.scala b/test/files/neg/macro-bundle-class.scala deleted file mode 100644 index 40a7ae0625..0000000000 --- a/test/files/neg/macro-bundle-class.scala +++ /dev/null @@ -1,10 +0,0 @@ -import scala.language.experimental.macros -import scala.reflect.macros.blackbox._ - -class Bundle(val c: Context) extends Macro { - def impl = ??? -} - -object Macros { - def foo = macro Bundle.impl -} \ No newline at end of file diff --git a/test/files/neg/macro-bundle-mixbox.check b/test/files/neg/macro-bundle-mixbox.check deleted file mode 100644 index 38aad273ea..0000000000 --- a/test/files/neg/macro-bundle-mixbox.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-bundle-mixbox.scala:10: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member - def foo = macro Bundle.impl - ^ -one error found diff --git a/test/files/neg/macro-bundle-mixbox.scala b/test/files/neg/macro-bundle-mixbox.scala deleted file mode 100644 index 17120aaf07..0000000000 --- a/test/files/neg/macro-bundle-mixbox.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.language.experimental.macros -import scala.reflect.macros.blackbox.{Macro => BlackboxMacro} -import scala.reflect.macros.whitebox.{Macro => WhiteboxMacro} - -trait Bundle extends BlackboxMacro with WhiteboxMacro { - def impl = ??? -} - -object Macros { - def foo = macro Bundle.impl -} \ No newline at end of file diff --git a/test/files/neg/macro-bundle-noncontext.check b/test/files/neg/macro-bundle-noncontext.check new file mode 100644 index 0000000000..bb5d0851f5 --- /dev/null +++ b/test/files/neg/macro-bundle-noncontext.check @@ -0,0 +1,4 @@ +macro-bundle-noncontext.scala:8: error: not found: value Bundle + def foo = Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-noncontext.scala b/test/files/neg/macro-bundle-noncontext.scala new file mode 100644 index 0000000000..c228827e70 --- /dev/null +++ b/test/files/neg/macro-bundle-noncontext.scala @@ -0,0 +1,9 @@ +import scala.language.experimental.macros + +class Bundle { + def impl = ??? +} + +object Macros { + def foo = Bundle.impl +} \ No newline at end of file diff --git a/test/files/neg/macro-bundle-nonmacro.check b/test/files/neg/macro-bundle-nonmacro.check deleted file mode 100644 index 5a265b5724..0000000000 --- a/test/files/neg/macro-bundle-nonmacro.check +++ /dev/null @@ -1,4 +0,0 @@ -macro-bundle-nonmacro.scala:8: error: not found: value Bundle - def foo = Bundle.impl - ^ -one error found diff --git a/test/files/neg/macro-bundle-nonmacro.scala b/test/files/neg/macro-bundle-nonmacro.scala deleted file mode 100644 index c7d99f4582..0000000000 --- a/test/files/neg/macro-bundle-nonmacro.scala +++ /dev/null @@ -1,9 +0,0 @@ -import scala.language.experimental.macros - -trait Bundle { - def impl = ??? -} - -object Macros { - def foo = Bundle.impl -} \ No newline at end of file diff --git a/test/files/neg/macro-bundle-object.scala b/test/files/neg/macro-bundle-object.scala index 02278e7165..6e1eec1686 100644 --- a/test/files/neg/macro-bundle-object.scala +++ b/test/files/neg/macro-bundle-object.scala @@ -1,7 +1,7 @@ import scala.language.experimental.macros -import scala.reflect.macros.blackbox._ +import scala.reflect.macros.blackbox.Context -object Bundle extends Macro { +object Bundle { val c: Context = ??? def impl = ??? } diff --git a/test/files/neg/macro-bundle-polymorphic.check b/test/files/neg/macro-bundle-polymorphic.check deleted file mode 100644 index 8eedce7e87..0000000000 --- a/test/files/neg/macro-bundle-polymorphic.check +++ /dev/null @@ -1,10 +0,0 @@ -macro-bundle-polymorphic.scala:9: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member - def foo = macro Bundle.impl - ^ -macro-bundle-polymorphic.scala:10: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member - def foo = macro Bundle[Int].impl - ^ -macro-bundle-polymorphic.scala:11: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member - def foo = macro Bundle[Int, Nothing].impl - ^ -three errors found diff --git a/test/files/neg/macro-bundle-polymorphic.scala b/test/files/neg/macro-bundle-polymorphic.scala deleted file mode 100644 index b636b6bd6a..0000000000 --- a/test/files/neg/macro-bundle-polymorphic.scala +++ /dev/null @@ -1,12 +0,0 @@ -import scala.language.experimental.macros -import scala.reflect.macros.blackbox.Macro - -trait Bundle[T] extends Macro { - def impl = ??? -} - -object Macros { - def foo = macro Bundle.impl - def foo = macro Bundle[Int].impl - def foo = macro Bundle[Int, Nothing].impl -} \ No newline at end of file diff --git a/test/files/neg/macro-bundle-trait.check b/test/files/neg/macro-bundle-trait.check index d7363fc361..869c67e1e3 100644 --- a/test/files/neg/macro-bundle-trait.check +++ b/test/files/neg/macro-bundle-trait.check @@ -1,4 +1,4 @@ -macro-bundle-trait.scala:10: error: macro bundles must be monomorphic traits extending either blackbox.Macro or whitebox.Macro and not implementing their `val c: Context` member +macro-bundle-trait.scala:10: error: not found: value Bundle def foo = macro Bundle.impl ^ one error found diff --git a/test/files/neg/macro-bundle-trait.scala b/test/files/neg/macro-bundle-trait.scala index 0d01459f7e..2aa63216f5 100644 --- a/test/files/neg/macro-bundle-trait.scala +++ b/test/files/neg/macro-bundle-trait.scala @@ -1,7 +1,7 @@ import scala.language.experimental.macros -import scala.reflect.macros.blackbox._ +import scala.reflect.macros.blackbox.Context -trait Bundle extends Macro { +trait Bundle { val c: Context = ??? def impl = ??? } diff --git a/test/files/neg/macro-quasiquotes/Macros_1.scala b/test/files/neg/macro-quasiquotes/Macros_1.scala index 7bfdbaeef9..b123c475c2 100644 --- a/test/files/neg/macro-quasiquotes/Macros_1.scala +++ b/test/files/neg/macro-quasiquotes/Macros_1.scala @@ -1,7 +1,7 @@ import language.experimental.macros -import scala.reflect.macros.blackbox.Macro +import scala.reflect.macros.blackbox.Context -trait Impls extends Macro { +class Impls(val c: Context) { import c.universe._ def impl1(x: Expr[Int]) = q"println(x)" def impl2(x: Tree) = q"println(x)" diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check index e5456c411b..4a0b421606 100644 --- a/test/files/run/macro-bundle-repl.check +++ b/test/files/run/macro-bundle-repl.check @@ -4,17 +4,17 @@ Type :help for more information. scala> import scala.language.experimental.macros import scala.language.experimental.macros -scala> import scala.reflect.macros.blackbox.Macro -import scala.reflect.macros.blackbox.Macro +scala> import scala.reflect.macros.blackbox.Context +import scala.reflect.macros.blackbox.Context -scala> trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl -defined trait Bar +scala> class Bar(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl +defined class Bar defined term macro bar: Unit scala> bar -scala> trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } } -defined trait Foo +scala> class Foo(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } } +defined class Foo scala> def foo: Unit = macro Foo.impl defined term macro foo: Unit diff --git a/test/files/run/macro-bundle-repl.scala b/test/files/run/macro-bundle-repl.scala index 4dfd450b69..8084418454 100644 --- a/test/files/run/macro-bundle-repl.scala +++ b/test/files/run/macro-bundle-repl.scala @@ -3,10 +3,10 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ import scala.language.experimental.macros -import scala.reflect.macros.blackbox.Macro -trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl +import scala.reflect.macros.blackbox.Context +class Bar(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar: Unit = macro Bar.impl bar -trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } } +class Foo(val c: Context) { def impl = { import c.universe._; c.Expr[Unit](q"()") } } def foo: Unit = 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 34328edcd8..0142e5d945 100644 --- a/test/files/run/macro-bundle-static/Impls_Macros_1.scala +++ b/test/files/run/macro-bundle-static/Impls_Macros_1.scala @@ -1,8 +1,8 @@ -import scala.reflect.macros.blackbox.Macro +import scala.reflect.macros.blackbox.Context import scala.language.experimental.macros object Enclosing { - trait Impl extends Macro { + class Impl(val c: Context) { 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 @@ -16,7 +16,7 @@ object Macros { package pkg { object Enclosing { - trait Impl extends Macro { + class Impl(val c: Context) { 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-static/Test_2.scala b/test/files/run/macro-bundle-static/Test_2.scala index 72160f6ec2..e35260cdce 100644 --- a/test/files/run/macro-bundle-static/Test_2.scala +++ b/test/files/run/macro-bundle-static/Test_2.scala @@ -1,8 +1,8 @@ object Test extends App { println(Macros.mono) println(Macros.poly[Int]) - println(new Enclosing.Impl{val c = ???}.weird) + println(new Enclosing.Impl(???).weird) println(pkg.Macros.mono) println(pkg.Macros.poly[Int]) - println(new pkg.Enclosing.Impl{val c = ???}.weird) + println(new pkg.Enclosing.Impl(???).weird) } \ No newline at end of file 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 aa71346889..6fd7be3b25 100644 --- a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala +++ b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala @@ -1,6 +1,6 @@ -import scala.reflect.macros.blackbox.Macro +import scala.reflect.macros.blackbox.Context -trait Impl extends Macro { +class Impl(val c: Context) { 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 @@ -12,7 +12,7 @@ object Macros { } package pkg { - trait Impl extends Macro { + class Impl(val c: Context) { 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/Test_2.scala b/test/files/run/macro-bundle-toplevel/Test_2.scala index 139cc5bef2..195fb49262 100644 --- a/test/files/run/macro-bundle-toplevel/Test_2.scala +++ b/test/files/run/macro-bundle-toplevel/Test_2.scala @@ -1,8 +1,8 @@ object Test extends App { println(Macros.mono) println(Macros.poly[Int]) - println(new Impl{val c = ???}.weird) + println(new Impl(???).weird) println(pkg.Macros.mono) println(pkg.Macros.poly[Int]) - println(new pkg.Impl{val c = ???}.weird) + println(new pkg.Impl(???).weird) } \ No newline at end of file diff --git a/test/files/run/macro-bundle-whitebox.check b/test/files/run/macro-bundle-whitebox.check new file mode 100644 index 0000000000..37c8eaf27a --- /dev/null +++ b/test/files/run/macro-bundle-whitebox.check @@ -0,0 +1,6 @@ +() +Int +() +true +IntInt +true diff --git a/test/files/run/macro-bundle-whitebox/Impls_Macros_1.scala b/test/files/run/macro-bundle-whitebox/Impls_Macros_1.scala new file mode 100644 index 0000000000..5e1b11895d --- /dev/null +++ b/test/files/run/macro-bundle-whitebox/Impls_Macros_1.scala @@ -0,0 +1,26 @@ +import scala.language.experimental.macros +import scala.reflect.macros.whitebox.Context + +class Impl(val c: Context) { + 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 +} + +object Macros { + def mono = macro Impl.mono + def poly[T] = macro Impl.poly[T] +} + +package pkg { + class Impl(val c: Context) { + 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 + } + + object Macros { + def mono = macro Impl.mono + def poly[T] = macro Impl.poly[T] + } +} \ No newline at end of file diff --git a/test/files/run/macro-bundle-whitebox/Test_2.scala b/test/files/run/macro-bundle-whitebox/Test_2.scala new file mode 100644 index 0000000000..195fb49262 --- /dev/null +++ b/test/files/run/macro-bundle-whitebox/Test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + println(Macros.mono) + println(Macros.poly[Int]) + println(new Impl(???).weird) + println(pkg.Macros.mono) + println(pkg.Macros.poly[Int]) + println(new pkg.Impl(???).weird) +} \ No newline at end of file diff --git a/test/files/run/macro-quasiquotes/Macros_1.scala b/test/files/run/macro-quasiquotes/Macros_1.scala index 9e0f4ec0db..764542a870 100644 --- a/test/files/run/macro-quasiquotes/Macros_1.scala +++ b/test/files/run/macro-quasiquotes/Macros_1.scala @@ -1,7 +1,7 @@ import language.experimental.macros -import scala.reflect.macros.blackbox.Macro +import scala.reflect.macros.blackbox.Context -trait Impls extends Macro { +class Impls(val c: Context) { import c.universe._ def impl1 = q"println(1)" def impl2 = q"{ println(2); println(3) }" -- cgit v1.2.3 From e36888c3d953048483ccea9a95d5984b54ad6ebc Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sun, 12 Jan 2014 12:01:12 +0100 Subject: prohibits constructor overloading for macro bundles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per Jason’s feedback, this commit handles overloaded constructors in macro bundles. The backend now checks that we have a constructor of a correct type. The frontend now prohibits multiple constructors altogether. --- src/compiler/scala/reflect/macros/compiler/Errors.scala | 2 +- .../reflect/macros/runtime/JavaReflectionRuntimes.scala | 15 ++++++++++++--- src/reflect/scala/reflect/internal/Definitions.scala | 3 ++- test/files/neg/macro-bundle-abstract.check | 2 +- test/files/neg/macro-bundle-overloaded.check | 4 ++++ test/files/neg/macro-bundle-overloaded.scala | 12 ++++++++++++ 6 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 test/files/neg/macro-bundle-overloaded.check create mode 100644 test/files/neg/macro-bundle-overloaded.scala (limited to 'test/files/neg') diff --git a/src/compiler/scala/reflect/macros/compiler/Errors.scala b/src/compiler/scala/reflect/macros/compiler/Errors.scala index 6b6d4248aa..280baa2a42 100644 --- a/src/compiler/scala/reflect/macros/compiler/Errors.scala +++ b/src/compiler/scala/reflect/macros/compiler/Errors.scala @@ -51,7 +51,7 @@ trait Errors extends Traces { def MacroBundleNonStaticError() = bundleRefError("macro bundles must be static") - def MacroBundleWrongShapeError() = bundleRefError("macro bundles must be concrete classes having a single `val c: Context` parameter") + def MacroBundleWrongShapeError() = bundleRefError("macro bundles must be concrete classes having a single constructor with a `val c: Context` parameter") // compatibility errors diff --git a/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala b/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala index 8ad38ff5f0..ecdd48db22 100644 --- a/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala +++ b/src/compiler/scala/reflect/macros/runtime/JavaReflectionRuntimes.scala @@ -2,7 +2,9 @@ package scala.reflect.macros package runtime import scala.reflect.runtime.ReflectionUtils -import scala.reflect.macros.blackbox.{Context => ApiContext} +import scala.reflect.macros.blackbox.{Context => BlackboxContext} +import scala.reflect.macros.whitebox.{Context => WhiteboxContext} +import java.lang.reflect.{Constructor => jConstructor} trait JavaReflectionRuntimes { self: scala.tools.nsc.typechecker.Analyzer => @@ -19,8 +21,15 @@ trait JavaReflectionRuntimes { macroLogVerbose(s"successfully loaded macro impl as ($implClass, $implMeth)") args => { val implObj = - if (isBundle) implClass.getConstructors().head.newInstance(args.c) - else ReflectionUtils.staticSingletonInstance(implClass) + if (isBundle) { + def isMacroContext(clazz: Class[_]) = clazz == classOf[BlackboxContext] || clazz == classOf[WhiteboxContext] + def isBundleCtor(ctor: jConstructor[_]) = ctor.getParameterTypes match { + case Array(param) if isMacroContext(param) => true + case _ => false + } + val Array(bundleCtor) = implClass.getConstructors.filter(isBundleCtor) + bundleCtor.newInstance(args.c) + } else ReflectionUtils.staticSingletonInstance(implClass) val implArgs = if (isBundle) args.others else args.c +: args.others implMeth.invoke(implObj, implArgs.asInstanceOf[Seq[AnyRef]]: _*) } diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 03826a3011..29a8e62b6e 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -616,8 +616,9 @@ trait Definitions extends api.StandardDefinitions { def isMacroBundleType(tp: Type) = { val isContextCompatible = macroBundleParamInfo(tp) != NoType + val hasSingleConstructor = !tp.declaration(nme.CONSTRUCTOR).isOverloaded val nonAbstract = !tp.erasure.typeSymbol.isAbstractClass - isContextCompatible && nonAbstract + isContextCompatible && hasSingleConstructor && nonAbstract } def isBlackboxMacroBundleType(tp: Type) = diff --git a/test/files/neg/macro-bundle-abstract.check b/test/files/neg/macro-bundle-abstract.check index 010d0768c9..3afd079521 100644 --- a/test/files/neg/macro-bundle-abstract.check +++ b/test/files/neg/macro-bundle-abstract.check @@ -1,4 +1,4 @@ -macro-bundle-abstract.scala:10: error: macro bundles must be concrete classes having a single `val c: Context` parameter +macro-bundle-abstract.scala:10: error: macro bundles must be concrete classes having a single constructor with a `val c: Context` parameter def foo = macro Bundle.impl ^ one error found diff --git a/test/files/neg/macro-bundle-overloaded.check b/test/files/neg/macro-bundle-overloaded.check new file mode 100644 index 0000000000..fc94ff0000 --- /dev/null +++ b/test/files/neg/macro-bundle-overloaded.check @@ -0,0 +1,4 @@ +macro-bundle-overloaded.scala:11: error: macro bundles must be concrete classes having a single constructor with a `val c: Context` parameter + def foo = macro Bundle.impl + ^ +one error found diff --git a/test/files/neg/macro-bundle-overloaded.scala b/test/files/neg/macro-bundle-overloaded.scala new file mode 100644 index 0000000000..a4bc66f974 --- /dev/null +++ b/test/files/neg/macro-bundle-overloaded.scala @@ -0,0 +1,12 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.{Context => BlackboxContext} +import scala.reflect.macros.whitebox.{Context => WhiteboxContext} + +class Bundle(val c: BlackboxContext) { + def this(c: WhiteboxContext) = this(c: BlackboxContext) + def impl = ??? +} + +object Macros { + def foo = macro Bundle.impl +} \ No newline at end of file -- cgit v1.2.3