diff options
Diffstat (limited to 'test/files/run')
253 files changed, 1277 insertions, 636 deletions
diff --git a/test/files/run/idempotency-case-classes.scala b/test/files/run/idempotency-case-classes.scala index 4da8393cb6..81e119582b 100644 --- a/test/files/run/idempotency-case-classes.scala +++ b/test/files/run/idempotency-case-classes.scala @@ -10,7 +10,7 @@ object Test extends App { } println(casee.eval) val tb = cm.mkToolBox() - val tcasee = tb.typeCheck(casee.tree) + val tcasee = tb.typecheck(casee.tree) println(tcasee) val rtcasee = tb.resetAllAttrs(tcasee) try { diff --git a/test/files/run/idempotency-extractors.scala b/test/files/run/idempotency-extractors.scala index fe033295f5..b66b043be1 100644 --- a/test/files/run/idempotency-extractors.scala +++ b/test/files/run/idempotency-extractors.scala @@ -10,7 +10,7 @@ object Test extends App { } println(extractor.eval) val tb = cm.mkToolBox() - val textractor = tb.typeCheck(extractor.tree) + val textractor = tb.typecheck(extractor.tree) println(textractor) val rtextractor = tb.resetAllAttrs(textractor) try { diff --git a/test/files/run/idempotency-labels.scala b/test/files/run/idempotency-labels.scala index 82d009751a..f1a185d3d0 100644 --- a/test/files/run/idempotency-labels.scala +++ b/test/files/run/idempotency-labels.scala @@ -11,7 +11,7 @@ object Test extends App { } println(label.eval) val tb = cm.mkToolBox() - val tlabel = tb.typeCheck(label.tree) + val tlabel = tb.typecheck(label.tree) println(tlabel) val rtlabel = tb.resetAllAttrs(tlabel) try { diff --git a/test/files/run/idempotency-lazy-vals.scala b/test/files/run/idempotency-lazy-vals.scala index 3531f9ff4b..e763f2f3f4 100644 --- a/test/files/run/idempotency-lazy-vals.scala +++ b/test/files/run/idempotency-lazy-vals.scala @@ -15,7 +15,7 @@ object Test extends App { } println(lazee.eval) val tb = cm.mkToolBox() - val tlazee = tb.typeCheck(lazee.tree) + val tlazee = tb.typecheck(lazee.tree) println(tlazee) val rtlazee = tb.resetAllAttrs(tlazee) try { diff --git a/test/files/run/idempotency-this.scala b/test/files/run/idempotency-this.scala index 5cd4226326..2db1efd2d1 100644 --- a/test/files/run/idempotency-this.scala +++ b/test/files/run/idempotency-this.scala @@ -9,7 +9,7 @@ object Test extends App { } println(thiss.eval) val tb = cm.mkToolBox() - val tthiss = tb.typeCheck(thiss.tree) + val tthiss = tb.typecheck(thiss.tree) println(tthiss) println(showRaw(tthiss)) val rtthiss = tb.resetAllAttrs(tthiss) diff --git a/test/files/run/macro-abort-fresh/Macros_1.scala b/test/files/run/macro-abort-fresh/Macros_1.scala index 350d7b41aa..2b03512efb 100644 --- a/test/files/run/macro-abort-fresh/Macros_1.scala +++ b/test/files/run/macro-abort-fresh/Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Impls { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ println(c.fresh()) println(c.fresh("qwe")) diff --git a/test/files/run/macro-auto-duplicate/Macros_1.scala b/test/files/run/macro-auto-duplicate/Macros_1.scala index 255dafd47e..2c910e6af7 100644 --- a/test/files/run/macro-auto-duplicate/Macros_1.scala +++ b/test/files/run/macro-auto-duplicate/Macros_1.scala @@ -1,8 +1,8 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros object Macros { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ val x = Ident(newTermName("x")) def defAndUseX(rhs: Tree) = { diff --git a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala index c63353164e..fc75b99ef2 100644 --- a/test/files/run/macro-basic-ma-md-mi/Impls_1.scala +++ b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala @@ -1,19 +1,19 @@ -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._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } - 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._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } - 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._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) diff --git a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala index 3cdd531316..73a5a971a4 100644 --- a/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala +++ b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala @@ -1,19 +1,19 @@ -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._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } - 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._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } - 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._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) diff --git a/test/files/run/macro-basic-mamd-mi/Impls_1.scala b/test/files/run/macro-basic-mamd-mi/Impls_1.scala index 3feddd2786..0be915c119 100644 --- a/test/files/run/macro-basic-mamd-mi/Impls_1.scala +++ b/test/files/run/macro-basic-mamd-mi/Impls_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(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(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(Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(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._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) diff --git a/test/files/run/macro-blackbox-materialization/Macros_1.scala b/test/files/run/macro-blackbox-materialization/Macros_1.scala index 7c31dd7dc2..ea8d1bed14 100644 --- a/test/files/run/macro-blackbox-materialization/Macros_1.scala +++ b/test/files/run/macro-blackbox-materialization/Macros_1.scala @@ -1,6 +1,6 @@ // For the full version of the test, take a look at run/t5923a -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros case class C[T](t: String) @@ -9,7 +9,7 @@ object C { } object Macros { - def impl[T: c.WeakTypeTag](c: BlackboxContext) = { + def impl[T: c.WeakTypeTag](c: Context) = { import c.universe._ reify(C[T](c.literal(weakTypeOf[T].toString).splice)) } diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala index 8506239952..d46af4952d 100644 --- a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala +++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala @@ -1,5 +1,6 @@ import scala.language.experimental.macros -import scala.reflect.macros.{BlackboxContext, WhiteboxContext} +import scala.reflect.macros.blackbox.{Context => BlackboxContext} +import scala.reflect.macros.whitebox.{Context => WhiteboxContext} object Impls { def foo(c: BlackboxContext)(x: c.Expr[Int]) = x diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check index 8487042d66..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.BlackboxMacro -import scala.reflect.macros.BlackboxMacro +scala> import scala.reflect.macros.blackbox.Context +import scala.reflect.macros.blackbox.Context -scala> trait Bar extends BlackboxMacro { 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 BlackboxMacro { 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 db64f05943..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.BlackboxMacro -trait Bar extends BlackboxMacro { 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 BlackboxMacro { 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 b859411325..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.BlackboxMacro +import scala.reflect.macros.blackbox.Context import scala.language.experimental.macros object Enclosing { - trait Impl extends BlackboxMacro { + 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 BlackboxMacro { + 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 e026768642..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.BlackboxMacro +import scala.reflect.macros.blackbox.Context -trait Impl extends BlackboxMacro { +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 BlackboxMacro { + 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-def-path-dependent/Test_1.scala b/test/files/run/macro-def-path-dependent/Test_1.scala index bba97fcae1..4161a64303 100644 --- a/test/files/run/macro-def-path-dependent/Test_1.scala +++ b/test/files/run/macro-def-path-dependent/Test_1.scala @@ -2,7 +2,7 @@ // package test1 // -// import scala.reflect.macros.{BlackboxContext => Ctx} +// import scala.reflect.macros.blackbox.Context // // trait Exprs { // self: Universe => @@ -21,5 +21,5 @@ // trait Universe extends Exprs with Reifiers // // object Impls { -// def reify[T](cc: Ctx{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? +// def reify[T](cc: Context{ type PrefixType = Reifiers })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? // } diff --git a/test/files/run/macro-def-path-dependent/Test_2.scala b/test/files/run/macro-def-path-dependent/Test_2.scala index c884ab9d0b..75a03b54e7 100644 --- a/test/files/run/macro-def-path-dependent/Test_2.scala +++ b/test/files/run/macro-def-path-dependent/Test_2.scala @@ -1,6 +1,6 @@ package test2 -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context trait Exprs { self: Universe => @@ -18,5 +18,5 @@ trait Universe extends Exprs with Reifiers { } object Impls { - def reify[T](cc: Ctx{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? + def reify[T](cc: Context{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? } diff --git a/test/files/run/macro-def-path-dependent/Test_3.scala b/test/files/run/macro-def-path-dependent/Test_3.scala index 6d856d1450..1a5da8200b 100644 --- a/test/files/run/macro-def-path-dependent/Test_3.scala +++ b/test/files/run/macro-def-path-dependent/Test_3.scala @@ -1,6 +1,6 @@ package test3 -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context trait Exprs { self: Universe => @@ -18,5 +18,5 @@ trait Universe extends Exprs with Reifiers { } object Impls { - def reify[T](cc: Ctx{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? + def reify[T](cc: Context{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? } diff --git a/test/files/run/macro-def-path-dependent/Test_4.scala b/test/files/run/macro-def-path-dependent/Test_4.scala index 6562802013..67cb88ee6f 100644 --- a/test/files/run/macro-def-path-dependent/Test_4.scala +++ b/test/files/run/macro-def-path-dependent/Test_4.scala @@ -1,11 +1,11 @@ package test4 import scala.reflect.runtime.universe._ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import scala.reflect.api.Universe object Test { def materializeTypeTag[T](u: Universe)(e: T): u.TypeTag[T] = macro materializeTypeTag_impl[T] - def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? + def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? }
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent/Test_5.scala b/test/files/run/macro-def-path-dependent/Test_5.scala index 22407b850c..b518ce864c 100644 --- a/test/files/run/macro-def-path-dependent/Test_5.scala +++ b/test/files/run/macro-def-path-dependent/Test_5.scala @@ -1,9 +1,9 @@ package test56 import scala.reflect.runtime.universe._ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import scala.reflect.api.Universe object Impls { - def materializeTypeTag_impl[T: c.WeakTypeTag](c: BlackboxContext)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? + def materializeTypeTag_impl[T: c.WeakTypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? }
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent/Test_6.scala b/test/files/run/macro-def-path-dependent/Test_6.scala index 011e726b3f..a8b50ce7d2 100644 --- a/test/files/run/macro-def-path-dependent/Test_6.scala +++ b/test/files/run/macro-def-path-dependent/Test_6.scala @@ -1,7 +1,7 @@ package test56 import scala.reflect.runtime.universe._ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import scala.reflect.api.Universe object Macros { diff --git a/test/files/run/macro-default-params.check b/test/files/run/macro-default-params.check new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/test/files/run/macro-default-params.check @@ -0,0 +1 @@ +0 diff --git a/test/files/run/macro-default-params/Macros_1.scala b/test/files/run/macro-default-params/Macros_1.scala new file mode 100644 index 0000000000..74588a1cf4 --- /dev/null +++ b/test/files/run/macro-default-params/Macros_1.scala @@ -0,0 +1,27 @@ +import scala.language.experimental.macros +import scala.reflect.macros.whitebox.Context + +object Macros { + def id[A]: A = null.asInstanceOf[A] + + def foo: Any = macro impl + def impl(c: Context): c.Tree = { + import c.universe._ + import Flag._ + + lazy val tpe = TypeTree(typeOf[Int]) + + /* If we used this line instead, it would work! */ + // lazy val tpe = tq"Int" + + lazy val param: ValDef = { + val p1 = q"val a: ${tpe.duplicate} = Macros.id[${tpe.duplicate}]" + ValDef(Modifiers(DEFAULTPARAM), p1.name, p1.tpt, p1.rhs) + } + + q""" + class C { def f($param) = a } + println(new C().f()) + """ + } +} diff --git a/test/files/run/macro-reify-splice-splice/Test_2.scala b/test/files/run/macro-default-params/Test_2.scala index f697da6020..5d19639cdd 100644 --- a/test/files/run/macro-reify-splice-splice/Test_2.scala +++ b/test/files/run/macro-default-params/Test_2.scala @@ -1,3 +1,3 @@ object Test extends App { - println(Macros.foo) -}
\ No newline at end of file + Macros.foo +} diff --git a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala index 4bafa84128..85d0f0bb7e 100644 --- a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala +++ b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros trait Complex[T] @@ -7,7 +7,7 @@ class Foo(val bar: Bar) class Bar(val s: String) object Complex { - def impl[T: c.WeakTypeTag](c: BlackboxContext): 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/run/macro-duplicate/Impls_Macros_1.scala b/test/files/run/macro-duplicate/Impls_Macros_1.scala index ab852c9e46..84fb2c5b61 100644 --- a/test/files/run/macro-duplicate/Impls_Macros_1.scala +++ b/test/files/run/macro-duplicate/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) = { import c.universe._ val Expr(Block((cdef: ClassDef) :: Nil, _)) = reify { class C { def x = 2 } } val cdef1 = diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala index dfffb48e73..5b04cf29e9 100644 --- a/test/files/run/macro-enclosures/Impls_Macros_1.scala +++ b/test/files/run/macro-enclosures/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) = { import c.universe._ reify { println("enclosingPackage = " + c.Expr[String](Literal(Constant(c.enclosingPackage.toString))).splice) diff --git a/test/files/run/macro-expand-implicit-argument/Macros_1.scala b/test/files/run/macro-expand-implicit-argument/Macros_1.scala index 7ac30e3ff2..465f313ef2 100644 --- a/test/files/run/macro-expand-implicit-argument/Macros_1.scala +++ b/test/files/run/macro-expand-implicit-argument/Macros_1.scala @@ -5,7 +5,7 @@ import scala.{specialized => spec} import language.experimental.macros import scala.reflect.ClassTag -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { def alloc[@spec A:ClassTag](src:Array[A], s1:Int, len:Int) = { @@ -35,7 +35,7 @@ object Macros { * arr * } */ - def arrayMacro[A:c.WeakTypeTag](c:BlackboxContext)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = { + def arrayMacro[A:c.WeakTypeTag](c:Context)(as:c.Expr[A]*)(ct: c.Expr[ClassTag[A]]): c.Expr[Array[A]] = { import c.mirror._ import c.universe._ def const(x:Int) = Literal(Constant(x)) diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala index c56489e61c..18c97956e4 100644 --- a/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/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)(x: c.Expr[Int]) = { + def foo(c: Context)(x: c.Expr[Int]) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(x.tree)) c.Expr[Unit](body) diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala index f93d9100e8..aeceee5a5b 100644 --- a/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-implicit/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)(x: c.Expr[String]): c.Expr[Option[Int]] = { + def foo(c: Context)(x: c.Expr[String]): c.Expr[Option[Int]] = { import c.universe._ val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt")))) c.Expr[Option[Int]](body) diff --git a/test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala index a8b478e9f2..fd267d32c4 100644 --- a/test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-val/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._ val body = Literal(Constant(2)) c.Expr[Int](body) diff --git a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala index f93d9100e8..aeceee5a5b 100644 --- a/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala +++ b/test/files/run/macro-expand-implicit-macro-is-view/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)(x: c.Expr[String]): c.Expr[Option[Int]] = { + def foo(c: Context)(x: c.Expr[String]): c.Expr[Option[Int]] = { import c.universe._ val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, TermName("toInt")))) c.Expr[Option[Int]](body) diff --git a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala index bc3d768a67..9278633c11 100644 --- a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala +++ b/test/files/run/macro-expand-multiple-arglists/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)(x: c.Expr[Int])(y: c.Expr[Int]) = { + def foo(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._ val sum = Apply(Select(x.tree, TermName("$minus")), List(y.tree)) val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala index e0a048046f..9362d6c17a 100644 --- a/test/files/run/macro-expand-nullary-generic/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala @@ -1,15 +1,15 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def impl[T: c.WeakTypeTag](c: Ctx)(meth: String) = { + def impl[T: c.WeakTypeTag](c: Context)(meth: String) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(s"$meth[${c.weakTypeOf[T]}]")))) c.Expr[Unit](body) } - def fooNullary[T: c.WeakTypeTag](c: Ctx) = impl[T](c)("fooNullary") - def fooEmpty[T: c.WeakTypeTag](c: Ctx)() = impl[T](c)("fooEmpty") - def barNullary[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c)("barNullary") - def barEmpty[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c)("barEmpty") + def fooNullary[T: c.WeakTypeTag](c: Context) = impl[T](c)("fooNullary") + def fooEmpty[T: c.WeakTypeTag](c: Context)() = impl[T](c)("fooEmpty") + def barNullary[T: c.WeakTypeTag](c: Context)(x: c.Expr[Int]) = impl[T](c)("barNullary") + def barEmpty[T: c.WeakTypeTag](c: Context)(x: c.Expr[Int])() = impl[T](c)("barEmpty") }
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala index 5da33babd3..c8c3d255c4 100644 --- a/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala +++ b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala @@ -1,15 +1,15 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def impl(c: Ctx)(meth: String) = { + def impl(c: Context)(meth: String) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(meth)))) c.Expr[Unit](body) } - def fooNullary(c: Ctx) = impl(c)("fooNullary") - def fooEmpty(c: Ctx)() = impl(c)("fooEmpty") - def barNullary(c: Ctx)(x: c.Expr[Int]) = impl(c)("barNullary") - def barEmpty(c: Ctx)(x: c.Expr[Int])() = impl(c)("barEmpty") + def fooNullary(c: Context) = impl(c)("fooNullary") + def fooEmpty(c: Context)() = impl(c)("fooEmpty") + def barNullary(c: Context)(x: c.Expr[Int]) = impl(c)("barNullary") + def barEmpty(c: Context)(x: c.Expr[Int])() = impl(c)("barEmpty") }
\ No newline at end of file diff --git a/test/files/run/macro-expand-overload/Impls_1.scala b/test/files/run/macro-expand-overload/Impls_1.scala index ea68e9eb93..ef9d01d4ed 100644 --- a/test/files/run/macro-expand-overload/Impls_1.scala +++ b/test/files/run/macro-expand-overload/Impls_1.scala @@ -1,15 +1,15 @@ -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._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } - def fooObjectString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooObjectString", x) - def fooObjectInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooObjectInt", x) - def fooClassString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooClassString", x) - def fooClassInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooClassInt", x) + def fooObjectString(c: Context)(x: c.Expr[_]) = impl(c)("fooObjectString", x) + def fooObjectInt(c: Context)(x: c.Expr[_]) = impl(c)("fooObjectInt", x) + def fooClassString(c: Context)(x: c.Expr[_]) = impl(c)("fooClassString", x) + def fooClassInt(c: Context)(x: c.Expr[_]) = impl(c)("fooClassInt", x) }
\ No newline at end of file diff --git a/test/files/run/macro-expand-override/Impls_1.scala b/test/files/run/macro-expand-override/Impls_1.scala index 648641f578..e6ce18f172 100644 --- a/test/files/run/macro-expand-override/Impls_1.scala +++ b/test/files/run/macro-expand-override/Impls_1.scala @@ -1,15 +1,15 @@ -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._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) c.Expr[Unit](body) } - 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/run/macro-expand-recursive/Impls_1.scala b/test/files/run/macro-expand-recursive/Impls_1.scala index 8ba1a24540..3def2d2fbe 100644 --- a/test/files/run/macro-expand-recursive/Impls_1.scala +++ b/test/files/run/macro-expand-recursive/Impls_1.scala @@ -1,13 +1,13 @@ -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 = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works")))) c.Expr[Unit](body) } - def fooFoo(c: Ctx) = { + def fooFoo(c: Context) = { import c.universe._ val body = Select(Ident(TermName("Macros")), TermName("foo")) c.Expr[Unit](body) diff --git a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala index a255072774..95aaa1c3d7 100644 --- a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala @@ -1,12 +1,12 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Impls1 { - def foo[U <: String](c: BlackboxContext): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello")""") } + def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello")""") } } class C class D extends C object Impls2 { - def foo[U <: C](c: BlackboxContext): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello")""") } + def foo[U <: C](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello")""") } } diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala index e95d61a36a..c33ac6d1b7 100644 --- a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala @@ -1,8 +1,8 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo[U: c.WeakTypeTag](c: Ctx) = { + def foo[U: c.WeakTypeTag](c: Context) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala index 37cf785c0d..32cee0d5fb 100644 --- a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala @@ -1,8 +1,8 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo[U: c.WeakTypeTag](c: Ctx)(x: c.Expr[U]) = { + def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) diff --git a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala index 8f85ffff4a..289f07162b 100644 --- a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix/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](c: BlackboxContext)(x: c.Expr[U]) = { + def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] c.Expr[Unit](q"println(${U.toString})") @@ -10,7 +10,7 @@ object Impls1 { } object Impls2 { - def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[U]) = { + def foo[T: c.WeakTypeTag, U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { import c.universe._ val T = implicitly[c.WeakTypeTag[T]] val U = implicitly[c.WeakTypeTag[U]] @@ -20,7 +20,7 @@ object Impls2 { } object Impls345 { - def foo[T, U: c.WeakTypeTag, V](c: BlackboxContext)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { + def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ c.Expr(q""" println(${T.toString}) diff --git a/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala index 7bfff374e2..64f16c6a89 100644 --- a/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala +++ b/test/files/run/macro-expand-unapply-a/Impls_Macros_1.scala @@ -1,11 +1,11 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context object Helper { def unapplySeq[T](x: List[T]): Option[Seq[T]] = List.unapplySeq[T](x) } object Macros { - def impl[T: c.WeakTypeTag](c: WhiteboxContext)(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/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala index 2480af61ad..18af84583a 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/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)(xs: c.Expr[Int]*) = { + def foo(c: Context)(xs: c.Expr[Int]*) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList) c.Expr[Unit](body) diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala index a31c92a01c..4bdc5bec00 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/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)(xs: c.Expr[Int]*) = { + def foo(c: Context)(xs: c.Expr[Int]*) = { import c.universe._ val stripped_xs = xs map (_.tree) toList match { case List(Typed(stripped, Ident(wildstar))) if wildstar == tpnme.WILDCARD_STAR => List(stripped) diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala index 889240d628..64ab7de02a 100644 --- a/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala @@ -1,11 +1,11 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { def myprintln(xs: Int*) = { println(xs) } - def foo(c: Ctx)(xs: c.Expr[Int]*) = { + def foo(c: Context)(xs: c.Expr[Int]*) = { import c.universe._ val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList) c.Expr[Unit](body) diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala index 2480af61ad..18af84583a 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/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)(xs: c.Expr[Int]*) = { + def foo(c: Context)(xs: c.Expr[Int]*) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), xs.map(_.tree).toList) c.Expr[Unit](body) diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala index 889240d628..64ab7de02a 100644 --- a/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala @@ -1,11 +1,11 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { def myprintln(xs: Int*) = { println(xs) } - def foo(c: Ctx)(xs: c.Expr[Int]*) = { + def foo(c: Context)(xs: c.Expr[Int]*) = { import c.universe._ val body = Apply(Select(Ident(TermName("Impls")), TermName("myprintln")), xs.map(_.tree).toList) c.Expr[Unit](body) diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index aa76a410ea..9b1d0eed35 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -1,8 +1,8 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo_targs[T, U: c.WeakTypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = { + def foo_targs[T, U: c.WeakTypeTag](c: Context = null)(x: c.Expr[Int] = null) = { import c.{prefix => prefix} import c.universe._ val U = implicitly[c.WeakTypeTag[U]] diff --git a/test/files/run/macro-impl-relaxed/Macros_1.scala b/test/files/run/macro-impl-relaxed/Macros_1.scala index 3cf5090ec8..420eb2a399 100644 --- a/test/files/run/macro-impl-relaxed/Macros_1.scala +++ b/test/files/run/macro-impl-relaxed/Macros_1.scala @@ -1,11 +1,11 @@ import language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def implUU(c: BlackboxContext)(x: c.Tree): c.Tree = x - def implTU(c: BlackboxContext)(x: c.Expr[Int]): c.Tree = x.tree - def implUT(c: BlackboxContext)(x: c.Tree): c.Expr[Int] = c.Expr[Int](x) - def implTT(c: BlackboxContext)(x: c.Expr[Int]): c.Expr[Int] = x + def implUU(c: Context)(x: c.Tree): c.Tree = x + def implTU(c: Context)(x: c.Expr[Int]): c.Tree = x.tree + def implUT(c: Context)(x: c.Tree): c.Expr[Int] = c.Expr[Int](x) + def implTT(c: Context)(x: c.Expr[Int]): c.Expr[Int] = x def fooUU(x: Int): Int = macro implUU def fooTU(x: Int): Int = macro implTU diff --git a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala index c79fc30628..acc47fcde6 100644 --- a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = { + def foo(unconventionalName: Context)(x: unconventionalName.Expr[Int]) = { import unconventionalName.universe._ unconventionalName.Expr[Unit](q"""println("invoking foo...")""") } diff --git a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala index 55cf0dcafa..705defb18f 100644 --- a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala +++ b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala @@ -1,5 +1,5 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo[U <: String](c: Ctx): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } + def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"""println("hello world")""") } } diff --git a/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala b/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala index bcc746e39a..fc72e7a979 100644 --- a/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala +++ b/test/files/run/macro-impl-tparam-typetag-is-optional/Impls_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo[U](c: Ctx) = { + def foo[U](c: Context) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("don't know U")))) c.Expr[Unit](body) diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala index 5a51d27b24..603500b597 100644 --- a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/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): c.Expr[Int] = { + def foo(c: Context): c.Expr[Int] = { import c.universe._ c.Expr(Literal(Constant("42"))) } diff --git a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala index 44e508a1c6..b6b9611743 100644 --- a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidret-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/run/macro-invalidusage-badret/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala index a54eaa4001..0d4c5755f0 100644 --- a/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-badret/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: c.Expr[Int]) = x + def foo(c: Context)(x: c.Expr[Int]) = x } object Macros { diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala index a67a296335..8b5c59bde8 100644 --- a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo[T: c.WeakTypeTag](c: Ctx)(x: c.Expr[T]) = { + def foo[T: c.WeakTypeTag](c: Context)(x: c.Expr[T]) = { import c.universe._ val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(x.tree.toString)))) c.Expr[Unit](body) diff --git a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala index 88929df27a..6970b4dd7e 100644 --- a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala +++ b/test/files/run/macro-invalidusage-partialapplication/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: c.Expr[Int])(y: c.Expr[Int]) = { + def foo(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._ val sum = Apply(Select(x.tree, TermName("$plus")), List(y.tree)) val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(sum)) diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala index 22e94f32cd..b60ca90d91 100644 --- a/test/files/run/macro-openmacros/Impls_Macros_1.scala +++ b/test/files/run/macro-openmacros/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): c.Expr[Unit] = { + def impl(c: Context): c.Expr[Unit] = { // we're macros, so we can reflect against our source path // so we don't need any partests to clean up after us! val dir = c.enclosingUnit.source.file.file.getCanonicalFile.getParentFile diff --git a/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala index 2417eb6897..b623d8820a 100644 --- a/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala +++ b/test/files/run/macro-parse-position-malformed/Impls_Macros_1.scala @@ -1,8 +1,9 @@ import scala.language.experimental.macros -import scala.reflect.macros.{Context => Ctx, ParseException} +import scala.reflect.macros.blackbox.Context +import scala.reflect.macros.ParseException object Macros { - def impl(c: Ctx)() = { + def impl(c: Context)() = { import c.universe._ val out = try { c.parse("foo(bar") diff --git a/test/files/run/macro-parse-position/Impls_Macros_1.scala b/test/files/run/macro-parse-position/Impls_Macros_1.scala index 92f64a8e70..dd20fd291b 100644 --- a/test/files/run/macro-parse-position/Impls_Macros_1.scala +++ b/test/files/run/macro-parse-position/Impls_Macros_1.scala @@ -1,8 +1,8 @@ import scala.language.experimental.macros -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c: Ctx)() = { + def impl(c: Context)() = { import c.universe._ val t = c.parse("foo bar") val out = s"${t.pos == NoPosition}\n${t.pos}\n${t.pos.source.content.length}\n${new String(t.pos.source.content)}" diff --git a/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala b/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala index 04aa11b8fe..df189b70d3 100644 --- a/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala +++ b/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala @@ -1,8 +1,8 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Macros { object Impls { - def foo(c: Ctx)(x: c.Expr[Any]) = x + def foo(c: Context)(x: c.Expr[Any]) = x } def foo(x: Any) = macro Impls.foo diff --git a/test/files/run/macro-quasiquotes/Macros_1.scala b/test/files/run/macro-quasiquotes/Macros_1.scala index 81775d98e8..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.BlackboxMacro +import scala.reflect.macros.blackbox.Context -trait Impls extends BlackboxMacro { +class Impls(val c: Context) { import c.universe._ def impl1 = q"println(1)" def impl2 = q"{ println(2); println(3) }" diff --git a/test/files/run/macro-range/Common_1.scala b/test/files/run/macro-range/Common_1.scala index 1ad2a6c6eb..0e66815f15 100644 --- a/test/files/run/macro-range/Common_1.scala +++ b/test/files/run/macro-range/Common_1.scala @@ -1,4 +1,4 @@ -import reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context abstract class RangeDefault { val from, to: Int @@ -10,7 +10,7 @@ abstract class RangeDefault { /** This class should go into reflect.macro once it is a bit more stable. */ abstract class Utils { - val context: BlackboxContext + val context: Context import context.universe._ class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer { diff --git a/test/files/run/macro-range/Expansion_Impossible_2.scala b/test/files/run/macro-range/Expansion_Impossible_2.scala index fa869a2569..514de6864a 100644 --- a/test/files/run/macro-range/Expansion_Impossible_2.scala +++ b/test/files/run/macro-range/Expansion_Impossible_2.scala @@ -1,7 +1,7 @@ -import reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Impls { - def foreach(c: BlackboxContext)(f: c.Expr[Int => Unit]): c.Expr[Unit] = { + def foreach(c: Context)(f: c.Expr[Int => Unit]): c.Expr[Unit] = { // todo. read the compiler config and print if -Ydebug is set //println("macro-expand, _this = "+ _this) object utils extends Utils { val context: c.type = c } diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala index 53b96691e9..e964da2106 100644 --- a/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala +++ b/test/files/run/macro-reflective-ma-normal-mdmi/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: c.Expr[Int]) = { + def foo(c: Context)(x: c.Expr[Int]) = { import c.universe._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala index 81ad5cae0b..89a818d99c 100644 --- a/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala +++ b/test/files/run/macro-reflective-mamd-normal-mi/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)(x: c.Expr[Int]) = { + def foo(c: Context)(x: c.Expr[Int]) = { import c.universe._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) diff --git a/test/files/run/macro-reify-basic/Macros_1.scala b/test/files/run/macro-reify-basic/Macros_1.scala index e1a6d8abfb..1cf2a8a406 100644 --- a/test/files/run/macro-reify-basic/Macros_1.scala +++ b/test/files/run/macro-reify-basic/Macros_1.scala @@ -1,10 +1,10 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Macros { def foo(s: String) = macro Impls.foo object Impls { - def foo(c: Ctx)(s: c.Expr[String]) = c.universe.reify { + def foo(c: Context)(s: c.Expr[String]) = c.universe.reify { println("hello " + s.splice) } } diff --git a/test/files/run/macro-reify-freevars/Macros_1.scala b/test/files/run/macro-reify-freevars/Macros_1.scala index 2cd94f600a..912f602c6c 100644 --- a/test/files/run/macro-reify-freevars/Macros_1.scala +++ b/test/files/run/macro-reify-freevars/Macros_1.scala @@ -2,7 +2,7 @@ package scala.collection.slick object QueryableMacros{ def map[T:c.WeakTypeTag, S:c.WeakTypeTag] - (c: scala.reflect.macros.BlackboxContext) + (c: scala.reflect.macros.blackbox.Context) (projection: c.Expr[T => S]) : c.Expr[scala.collection.slick.Queryable[S]] = { import c.universe._ diff --git a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala index ebd80c02ba..8d2aa1e70a 100644 --- a/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala @@ -1,8 +1,8 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{universe => ru} -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context -case class Utils[C <: BlackboxContext]( c:C ) { +case class Utils[C <: Context]( c:C ) { import c.universe._ import c.{Tree=>_} object removeDoubleReify extends c.universe.Transformer { @@ -21,12 +21,12 @@ case class Utils[C <: BlackboxContext]( c:C ) { } } object QueryableMacros{ - def _helper[C <: BlackboxContext,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { + def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { import c.universe._ import treeBuild._ val element_type = implicitly[c.WeakTypeTag[S]].tpe val foo = c.Expr[ru.Expr[Queryable[S]]]( - c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck( + c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typecheck( Utils[c.type](c).removeDoubleReify( Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree )) ).asInstanceOf[Tree] @@ -34,7 +34,7 @@ object QueryableMacros{ c.universe.reify{ Queryable.factory[S]( foo.splice )} } def map[T:c.WeakTypeTag, S:c.WeakTypeTag] - (c: scala.reflect.macros.BlackboxContext) + (c: scala.reflect.macros.blackbox.Context) (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) } class Queryable[T]{ diff --git a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala index ebd80c02ba..8d2aa1e70a 100644 --- a/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala @@ -1,8 +1,8 @@ import scala.reflect.runtime.universe._ import scala.reflect.runtime.{universe => ru} -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context -case class Utils[C <: BlackboxContext]( c:C ) { +case class Utils[C <: Context]( c:C ) { import c.universe._ import c.{Tree=>_} object removeDoubleReify extends c.universe.Transformer { @@ -21,12 +21,12 @@ case class Utils[C <: BlackboxContext]( c:C ) { } } object QueryableMacros{ - def _helper[C <: BlackboxContext,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { + def _helper[C <: Context,S:c.WeakTypeTag]( c:C )( name:String, projection:c.Expr[_] ) = { import c.universe._ import treeBuild._ val element_type = implicitly[c.WeakTypeTag[S]].tpe val foo = c.Expr[ru.Expr[Queryable[S]]]( - c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typeCheck( + c.reifyTree( mkRuntimeUniverseRef, EmptyTree, c.typecheck( Utils[c.type](c).removeDoubleReify( Apply(Select(c.prefix.tree, TermName( name )), List( projection.tree )) ).asInstanceOf[Tree] @@ -34,7 +34,7 @@ object QueryableMacros{ c.universe.reify{ Queryable.factory[S]( foo.splice )} } def map[T:c.WeakTypeTag, S:c.WeakTypeTag] - (c: scala.reflect.macros.BlackboxContext) + (c: scala.reflect.macros.blackbox.Context) (projection: c.Expr[T => S]): c.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) } class Queryable[T]{ diff --git a/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala b/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala index bc0015774e..38ec6f022e 100644 --- a/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala +++ b/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala @@ -1,6 +1,6 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { val `Answer to the Ultimate Question of Life, the Universe, and Everything` = 42 - def foo(c: Ctx) = c.universe.reify { `Answer to the Ultimate Question of Life, the Universe, and Everything` } + def foo(c: Context) = c.universe.reify { `Answer to the Ultimate Question of Life, the Universe, and Everything` } } diff --git a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala index d89a5e380d..624479480d 100644 --- a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = { + def foo(c: Context)(x: c.Expr[Int]) = { import c.universe._ val x1 = c.Expr[Int](c.resetAllAttrs(x.tree)) c.Expr[Int](Literal(Constant(c.eval(x1)))) diff --git a/test/files/run/macro-reify-splice-splice.check b/test/files/run/macro-reify-splice-splice.check deleted file mode 100644 index 3b18e512db..0000000000 --- a/test/files/run/macro-reify-splice-splice.check +++ /dev/null @@ -1 +0,0 @@ -hello world diff --git a/test/files/run/macro-reify-splice-splice.flags b/test/files/run/macro-reify-splice-splice.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-reify-splice-splice.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-reify-splice-splice/Macros_1.scala b/test/files/run/macro-reify-splice-splice/Macros_1.scala deleted file mode 100644 index 691f22ad07..0000000000 --- a/test/files/run/macro-reify-splice-splice/Macros_1.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} - -object Macros { - def foo = macro Impls.foo - - object Impls { - def foo(c: Ctx) = c.universe.reify { - { c.universe.reify(c.universe.reify("hello world")) }.splice.splice - } - } -}
\ No newline at end of file diff --git a/test/files/run/macro-reify-staticXXX/Macros_1.scala b/test/files/run/macro-reify-staticXXX/Macros_1.scala index 077271d582..2993218bb4 100644 --- a/test/files/run/macro-reify-staticXXX/Macros_1.scala +++ b/test/files/run/macro-reify-staticXXX/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object B { override def toString = "object" } class C { override def toString = "class" } @@ -14,7 +14,7 @@ object foo { } object packageless { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ reify { println(B) @@ -31,7 +31,7 @@ object packageless { package packageful { object Test { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ reify { println(B) diff --git a/test/files/run/macro-reify-tagful-a/Macros_1.scala b/test/files/run/macro-reify-tagful-a/Macros_1.scala index 56d43c1c53..6f061fd26a 100644 --- a/test/files/run/macro-reify-tagful-a/Macros_1.scala +++ b/test/files/run/macro-reify-tagful-a/Macros_1.scala @@ -1,11 +1,11 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Macros { def foo[T](s: T) = macro Impls.foo[T] object Impls { - def foo[T: c.WeakTypeTag](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T: c.WeakTypeTag](c: Context)(s: c.Expr[T]) = c.universe.reify { List(s.splice) } } diff --git a/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala b/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala index 27acaa1626..faac3e3a31 100644 --- a/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala @@ -1,10 +1,10 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Macros { def foo[T](s: T) = macro Impls.foo[T] object Impls { - def foo[T](c: Ctx)(s: c.Expr[T]) = c.universe.reify { + def foo[T](c: Context)(s: c.Expr[T]) = c.universe.reify { List[T](s.splice) } } diff --git a/test/files/run/macro-reify-type/Macros_1.scala b/test/files/run/macro-reify-type/Macros_1.scala index 04634b649a..bac1744c50 100644 --- a/test/files/run/macro-reify-type/Macros_1.scala +++ b/test/files/run/macro-reify-type/Macros_1.scala @@ -1,10 +1,10 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import scala.reflect.runtime.{universe => ru} object StaticReflect { def method[A](name: String): ru.Type = macro methodImpl[A] - def methodImpl[A: c.WeakTypeTag](c: BlackboxContext)(name: c.Expr[String]): c.Expr[ru.Type] = { + def methodImpl[A: c.WeakTypeTag](c: Context)(name: c.Expr[String]): c.Expr[ru.Type] = { import c.universe._ val nameName: TermName = name.tree match { diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala index d1e71b3311..6e358eb72d 100644 --- a/test/files/run/macro-reify-unreify/Macros_1.scala +++ b/test/files/run/macro-reify-unreify/Macros_1.scala @@ -1,15 +1,15 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Macros { def foo(s: String) = macro Impls.foo object Impls { - def foo(c: Ctx)(s: c.Expr[String]) = { + def foo(c: Context)(s: c.Expr[String]) = { import c.universe._ import treeBuild._ val world = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, s.tree) - val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typeCheck(Apply(Select(Literal(Constant("hello ")), TermName("$plus")), List(c.unreifyTree(world))))) + val greeting = c.reifyTree(mkRuntimeUniverseRef, EmptyTree, c.typecheck(Apply(Select(Literal(Constant("hello ")), TermName("$plus")), List(c.unreifyTree(world))))) val typedGreeting = c.Expr[String](greeting) c.universe.reify { diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check index cc974897f2..86b4d472ed 100644 --- a/test/files/run/macro-repl-basic.check +++ b/test/files/run/macro-repl-basic.check @@ -4,25 +4,25 @@ Type :help for more information. scala> import language.experimental.macros import language.experimental.macros -scala> import scala.reflect.macros.{BlackboxContext => Ctx} -import scala.reflect.macros.{BlackboxContext=>Ctx} +scala> import scala.reflect.macros.blackbox.Context +import scala.reflect.macros.blackbox.Context scala> scala> object Impls { - def foo(c: Ctx)(x: c.Expr[Int]) = { + def foo(c: Context)(x: c.Expr[Int]) = { import c.universe._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) c.Expr[Int](body) } - def bar(c: Ctx)(x: c.Expr[Int]) = { + def bar(c: Context)(x: c.Expr[Int]) = { import c.universe._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) c.Expr[Int](body) } - def quux(c: Ctx)(x: c.Expr[Int]) = { + def quux(c: Context)(x: c.Expr[Int]) = { import c.universe._ val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) c.Expr[Int](body) diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala index dea36c481c..217f3bc0eb 100644 --- a/test/files/run/macro-repl-basic.scala +++ b/test/files/run/macro-repl-basic.scala @@ -3,22 +3,22 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ |import language.experimental.macros - |import scala.reflect.macros.{BlackboxContext => Ctx} + |import scala.reflect.macros.blackbox.Context | |object Impls { - | def foo(c: Ctx)(x: c.Expr[Int]) = { + | def foo(c: Context)(x: c.Expr[Int]) = { | import c.universe._ | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(1)))) | c.Expr[Int](body) | } | - | def bar(c: Ctx)(x: c.Expr[Int]) = { + | def bar(c: Context)(x: c.Expr[Int]) = { | import c.universe._ | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(2)))) | c.Expr[Int](body) | } | - | def quux(c: Ctx)(x: c.Expr[Int]) = { + | def quux(c: Context)(x: c.Expr[Int]) = { | import c.universe._ | val body = Apply(Select(x.tree, TermName("$plus")), List(Literal(Constant(3)))) | c.Expr[Int](body) diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check index 9f538c04b6..20d3b2d702 100644 --- a/test/files/run/macro-repl-dontexpand.check +++ b/test/files/run/macro-repl-dontexpand.check @@ -1,14 +1,14 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> def bar1(c: scala.reflect.macros.BlackboxContext) = ??? -bar1: (c: scala.reflect.macros.BlackboxContext)Nothing +scala> def bar1(c: scala.reflect.macros.blackbox.Context) = ??? +bar1: (c: scala.reflect.macros.blackbox.Context)Nothing scala> def foo1 = macro bar1 defined term macro foo1: Nothing -scala> def bar2(c: scala.reflect.macros.WhiteboxContext) = ??? -bar2: (c: scala.reflect.macros.WhiteboxContext)Nothing +scala> def bar2(c: scala.reflect.macros.whitebox.Context) = ??? +bar2: (c: scala.reflect.macros.whitebox.Context)Nothing scala> def foo2 = macro bar2 defined term macro foo2: Nothing diff --git a/test/files/run/macro-repl-dontexpand.scala b/test/files/run/macro-repl-dontexpand.scala index 733288e513..920f40084f 100644 --- a/test/files/run/macro-repl-dontexpand.scala +++ b/test/files/run/macro-repl-dontexpand.scala @@ -3,9 +3,9 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { override def extraSettings = "-language:experimental.macros" def code = """ - |def bar1(c: scala.reflect.macros.BlackboxContext) = ??? + |def bar1(c: scala.reflect.macros.blackbox.Context) = ??? |def foo1 = macro bar1 - |def bar2(c: scala.reflect.macros.WhiteboxContext) = ??? + |def bar2(c: scala.reflect.macros.whitebox.Context) = ??? |def foo2 = macro bar2 |""".stripMargin } diff --git a/test/files/run/macro-settings/Impls_Macros_1.scala b/test/files/run/macro-settings/Impls_Macros_1.scala index c9cecfa99f..851a987206 100644 --- a/test/files/run/macro-settings/Impls_Macros_1.scala +++ b/test/files/run/macro-settings/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Impls { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ reify { println(c.Expr[String](Literal(Constant(c.settings.toString))).splice) diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala index 3acc52dbe0..ded4d85cfc 100644 --- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context object Macros { - def impl(c: WhiteboxContext) = { + def impl(c: Context) = { import c.universe._ val inscope = c.inferImplicitValue(c.mirror.staticClass("SourceLocation").toType) diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala index f830d2af0d..f66ab71479 100644 --- a/test/files/run/macro-sip19/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context object Macros { - def impl(c: WhiteboxContext) = { + def impl(c: Context) = { import c.universe._ val Apply(fun, args) = c.enclosingImplicits(0).tree val fileName = fun.pos.source.file.file.getName diff --git a/test/files/run/macro-subpatterns/Macro_1.scala b/test/files/run/macro-subpatterns/Macro_1.scala index d8e86e27c6..2de6b4da9d 100644 --- a/test/files/run/macro-subpatterns/Macro_1.scala +++ b/test/files/run/macro-subpatterns/Macro_1.scala @@ -1,9 +1,9 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import language.experimental.macros object Extractor { def unapply(x: Any): Any = macro unapplyImpl - def unapplyImpl(c: WhiteboxContext)(x: c.Tree) = { + def unapplyImpl(c: Context)(x: c.Tree) = { val st = c.universe.asInstanceOf[reflect.internal.SymbolTable] import st._ val subpatterns = x.attachments.get[SubpatternsAttachment].get.patterns diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check index ceed1079b2..ffbd5a8aa8 100644 --- a/test/files/run/macro-system-properties.check +++ b/test/files/run/macro-system-properties.check @@ -1,14 +1,14 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> import language.experimental._, reflect.macros.BlackboxContext -import language.experimental._ -import reflect.macros.BlackboxContext +scala> import scala.language.experimental._, scala.reflect.macros.blackbox.Context +import scala.language.experimental._ +import scala.reflect.macros.blackbox.Context scala> object GrabContext { def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) // System.properties lets you stash true globals (unlike statics which are classloader scoped) - def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } + def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } def grab(): Unit = macro impl } defined object GrabContext diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala index 3325c1747a..db88eb7df6 100644 --- a/test/files/run/macro-system-properties.scala +++ b/test/files/run/macro-system-properties.scala @@ -3,11 +3,11 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ - import language.experimental._, reflect.macros.BlackboxContext + import scala.language.experimental._, scala.reflect.macros.blackbox.Context object GrabContext { def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) // System.properties lets you stash true globals (unlike statics which are classloader scoped) - def impl(c: BlackboxContext)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } + def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } def grab(): Unit = macro impl } object Test { class C(implicit a: Any) { GrabContext.grab } } diff --git a/test/files/run/macro-term-declared-in-annotation/Impls_1.scala b/test/files/run/macro-term-declared-in-annotation/Impls_1.scala index df3509731b..c4bcfbc1ba 100644 --- a/test/files/run/macro-term-declared-in-annotation/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-annotation/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala b/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-anonymous/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-anonymous/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-block/Impls_1.scala b/test/files/run/macro-term-declared-in-block/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-block/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-block/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-class-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class-class/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-class-class/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-class-class/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-class-object/Impls_1.scala b/test/files/run/macro-term-declared-in-class-object/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-class-object/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-class-object/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-class/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-class/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-default-param/Impls_1.scala b/test/files/run/macro-term-declared-in-default-param/Impls_1.scala index 4fae9b200f..ef0f136139 100644 --- a/test/files/run/macro-term-declared-in-default-param/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-default-param/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala index 053af625a2..ef00f6ff32 100644 --- a/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala +++ b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context object Impls { - def toOptionOfInt(c: Ctx) = { + def toOptionOfInt(c: Context) = { import c.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-method/Impls_1.scala b/test/files/run/macro-term-declared-in-method/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-method/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-method/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-object-class/Impls_1.scala b/test/files/run/macro-term-declared-in-object-class/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-object-class/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-object-class/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-object-object/Impls_1.scala b/test/files/run/macro-term-declared-in-object-object/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-object-object/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-object-object/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-object/Impls_1.scala b/test/files/run/macro-term-declared-in-object/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-object/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-object/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-package-object/Impls_1.scala b/test/files/run/macro-term-declared-in-package-object/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-package-object/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-package-object/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-refinement/Impls_1.scala b/test/files/run/macro-term-declared-in-refinement/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-refinement/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-refinement/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-term-declared-in-trait/Impls_1.scala b/test/files/run/macro-term-declared-in-trait/Impls_1.scala index d69422872b..c43f5f3f53 100644 --- a/test/files/run/macro-term-declared-in-trait/Impls_1.scala +++ b/test/files/run/macro-term-declared-in-trait/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.{prefix => prefix} import c.universe._ val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala index 9f7d6f641c..956331cfae 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala @@ -1,22 +1,22 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl_with_implicits_enabled(c: BlackboxContext) = { + def impl_with_implicits_enabled(c: Context) = { import c.universe._ val tree1 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) - val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false) + val ttree1 = c.typecheck(tree1, withImplicitViewsDisabled = false) c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_implicits_enabled = macro impl_with_implicits_enabled - def impl_with_implicits_disabled(c: BlackboxContext) = { + def impl_with_implicits_disabled(c: Context) = { import c.universe._ try { val tree2 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) - val ttree2 = c.typeCheck(tree2, withImplicitViewsDisabled = true) + val ttree2 = c.typecheck(tree2, withImplicitViewsDisabled = true) c.Expr[String](Literal(Constant(ttree2.toString))) } catch { case ex: Throwable => diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check index e0e880ab66..0579a4f4c8 100644 --- a/test/files/run/macro-typecheck-macrosdisabled.check +++ b/test/files/run/macro-typecheck-macrosdisabled.check @@ -1,4 +1,4 @@ -{ +({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(this.getClass().getClassLoader()); $u.Expr.apply[Int(2)]($m, { @@ -28,5 +28,5 @@ }; new $typecreator2() })) -} +}: reflect.runtime.universe.Expr[Int]) ru.reify[Int](2) diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index 41e58e0e4d..eb558f49b5 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -1,18 +1,18 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl_with_macros_enabled(c: BlackboxContext) = { + def impl_with_macros_enabled(c: Context) = { import c.universe._ val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) val tree1 = Apply(Select(ru, TermName("reify")), List(Literal(Constant(2)))) - val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) + val ttree1 = c.typecheck(tree1, withMacrosDisabled = false) c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_macros_enabled = macro impl_with_macros_enabled - def impl_with_macros_disabled(c: BlackboxContext) = { + def impl_with_macros_disabled(c: Context) = { import c.universe._ val rupkg = c.mirror.staticModule("scala.reflect.runtime.package") @@ -22,7 +22,7 @@ object Macros { build.setTypeSignature(ru, rutpe) val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) - val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) + val ttree2 = c.typecheck(tree2, withMacrosDisabled = true) c.Expr[String](Literal(Constant(ttree2.toString))) } diff --git a/test/files/run/macro-typecheck-macrosdisabled2.check b/test/files/run/macro-typecheck-macrosdisabled2.check index 347dfec1dc..c6e1c08d5d 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2.check +++ b/test/files/run/macro-typecheck-macrosdisabled2.check @@ -1,4 +1,4 @@ -{ +({ val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe; val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(this.getClass().getClassLoader()); $u.Expr.apply[Array[Int]]($m, { @@ -28,5 +28,5 @@ }; new $typecreator2() })) -} +}: reflect.runtime.universe.Expr[Array[Int]]) ru.reify[Array[Int]](scala.Array.apply(2)) diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala index 3d12020109..3412f5c88f 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -1,18 +1,18 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl_with_macros_enabled(c: BlackboxContext) = { + def impl_with_macros_enabled(c: Context) = { import c.universe._ val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) val tree1 = Apply(Select(ru, TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) - val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) + val ttree1 = c.typecheck(tree1, withMacrosDisabled = false) c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_macros_enabled = macro impl_with_macros_enabled - def impl_with_macros_disabled(c: BlackboxContext) = { + def impl_with_macros_disabled(c: Context) = { import c.universe._ val rupkg = c.mirror.staticModule("scala.reflect.runtime.package") @@ -22,7 +22,7 @@ object Macros { build.setTypeSignature(ru, rutpe) val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) - val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) + val ttree2 = c.typecheck(tree2, withMacrosDisabled = true) c.Expr[String](Literal(Constant(ttree2.toString))) } diff --git a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala index 1af0579abc..5df5f96aa8 100644 --- a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala @@ -1,8 +1,8 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def cons_impl[A: c.WeakTypeTag](c: BlackboxContext)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = { + def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = { import c.universe._ reify { println("A = " + c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[A]].toString))).splice) @@ -10,7 +10,7 @@ object Macros { } } - def nil_impl[B: c.WeakTypeTag](c: BlackboxContext): c.Expr[List[B]] = { + def nil_impl[B: c.WeakTypeTag](c: Context): c.Expr[List[B]] = { import c.universe._ reify { println("B = " + c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[B]].toString))).splice) diff --git a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala index f698320579..1eb257e1d9 100644 --- a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala @@ -1,8 +1,8 @@ import scala.reflect.runtime.universe._ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl[T: c.WeakTypeTag](c: BlackboxContext)(foo: c.Expr[T]): c.Expr[Unit] = { + def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = { import c.universe._ reify { println(c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[T]].toString))).splice) } } diff --git a/test/files/run/macro-vampire-false-warning/Macros_1.scala b/test/files/run/macro-vampire-false-warning/Macros_1.scala index bf75e924e8..0912bfba0c 100644 --- a/test/files/run/macro-vampire-false-warning/Macros_1.scala +++ b/test/files/run/macro-vampire-false-warning/Macros_1.scala @@ -1,20 +1,20 @@ // As per http://meta.plasm.us/posts/2013/08/31/feeding-our-vampires/ import scala.annotation.StaticAnnotation -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import scala.language.experimental.macros class body(tree: Any) extends StaticAnnotation object Macros { - def selFieldImpl(c: WhiteboxContext) = { + def selFieldImpl(c: Context) = { import c.universe._ val field = c.macroApplication.symbol val bodyAnn = field.annotations.filter(_.tpe <:< typeOf[body]).head c.Expr[Any](bodyAnn.scalaArgs.head) } - def mkObjectImpl(c: WhiteboxContext)(xs: c.Expr[Any]*) = { + def mkObjectImpl(c: Context)(xs: c.Expr[Any]*) = { import c.universe._ import Flag._ // val kvps = xs.toList map { case q"${_}(${Literal(Constant(name: String))}).->[${_}]($value)" => name -> value } diff --git a/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala b/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala index 87cd310b09..60a8d011f1 100644 --- a/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala +++ b/test/files/run/macro-whitebox-dynamic-materialization/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.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: WhiteboxContext) = { + 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/run/macro-whitebox-extractor/Macros_1.scala b/test/files/run/macro-whitebox-extractor/Macros_1.scala index 64053b8a24..d394c0241a 100644 --- a/test/files/run/macro-whitebox-extractor/Macros_1.scala +++ b/test/files/run/macro-whitebox-extractor/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import language.experimental.macros object Extractor { @@ -6,7 +6,7 @@ object Extractor { } 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/run/macro-whitebox-fundep-materialization/Macros_1.scala b/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala index 671a4fff4e..a8309e35b0 100644 --- a/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala +++ b/test/files/run/macro-whitebox-fundep-materialization/Macros_1.scala @@ -1,5 +1,5 @@ import scala.language.experimental.macros -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.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: WhiteboxContext): 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/run/macro-whitebox-fundep-materialization/Test_2.scala b/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala index a00f4ed7db..40ca1d549c 100644 --- a/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala +++ b/test/files/run/macro-whitebox-fundep-materialization/Test_2.scala @@ -1,4 +1,4 @@ -// see the comments for macroExpandApply.onDelayed for an explanation of what's tested here +// see the comments for macroExpand.onDelayed for an explanation of what's tested here object Test extends App { case class Foo(i: Int, s: String, b: Boolean) def foo[C, L](c: C)(implicit iso: Iso[C, L]): L = iso.to(c) diff --git a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala index b8d0c042be..45fdb79c30 100644 --- a/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala +++ b/test/files/run/macro-whitebox-structural/Impls_Macros_1.scala @@ -1,8 +1,8 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import scala.language.experimental.macros object Macros { - def impl(c: WhiteboxContext) = { + def impl(c: Context) = { import c.universe._ q""" trait Foo { diff --git a/test/files/run/macroPlugins-macroArgs.check b/test/files/run/macroPlugins-macroArgs.check new file mode 100644 index 0000000000..a68f8069b6 --- /dev/null +++ b/test/files/run/macroPlugins-macroArgs.check @@ -0,0 +1,2 @@ +hijacked 1 +hijacked 2 diff --git a/test/files/run/macroPlugins-macroArgs/Macros_2.scala b/test/files/run/macroPlugins-macroArgs/Macros_2.scala new file mode 100644 index 0000000000..b19b8f18dc --- /dev/null +++ b/test/files/run/macroPlugins-macroArgs/Macros_2.scala @@ -0,0 +1,11 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl(c: Context)(arg: c.Tree) = { + import c.universe._ + q"""println($arg)""" + } + + def foo(arg: String): Unit = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroArgs/Plugin_1.scala b/test/files/run/macroPlugins-macroArgs/Plugin_1.scala new file mode 100644 index 0000000000..23e80ced3b --- /dev/null +++ b/test/files/run/macroPlugins-macroArgs/Plugin_1.scala @@ -0,0 +1,21 @@ +package macroArgs + +import scala.tools.nsc.Global +import scala.tools.nsc.plugins.{Plugin => NscPlugin} + +class Plugin(val global: Global) extends NscPlugin { + import global._ + import analyzer._ + + val name = "macroArgs" + val description = "A sample analyzer plugin that overrides macroArgs." + val components = Nil + addMacroPlugin(MacroPlugin) + + object MacroPlugin extends MacroPlugin { + override def pluginsMacroArgs(typer: Typer, expandee: Tree): Option[MacroArgs] = { + val MacroArgs(c, List(Literal(Constant(s: String)))) = standardMacroArgs(typer, expandee) + Some(MacroArgs(c, List(Literal(Constant("hijacked " + s))))) + } + } +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroArgs/Test_3.flags b/test/files/run/macroPlugins-macroArgs/Test_3.flags new file mode 100644 index 0000000000..966df731d0 --- /dev/null +++ b/test/files/run/macroPlugins-macroArgs/Test_3.flags @@ -0,0 +1 @@ +-Xplugin:.
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroArgs/Test_3.scala b/test/files/run/macroPlugins-macroArgs/Test_3.scala new file mode 100644 index 0000000000..a54d608178 --- /dev/null +++ b/test/files/run/macroPlugins-macroArgs/Test_3.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo("1") + Macros.foo("2") +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroArgs/scalac-plugin.xml b/test/files/run/macroPlugins-macroArgs/scalac-plugin.xml new file mode 100644 index 0000000000..0849f0f4ea --- /dev/null +++ b/test/files/run/macroPlugins-macroArgs/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> + <name>macro-args</name> + <classname>macroArgs.Plugin</classname> +</plugin>
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroExpand.check b/test/files/run/macroPlugins-macroExpand.check new file mode 100644 index 0000000000..6f685c2af4 --- /dev/null +++ b/test/files/run/macroPlugins-macroExpand.check @@ -0,0 +1,2 @@ +expanded into println("impl1") +expanded into println("impl2") diff --git a/test/files/run/macroPlugins-macroExpand/Macros_2.scala b/test/files/run/macroPlugins-macroExpand/Macros_2.scala new file mode 100644 index 0000000000..c9c88ad2fd --- /dev/null +++ b/test/files/run/macroPlugins-macroExpand/Macros_2.scala @@ -0,0 +1,18 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl1(c: Context) = { + import c.universe._ + q"""println("impl1")""" + } + + def impl2(c: Context) = { + import c.universe._ + q"""println("impl2")""" + } + + def foo1: Unit = macro impl1 + + def foo2: Unit = macro impl2 +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroExpand/Plugin_1.scala b/test/files/run/macroPlugins-macroExpand/Plugin_1.scala new file mode 100644 index 0000000000..13df85cb23 --- /dev/null +++ b/test/files/run/macroPlugins-macroExpand/Plugin_1.scala @@ -0,0 +1,27 @@ +package macroExpand + +import scala.tools.nsc.Global +import scala.tools.nsc.plugins.{Plugin => NscPlugin} + +class Plugin(val global: Global) extends NscPlugin { + import global._ + import analyzer._ + import scala.reflect.internal.Mode + + val name = "macroExpand" + val description = "A sample analyzer plugin that overrides macroExpand." + val components = Nil + addMacroPlugin(MacroPlugin) + + object MacroPlugin extends MacroPlugin { + override def pluginsMacroExpand(typer: Typer, expandee: Tree, mode: Mode, pt: Type): Option[Tree] = { + object expander extends DefMacroExpander(typer, expandee, mode, pt) { + override def onSuccess(expanded: Tree) = { + val message = s"expanded into ${expanded.toString}" + typer.typed(q"println($message)") + } + } + Some(expander(expandee)) + } + } +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroExpand/Test_3.flags b/test/files/run/macroPlugins-macroExpand/Test_3.flags new file mode 100644 index 0000000000..966df731d0 --- /dev/null +++ b/test/files/run/macroPlugins-macroExpand/Test_3.flags @@ -0,0 +1 @@ +-Xplugin:.
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroExpand/Test_3.scala b/test/files/run/macroPlugins-macroExpand/Test_3.scala new file mode 100644 index 0000000000..def9b5608a --- /dev/null +++ b/test/files/run/macroPlugins-macroExpand/Test_3.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo1 + Macros.foo2 +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroExpand/scalac-plugin.xml b/test/files/run/macroPlugins-macroExpand/scalac-plugin.xml new file mode 100644 index 0000000000..860150865c --- /dev/null +++ b/test/files/run/macroPlugins-macroExpand/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> + <name>macro-expand</name> + <classname>macroExpand.Plugin</classname> +</plugin>
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroRuntime.check b/test/files/run/macroPlugins-macroRuntime.check new file mode 100644 index 0000000000..af16d1ac36 --- /dev/null +++ b/test/files/run/macroPlugins-macroRuntime.check @@ -0,0 +1,2 @@ +hijacked +hijacked diff --git a/test/files/run/macroPlugins-macroRuntime/Macros_2.scala b/test/files/run/macroPlugins-macroRuntime/Macros_2.scala new file mode 100644 index 0000000000..b19b8f18dc --- /dev/null +++ b/test/files/run/macroPlugins-macroRuntime/Macros_2.scala @@ -0,0 +1,11 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl(c: Context)(arg: c.Tree) = { + import c.universe._ + q"""println($arg)""" + } + + def foo(arg: String): Unit = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroRuntime/Plugin_1.scala b/test/files/run/macroPlugins-macroRuntime/Plugin_1.scala new file mode 100644 index 0000000000..a55adadb48 --- /dev/null +++ b/test/files/run/macroPlugins-macroRuntime/Plugin_1.scala @@ -0,0 +1,20 @@ +package macroRuntime + +import scala.tools.nsc.Global +import scala.tools.nsc.plugins.{Plugin => NscPlugin} + +class Plugin(val global: Global) extends NscPlugin { + import global._ + import analyzer._ + + val name = "macroRuntime" + val description = "A sample analyzer plugin that overrides macroRuntime." + val components = Nil + addMacroPlugin(MacroPlugin) + + object MacroPlugin extends MacroPlugin { + override def pluginsMacroRuntime(expandee: Tree): Option[MacroRuntime] = Some({ + case MacroArgs(_, List(msg)) => q"""println("hijacked")""" + }) + } +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroRuntime/Test_3.flags b/test/files/run/macroPlugins-macroRuntime/Test_3.flags new file mode 100644 index 0000000000..966df731d0 --- /dev/null +++ b/test/files/run/macroPlugins-macroRuntime/Test_3.flags @@ -0,0 +1 @@ +-Xplugin:.
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroRuntime/Test_3.scala b/test/files/run/macroPlugins-macroRuntime/Test_3.scala new file mode 100644 index 0000000000..a54d608178 --- /dev/null +++ b/test/files/run/macroPlugins-macroRuntime/Test_3.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo("1") + Macros.foo("2") +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-macroRuntime/scalac-plugin.xml b/test/files/run/macroPlugins-macroRuntime/scalac-plugin.xml new file mode 100644 index 0000000000..8001af1054 --- /dev/null +++ b/test/files/run/macroPlugins-macroRuntime/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> + <name>macro-runtime</name> + <classname>macroRuntime.Plugin</classname> +</plugin>
\ No newline at end of file diff --git a/test/files/run/macroPlugins-namerHooks.check b/test/files/run/macroPlugins-namerHooks.check new file mode 100644 index 0000000000..c2db5935d4 --- /dev/null +++ b/test/files/run/macroPlugins-namerHooks.check @@ -0,0 +1,45 @@ +enterSym(package <empty> { case class C extends scala.Product with scala.Serializable { <caseaccessor> <paramaccessor> val x: Int = _; <caseaccessor> <paramaccessor> val y: Int = _; def <init>(x: Int, y: Int) = { super.<init>(); () } } }) +enterSym(case class C extends scala.Product with scala.Serializable { <caseaccessor> <paramaccessor> val x: Int = _; <caseaccessor> <paramaccessor> val y: Int = _; def <init>(x: Int, y: Int) = { super.<init>(); () } }) +ensureCompanionObject(case class C extends scala.Product with scala.Serializable { <caseaccessor> <paramaccessor> val x: Int = _; <caseaccessor> <paramaccessor> val y: Int = _; def <init>(x: Int, y: Int) = { super.<init>(); () } }, ...) +enterSym(<synthetic> object C extends runtime.this.AbstractFunction2[Int, Int, C] { def <init>() = { super.<init>(); () }; final override <synthetic> def toString() = "C" }) +enterStat(case class C extends scala.Product with scala.Serializable { <caseaccessor> <paramaccessor> val x: Int = _; <caseaccessor> <paramaccessor> val y: Int = _; def <init>(x: Int, y: Int) = { super.<init>(); () } }) +enterSym(<caseaccessor> <paramaccessor> val x: Int = _) +enterSym(<caseaccessor> <paramaccessor> val y: Int = _) +enterSym(def <init>(x: Int, y: Int) = { super.<init>(); () }) +enterSym(<synthetic> def copy(x = x, y = y) = new C(x, y)) +enterStat(<caseaccessor> <paramaccessor> private[this] val x: Int = _) +enterStat(<caseaccessor> <paramaccessor> private[this] val y: Int = _) +enterStat(def <init>(x: Int, y: Int) = { super.<init>(); () }) +enterSym(<caseaccessor> <paramaccessor> private[this] val x: Int = _) +enterSym(<caseaccessor> <paramaccessor> private[this] val y: Int = _) +enterSym(def <init>(x: Int, y: Int) = { super.<init>(); () }) +enterSym(super.<init>()) +enterStat(super.<init>()) +enterSym(<synthetic> def copy$default$1 = x) +enterSym(<synthetic> def copy$default$2 = y) +enterSym(<synthetic> var acc: Int = -889275714) +enterSym(acc = Statics.this.mix(acc, x)) +enterSym(acc = Statics.this.mix(acc, y)) +enterStat(<synthetic> var acc: Int = -889275714) +enterStat(acc = Statics.this.mix(acc, x)) +enterStat(acc = Statics.this.mix(acc, y)) +enterSym(<synthetic> val C$1: C = x$1.asInstanceOf[C]) +enterStat(<synthetic> val C$1: C = x$1.asInstanceOf[C]) +enterSym(def <init>() = { super.<init>(); () }) +enterSym(final override <synthetic> def toString() = "C") +enterSym(case <synthetic> def apply(x: Int, y: Int): C = new C(x, y)) +enterSym(case <synthetic> def unapply(x$0: C) = if (x$0.==(null)) scala.this.None else Some(scala.Tuple2(x$0.x, x$0.y))) +enterStat(def <init>() = { super.<init>(); () }) +enterStat(final override <synthetic> def toString() = "C") +enterSym(def <init>() = { super.<init>(); () }) +enterSym(final override <synthetic> def toString() = "C") +enterSym(super.<init>()) +enterStat(super.<init>()) +enterSym(case <synthetic> val x1: Int = x$1) +enterStat(case <synthetic> val x1: Int = x$1) +enterSym(case <synthetic> val x1: Any = x$1) +enterSym(case5(){ if (x1.isInstanceOf[C]) matchEnd4(true) else case6() }) +enterSym(case6(){ matchEnd4(false) }) +enterStat(case <synthetic> val x1: Any = x$1) +enterStat(case5(){ if (x1.isInstanceOf[C]) matchEnd4(true) else case6() }) +enterStat(case6(){ matchEnd4(false) }) diff --git a/test/files/run/macroPlugins-namerHooks.scala b/test/files/run/macroPlugins-namerHooks.scala new file mode 100644 index 0000000000..302429b19e --- /dev/null +++ b/test/files/run/macroPlugins-namerHooks.scala @@ -0,0 +1,39 @@ +import scala.tools.partest._ +import scala.tools.nsc._ + +object Test extends DirectTest { + override def extraSettings: String = "-usejavacp" + + def code = """ + case class C(x: Int, y: Int) + """.trim + + def show() { + val global = newCompiler() + import global._ + import analyzer._ + + val output = collection.mutable.ListBuffer[String]() + def log(what: String) = output += what.replace(String.format("%n"), " ") + + object macroPlugin extends MacroPlugin { + override def pluginsEnterSym(namer: Namer, tree: Tree): Boolean = { + log(s"enterSym($tree)") + namer.standardEnterSym(tree) + true + } + override def pluginsEnsureCompanionObject(namer: Namer, cdef: ClassDef, creator: ClassDef => Tree = companionModuleDef(_)): Option[Symbol] = { + log(s"ensureCompanionObject($cdef, ...)") + Some(namer.standardEnsureCompanionObject(cdef, creator)) + } + override def pluginsEnterStats(typer: Typer, stats: List[Tree]): List[Tree] = { + stats.foreach(stat => log(s"enterStat($stat)")) + stats + } + } + + addMacroPlugin(macroPlugin) + compileString(global)(code) + println(output.mkString("\n")) + } +} diff --git a/test/files/run/macroPlugins-typedMacroBody.check b/test/files/run/macroPlugins-typedMacroBody.check new file mode 100644 index 0000000000..b6f8436189 --- /dev/null +++ b/test/files/run/macroPlugins-typedMacroBody.check @@ -0,0 +1,2 @@ +impl1 +impl2 diff --git a/test/files/run/macroPlugins-typedMacroBody/Macros_2.flags b/test/files/run/macroPlugins-typedMacroBody/Macros_2.flags new file mode 100644 index 0000000000..966df731d0 --- /dev/null +++ b/test/files/run/macroPlugins-typedMacroBody/Macros_2.flags @@ -0,0 +1 @@ +-Xplugin:.
\ No newline at end of file diff --git a/test/files/run/macroPlugins-typedMacroBody/Macros_2.scala b/test/files/run/macroPlugins-typedMacroBody/Macros_2.scala new file mode 100644 index 0000000000..80acfec659 --- /dev/null +++ b/test/files/run/macroPlugins-typedMacroBody/Macros_2.scala @@ -0,0 +1,18 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl1(c: Context) = { + import c.universe._ + q"""println("impl1")""" + } + + def impl2(c: Context) = { + import c.universe._ + q"""println("impl2")""" + } + + def foo1: Unit = macro 1 + + def foo2: Unit = macro 2 +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-typedMacroBody/Plugin_1.scala b/test/files/run/macroPlugins-typedMacroBody/Plugin_1.scala new file mode 100644 index 0000000000..e99cf7f75d --- /dev/null +++ b/test/files/run/macroPlugins-typedMacroBody/Plugin_1.scala @@ -0,0 +1,21 @@ +package typedMacroBody + +import scala.tools.nsc.Global +import scala.tools.nsc.plugins.{Plugin => NscPlugin} + +class Plugin(val global: Global) extends NscPlugin { + import global._ + import analyzer._ + + val name = "typedMacroBody" + val description = "A sample analyzer plugin that overrides typedMacroBody." + val components = Nil + addMacroPlugin(MacroPlugin) + + object MacroPlugin extends MacroPlugin { + override def pluginsTypedMacroBody(typer: Typer, ddef: DefDef): Option[Tree] = { + val DefDef(_, _, _, _, _, Literal(Constant(num: Int))) = ddef + Some(standardTypedMacroBody(typer, copyDefDef(ddef)(rhs = Ident(TermName("impl" + num))))) + } + } +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-typedMacroBody/Test_3.scala b/test/files/run/macroPlugins-typedMacroBody/Test_3.scala new file mode 100644 index 0000000000..def9b5608a --- /dev/null +++ b/test/files/run/macroPlugins-typedMacroBody/Test_3.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo1 + Macros.foo2 +}
\ No newline at end of file diff --git a/test/files/run/macroPlugins-typedMacroBody/scalac-plugin.xml b/test/files/run/macroPlugins-typedMacroBody/scalac-plugin.xml new file mode 100644 index 0000000000..e223fa5dca --- /dev/null +++ b/test/files/run/macroPlugins-typedMacroBody/scalac-plugin.xml @@ -0,0 +1,4 @@ +<plugin> + <name>typed-macro-body</name> + <classname>typedMacroBody.Plugin</classname> +</plugin>
\ No newline at end of file diff --git a/test/files/run/mutable-anyrefmap.scala b/test/files/run/mutable-anyrefmap.scala deleted file mode 100644 index ff615d0daf..0000000000 --- a/test/files/run/mutable-anyrefmap.scala +++ /dev/null @@ -1,91 +0,0 @@ -object Test extends App { - - import scala.collection.mutable.HashMap; - import scala.collection.mutable.AnyRefMap; - - val keys = Array( - null, "perch", "herring", "salmon", "pike", "cod", "" - ) - - val rn = new scala.util.Random(42L) - var arm = AnyRefMap.empty[String, Int] - val hm = HashMap.empty[String, Int] - - def checkConsistent = hm.forall{ case (k,v) => arm.get(k).exists(_ == v) } - - assert { - (0 to 10000).forall{ i => - val k = keys(rn.nextInt(keys.length)) - if (rn.nextInt(100) < 2) arm = arm.clone() - if (rn.nextInt(100) < 5) arm.repack() - if (rn.nextBoolean) { - hm += ((k, i)) - rn.nextInt(6) match { - case 0 => arm += ((k, i)) - case 1 => arm += (k, i) - case 2 => arm(k) = i - case 3 => arm.put(k,i) - case 4 => arm ++= List((k,i)) - case _ => if (!arm.contains(k)) arm.getOrElseUpdate(k,i) - else arm += (k,i) - } - } - else { - hm -= k - rn.nextInt(2) match { - case 0 => arm -= k - case _ => arm --= List(k) - } - } - checkConsistent - } - } - - assert { - val mapped = - arm.map{ case (k,v) => (if (k==null) "" else k+k) -> v.toString } - mapped.getClass == arm.getClass - } - - assert { - val arm2 = new AnyRefMap[java.lang.Integer,Unit](2000000) - for (i <- 0 until 1000000) arm2(java.lang.Integer.valueOf(i)) = () - - arm2.size == 1000000 && - (0 to 1100000 by 100000).map(java.lang.Integer.valueOf).forall(i => (arm2 contains i) == i < 1000000) - } - - arm = AnyRefMap("heron" -> 22, "dove" -> 5, "budgie" -> 0) - - assert{ - var s = "" - arm.foreachKey(s += _) - - s.length == "herondovebudgie".length && - s.contains("heron") && - s.contains("dove") && - s.contains("budgie") - } - - assert{ var s = 0L; arm.foreachValue(s += _); s == 27L } - - assert { - val m2 = arm.mapValuesNow(_+2) - arm.transformValues(_+2) - m2 == arm && !(m2 eq arm) && (for ((_,v) <- arm) yield v).sum == 33L - } - - assert { - val arm2 = new AnyRefMap[String, String](x => if (x==null) "null" else x) - arm2 += ("cod" -> "fish", "Rarity" -> "unicorn") - val hm2 = (new HashMap[String,String]) ++= arm2 - - List(null, "cod", "sparrow", "Rarity").forall(i => - arm2.get(i) == hm2.get(i) && - arm2.getOrElse(i, "") == hm2.getOrElse(i, "") && - arm2(i) == hm2.get(i).getOrElse(if (i==null) "null" else i.toString) && - arm2.getOrNull(i) == hm2.get(i).orNull - ) - } -} - diff --git a/test/files/run/mutable-longmap.scala b/test/files/run/mutable-longmap.scala deleted file mode 100644 index 07fd80f6f0..0000000000 --- a/test/files/run/mutable-longmap.scala +++ /dev/null @@ -1,79 +0,0 @@ -object Test extends App { - - import scala.collection.mutable.HashMap; - import scala.collection.mutable.LongMap; - - val keys = Array( - Long.MinValue, Int.MinValue - 1L, Int.MinValue, -9127, -1, - 0, 1, 9127, Int.MaxValue, Long.MaxValue - ) - - val rn = new scala.util.Random(42L) - var lm = LongMap.empty[Long] - val hm = HashMap.empty[Long,Long] - - def checkConsistent = hm.forall{ case (k,v) => lm.get(k).exists(_ == v) } - - assert { - (0 to 10000).forall{ i => - val k = keys(rn.nextInt(keys.length)) - if (rn.nextInt(100) < 2) lm = lm.clone() - if (rn.nextInt(100) < 5) lm.repack() - if (rn.nextBoolean) { - hm += ((k, i)) - rn.nextInt(6) match { - case 0 => lm += ((k, i)) - case 1 => lm += (k, i) - case 2 => lm(k) = i - case 3 => lm.put(k,i) - case 4 => lm ++= List((k,i)) - case _ => if (!lm.contains(k)) lm.getOrElseUpdate(k,i) - else lm += (k,i) - } - } - else { - hm -= k - rn.nextInt(2) match { - case 0 => lm -= k - case _ => lm --= List(k) - } - } - checkConsistent - } - } - - assert { - lm.map{ case (k,v) => -k*k -> v.toString }.getClass == lm.getClass - } - - assert { - val lm2 = new LongMap[Unit](2000000) - for (i <- 0 until 1000000) lm2(i) = () - - lm2.size == 1000000 && - (0 to 1100000 by 100000).forall(i => (lm2 contains i) == i < 1000000) - } - - lm = LongMap(8L -> 22L, -5L -> 5L, Long.MinValue -> 0L) - - assert{ var s = 0L; lm.foreachKey(s += _); s == Long.MinValue + 3 } - assert{ var s = 0L; lm.foreachValue(s += _); s == 27L } - assert { - val m2 = lm.mapValuesNow(_+2) - lm.transformValues(_+2) - m2 == lm && !(m2 eq lm) && (for ((_,v) <- lm) yield v).sum == 33L - } - - assert { - val lm2 = new LongMap[String](_.toString) - lm2 += (5L -> "fish", 0L -> "unicorn") - val hm2 = (new HashMap[Long,String]) ++= lm2 - - List(Long.MinValue, 0L, 1L, 5L).forall(i => - lm2.get(i) == hm2.get(i) && - lm2.getOrElse(i, "") == hm2.getOrElse(i, "") && - lm2(i) == hm2.get(i).getOrElse(i.toString) && - lm2.getOrNull(i) == hm2.get(i).orNull - ) - } -} diff --git a/test/files/run/name-based-patmat.check b/test/files/run/name-based-patmat.check index 1cc605ea3d..3d5fc40ed7 100644 --- a/test/files/run/name-based-patmat.check +++ b/test/files/run/name-based-patmat.check @@ -1,3 +1,5 @@ +`catdog only` has 11 chars +`catdog only, no product` has 23 chars catdog 2 catdogs! A ha ha! 3 catdogs! A ha ha! diff --git a/test/files/run/name-based-patmat.scala b/test/files/run/name-based-patmat.scala index 2c429c141f..8e20940100 100644 --- a/test/files/run/name-based-patmat.scala +++ b/test/files/run/name-based-patmat.scala @@ -1,5 +1,33 @@ final class MiniSome[T](val get: T) extends AnyVal { def isEmpty = false } +package p0 { + class Single(val x: Any) extends AnyRef with Product1[String] { + private def s = "" + x + override def canEqual(x: Any) = this eq x.asInstanceOf[AnyRef] + def isEmpty = false + def get = this + def _1 = s + " only" + + override def toString = s"Single(${_1})" + } + + object Single { + def unapply(x: Any): Single = new Single(x) + } + + class SingleNoProduct(val x: Any) extends AnyRef { + private def s = "" + x + def isEmpty = false + def get = s + " only, no product" + + override def toString = s"SingleNoProduct($get)" + } + + object SingleNoProduct { + def unapply(x: Any): SingleNoProduct = new SingleNoProduct(x) + } +} + package p1 { class Triple(val x: Any) extends AnyRef with Product3[String, String, String] { private def s = "" + x @@ -49,14 +77,16 @@ package p3 { } object Test { - - // def f(x: Any) = x match { - // case p1.Foo(x, y, z) => println((x, y, z)) - // case x => println(x) - // } - def main(args: Array[String]): Unit = { "catdog" match { + case p0.Single(x) => println(s"`${x._1}` has ${x._1.length} chars") + case x => println("fail: " + x) + } + "catdog" match { + case p0.SingleNoProduct(x) => println(s"`$x` has ${x.length} chars") + case x => println("fail: " + x) + } + "catdog" match { case p1.Triple(x, y, z) => List(x, y, z) foreach println case x => println("fail: " + x) } diff --git a/test/files/run/patmat-mix-case-extractor.check b/test/files/run/patmat-mix-case-extractor.check new file mode 100644 index 0000000000..a6e1bd23df --- /dev/null +++ b/test/files/run/patmat-mix-case-extractor.check @@ -0,0 +1,8 @@ +-1 +6 +4 +18 +-1 +1006 +1004 +1018 diff --git a/test/files/run/patmat-mix-case-extractor.scala b/test/files/run/patmat-mix-case-extractor.scala new file mode 100644 index 0000000000..964e6f743c --- /dev/null +++ b/test/files/run/patmat-mix-case-extractor.scala @@ -0,0 +1,110 @@ +trait CaseClass +trait ProdCaseClass extends CaseClass { def x: Int } +trait SeqCaseClass extends CaseClass { def xs: Seq[Int] } + +case class CaseClass1() extends CaseClass +case class CaseClass2(xs: Int*) extends SeqCaseClass +case class CaseClass3(x: Int) extends ProdCaseClass +case class CaseClass4(x: Int, xs: Int*) extends ProdCaseClass with SeqCaseClass + +object Extractor1 { def unapply(x: CaseClass): Boolean = false } +object Extractor2 { def unapplySeq(x: SeqCaseClass): Option[Seq[Int]] = Some(x.xs) } +object Extractor3 { def unapply(x: ProdCaseClass): Option[Int] = Some(x.x) } +object Extractor4 { def unapplySeq(x: ProdCaseClass with SeqCaseClass): Option[(Int, Seq[Int])] = Some(x.x, x.xs) } + +class A { + def f1(x: Any) = x match { + case CaseClass1() => -1 + case CaseClass2(xs @ _*) => xs.sum + case CaseClass3(x) => x + case CaseClass4(x, xs @ _*) => x + xs.sum + case Extractor4(x, xs @ _*) => 1000 + x + xs.sum + case Extractor3(x) => 1000 + x + case Extractor2(xs @ _*) => 1000 + xs.sum + case Extractor1() => -3 + case _ => -2 + } + def f2(x: Any) = x match { + case Extractor4(x, xs @ _*) => 1000 + x + xs.sum + case Extractor3(x) => 1000 + x + case Extractor2(xs @ _*) => 1000 + xs.sum + case Extractor1() => -3 + case CaseClass1() => -1 + case CaseClass2(xs @ _*) => xs.sum + case CaseClass3(x) => x + case CaseClass4(x, xs @ _*) => x + xs.sum + case _ => -2 + } + def run() { + List( + f1(CaseClass1()), + f1(CaseClass2(1, 2, 3)), + f1(CaseClass3(4)), + f1(CaseClass4(5, 6, 7)), + f2(CaseClass1()), + f2(CaseClass2(1, 2, 3)), + f2(CaseClass3(4)), + f2(CaseClass4(5, 6, 7)) + ) foreach println + } +} + +object Test { + def main(args: Array[String]): Unit = { + (new A).run + } +} + + +class B { + case class CaseClass0() + case class CaseClass0v(xs: Int*) + + case class CaseClass(x: Int, y: Int) + object Extractor { def unapply(x: Any): Option[(Int, Int)] = Some((1, 1)) } + + case class CaseSeq(x: Char, y: Double, zs: Int*) + object ExtractorSeq { def unapplySeq(x: Any): Option[(Int, Int, Seq[Int])] = Some((1, 1, List(1))) } + + def f1(x: CaseClass) = x match { case CaseClass(y, z) => y } + def f2(x: Any) = x match { case Extractor(y, z) => y } + + def f3(x: CaseSeq) = x match { + case CaseSeq(x, y) => y + case CaseSeq(x, y, z) => z + } + def f4(x: CaseSeq) = x match { + case CaseSeq(x, y, z) => z :: Nil + case CaseSeq(x, y, z @ _*) => z + } + + def f5(x: Any) = x match { case ExtractorSeq(x, y, z) => z } + def f6(x: Any) = x match { case ExtractorSeq(x, y, z @ _*) => z } + + def g1(x: CaseClass0) = x match { + case CaseClass0() => true + } + def g2(x: CaseClass0v) = x match { + case CaseClass0v() => true + case CaseClass0v(5) => true + case CaseClass0v(x) => true + case CaseClass0v(xs @ _*) => false + } +} + +package p1 { + trait _X { + case class _Foo(); + object _Bar { + def unapply(foo: _Foo): Boolean = true; + } + } + + object Y extends _X { + val foo = _Foo() + foo match { + case _Bar() => + case _ => assert(false) + } + } +} diff --git a/test/files/run/reflection-mem-typecheck.scala b/test/files/run/reflection-mem-typecheck.scala index a312c2c893..e3cabf689d 100644 --- a/test/files/run/reflection-mem-typecheck.scala +++ b/test/files/run/reflection-mem-typecheck.scala @@ -21,6 +21,6 @@ object Test extends MemoryTest { foo(List(new A {}, new B {})) """.trim snippet = snippet + "\n" + (List.fill(50)(snippet.split("\n").last) mkString "\n") - tb.typeCheck(tb.parse(snippet)) + tb.typecheck(tb.parse(snippet)) } }
\ No newline at end of file diff --git a/test/files/run/reflection-sync-potpourri.scala b/test/files/run/reflection-sync-potpourri.scala deleted file mode 100644 index 0ad5f2ab66..0000000000 --- a/test/files/run/reflection-sync-potpourri.scala +++ /dev/null @@ -1,32 +0,0 @@ -import scala.reflect.runtime.universe._ - -// this test checks that under heavily multithreaded conditions: -// 1) scala.reflect.runtime.universe, its rootMirror and definitions are initialized correctly -// 2) symbols are correctly materialized into PackageScopes (no dupes) -// 3) unpickling works okay even we unpickle the same symbol a lot of times - -object Test extends App { - def foo[T: TypeTag](x: T) = typeOf[T].toString - val n = 1000 - val rng = new scala.util.Random() - val types = List( - () => typeOf[java.lang.reflect.Method], - () => typeOf[java.lang.annotation.Annotation], - () => typeOf[scala.io.BufferedSource], - () => typeOf[scala.io.Codec]) - val perms = types.permutations.toList - def force(lazytpe: () => Type): String = { - lazytpe().typeSymbol.typeSignature - lazytpe().toString - } - val diceRolls = List.fill(n)(rng.nextInt(perms.length)) - val threads = (1 to n) map (i => new Thread(s"Reflector-$i") { - override def run(): Unit = { - val s1 = foo("42") - val s2 = perms(diceRolls(i - 1)).map(x => force(x)).sorted.mkString(", ") - assert(s1 == "java.lang.String") - assert(s2 == "java.lang.annotation.Annotation, java.lang.reflect.Method, scala.io.BufferedSource, scala.io.Codec") - } - }) - threads foreach (_.start) -}
\ No newline at end of file diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala index c23048e463..e3ff9e532d 100644 --- a/test/files/run/reify_ann1a.scala +++ b/test/files/run/reify_ann1a.scala @@ -20,7 +20,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala index 29ce6021a2..30bafadf75 100644 --- a/test/files/run/reify_ann1b.scala +++ b/test/files/run/reify_ann1b.scala @@ -20,7 +20,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala index 53423e12c3..515fba015f 100644 --- a/test/files/run/reify_ann2a.scala +++ b/test/files/run/reify_ann2a.scala @@ -20,7 +20,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann3.scala b/test/files/run/reify_ann3.scala index 4162fa532f..7098e928a7 100644 --- a/test/files/run/reify_ann3.scala +++ b/test/files/run/reify_ann3.scala @@ -14,7 +14,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann4.scala b/test/files/run/reify_ann4.scala index 0aedb77b5e..f6426213df 100644 --- a/test/files/run/reify_ann4.scala +++ b/test/files/run/reify_ann4.scala @@ -18,7 +18,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_ann5.scala b/test/files/run/reify_ann5.scala index d27be3b6d5..5e2f058a39 100644 --- a/test/files/run/reify_ann5.scala +++ b/test/files/run/reify_ann5.scala @@ -15,7 +15,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_classfileann_a.scala b/test/files/run/reify_classfileann_a.scala index 1d51688e78..9ae12bff82 100644 --- a/test/files/run/reify_classfileann_a.scala +++ b/test/files/run/reify_classfileann_a.scala @@ -14,7 +14,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_classfileann_b.scala b/test/files/run/reify_classfileann_b.scala index ef19e9240b..a0cb8f0b49 100644 --- a/test/files/run/reify_classfileann_b.scala +++ b/test/files/run/reify_classfileann_b.scala @@ -18,7 +18,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/reify_renamed_term_si5841.check b/test/files/run/reify_renamed_term_t5841.check index 6031277b76..6031277b76 100644 --- a/test/files/run/reify_renamed_term_si5841.check +++ b/test/files/run/reify_renamed_term_t5841.check diff --git a/test/files/run/reify_renamed_term_si5841.scala b/test/files/run/reify_renamed_term_t5841.scala index ef18d650bf..ef18d650bf 100644 --- a/test/files/run/reify_renamed_term_si5841.scala +++ b/test/files/run/reify_renamed_term_t5841.scala diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check index f73abb5dc3..3580bfe1f1 100644 --- a/test/files/run/repl-term-macros.check +++ b/test/files/run/repl-term-macros.check @@ -1,16 +1,16 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> import scala.reflect.macros.BlackboxContext -import scala.reflect.macros.BlackboxContext +scala> import scala.reflect.macros.blackbox.Context +import scala.reflect.macros.blackbox.Context scala> import language.experimental.macros import language.experimental.macros scala> -scala> def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } -impl1: (c: scala.reflect.macros.BlackboxContext)c.Expr[Unit] +scala> def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } +impl1: (c: scala.reflect.macros.blackbox.Context)c.Expr[Unit] scala> def foo1: Unit = macro impl1 defined term macro foo1: Unit @@ -19,8 +19,8 @@ scala> foo1 scala> -scala> def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") } -impl2: (c: scala.reflect.macros.BlackboxContext)()c.Expr[Unit] +scala> def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") } +impl2: (c: scala.reflect.macros.blackbox.Context)()c.Expr[Unit] scala> def foo2(): Unit = macro impl2 defined term macro foo2: ()Unit @@ -29,8 +29,8 @@ scala> foo2() scala> -scala> def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } -impl3: (c: scala.reflect.macros.BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit] +scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } +impl3: (c: scala.reflect.macros.blackbox.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit] scala> def foo3(x: Int)(y: Int): Unit = macro impl3 defined term macro foo3: (x: Int)(y: Int)Unit diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala index b4660e258e..32892b7314 100644 --- a/test/files/run/repl-term-macros.scala +++ b/test/files/run/repl-term-macros.scala @@ -2,18 +2,18 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ - import scala.reflect.macros.BlackboxContext + import scala.reflect.macros.blackbox.Context import language.experimental.macros -def impl1(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } +def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo1: Unit = macro impl1 foo1 -def impl2(c: BlackboxContext)() = { import c.universe._; c.Expr[Unit](q"()") } +def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") } def foo2(): Unit = macro impl2 foo2() -def impl3(c: BlackboxContext)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } +def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } def foo3(x: Int)(y: Int): Unit = macro impl3 foo3(2)(3) """ diff --git a/test/files/run/resetattrs-this.scala b/test/files/run/resetattrs-this.scala index 2a55437273..6150a4e265 100644 --- a/test/files/run/resetattrs-this.scala +++ b/test/files/run/resetattrs-this.scala @@ -5,7 +5,7 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() val tree = Select(This(cm.staticPackage("scala").moduleClass), TermName("Predef")) - val ttree = tb.typeCheck(tree) + val ttree = tb.typecheck(tree) val rttree = tb.resetAllAttrs(ttree) println(tb.eval(rttree) == Predef) } diff --git a/test/files/run/showraw_aliases.scala b/test/files/run/showraw_aliases.scala index 65b4fcb1cd..56bd13707d 100644 --- a/test/files/run/showraw_aliases.scala +++ b/test/files/run/showraw_aliases.scala @@ -7,7 +7,7 @@ object Test extends App { import scala.reflect.runtime.{universe => ru} ru """) - val ttree = tb.typeCheck(tree) + val ttree = tb.typecheck(tree) def stabilizeIds(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>") def stabilizePositions(s: String) = """\d+""".r.replaceAllIn(s, "<offset>") diff --git a/test/files/run/showraw_tree_types_ids.scala b/test/files/run/showraw_tree_types_ids.scala index 198729e705..883af0110a 100644 --- a/test/files/run/showraw_tree_types_ids.scala +++ b/test/files/run/showraw_tree_types_ids.scala @@ -6,6 +6,6 @@ object Test extends App { val tree1 = reify(new collection.immutable.HashMap[String, String]) val tree2 = reify(new collection.mutable.HashMap[String, String]) def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>") - println(stabilize(showRaw(tb.typeCheck(tree1.tree), printIds = true, printTypes = true))) - println(stabilize(showRaw(tb.typeCheck(tree2.tree), printIds = true, printTypes = true))) + println(stabilize(showRaw(tb.typecheck(tree1.tree), printIds = true, printTypes = true))) + println(stabilize(showRaw(tb.typecheck(tree2.tree), printIds = true, printTypes = true))) }
\ No newline at end of file diff --git a/test/files/run/showraw_tree_types_typed.scala b/test/files/run/showraw_tree_types_typed.scala index d7ccc84ea3..3dd696c77e 100644 --- a/test/files/run/showraw_tree_types_typed.scala +++ b/test/files/run/showraw_tree_types_typed.scala @@ -5,6 +5,6 @@ object Test extends App { val tb = runtimeMirror(getClass.getClassLoader).mkToolBox() val tree1 = reify(new collection.immutable.HashMap[String, String]) val tree2 = reify(new collection.mutable.HashMap[String, String]) - println(showRaw(tb.typeCheck(tree1.tree), printTypes = true)) - println(showRaw(tb.typeCheck(tree2.tree), printTypes = true)) + println(showRaw(tb.typecheck(tree1.tree), printTypes = true)) + println(showRaw(tb.typecheck(tree2.tree), printTypes = true)) }
\ No newline at end of file diff --git a/test/files/run/showraw_tree_ultimate.scala b/test/files/run/showraw_tree_ultimate.scala index a8507623bc..e0d36e6bb7 100644 --- a/test/files/run/showraw_tree_ultimate.scala +++ b/test/files/run/showraw_tree_ultimate.scala @@ -6,6 +6,6 @@ object Test extends App { val tree1 = reify(new collection.immutable.HashMap[String, String]) val tree2 = reify(new collection.mutable.HashMap[String, String]) def stabilize(s: String) = """#\d+""".r.replaceAllIn(s, "#<id>") - println(stabilize(showRaw(tb.typeCheck(tree1.tree), printIds = true, printKinds = true, printTypes = true))) - println(stabilize(showRaw(tb.typeCheck(tree2.tree), printIds = true, printKinds = true, printTypes = true))) + println(stabilize(showRaw(tb.typecheck(tree1.tree), printIds = true, printKinds = true, printTypes = true))) + println(stabilize(showRaw(tb.typecheck(tree2.tree), printIds = true, printKinds = true, printTypes = true))) }
\ No newline at end of file diff --git a/test/files/run/t4287inferredMethodTypes.check b/test/files/run/t4287inferredMethodTypes.check new file mode 100644 index 0000000000..56e9c097cc --- /dev/null +++ b/test/files/run/t4287inferredMethodTypes.check @@ -0,0 +1,30 @@ +[[syntax trees at end of typer]] // newSource1.scala +[0:92]package [0:0]<empty> { + [0:21]class A extends [7:21][23]scala.AnyRef { + [8:16]<paramaccessor> private[this] val a: [8]Int = _; + <8:20>def <init>(<8:20>a: [11]<type: [11]scala.Int> = [17:20]A.a): [7]A = <8:20>{ + <8:20><8:20><8:20>A.super.<init>(); + <8:20>() + } + }; + [23:47]object A extends [32:47][49]scala.AnyRef { + [49]def <init>(): [32]A.type = [49]{ + [49][49][49]A.super.<init>(); + [32]() + }; + [36:45]private[this] val a: [40]Int = [44:45]2; + [40]<stable> <accessor> def a: [40]Int = [40][40]A.this.a; + [8]<synthetic> def <init>$default$1: [8]Int = [19]A.a + }; + [49:92]class B extends [57:92][65:66]A { + [65]def <init>(): [57]B = [65]{ + [65][65][65]B.super.<init>([65]A.<init>$default$1); + [57]() + }; + [70:90]def <init>([79:80]a: [79]Int): [74]B = [84:90]{ + [84:90][84:90][84]B.this.<init>(); + [84]() + } + } +} + diff --git a/test/files/run/t4287inferredMethodTypes.scala b/test/files/run/t4287inferredMethodTypes.scala new file mode 100644 index 0000000000..f14e672da8 --- /dev/null +++ b/test/files/run/t4287inferredMethodTypes.scala @@ -0,0 +1,25 @@ +import scala.tools.partest.DirectTest + +object Test extends DirectTest { + + override def extraSettings: String = + s"-usejavacp -Yinfer-argument-types -Xprint-pos -Xprint:typer -Yrangepos -Ystop-after:typer -d ${testOutput.path}" + + override def code = """ +class A(a: Int = A.a) + +object A { + val a = 2 +} + +class B extends A { + def this(a) = this() +} + """.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +}
\ No newline at end of file diff --git a/test/files/run/si4750.check b/test/files/run/t4750.check index bf55f70df3..bf55f70df3 100644 --- a/test/files/run/si4750.check +++ b/test/files/run/t4750.check diff --git a/test/files/run/si4750.scala b/test/files/run/t4750.scala index 96d2c4fec7..96d2c4fec7 100644 --- a/test/files/run/si4750.scala +++ b/test/files/run/t4750.scala diff --git a/test/files/run/si5045.check b/test/files/run/t5045.check index 7e9c1961b7..7e9c1961b7 100644 --- a/test/files/run/si5045.check +++ b/test/files/run/t5045.check diff --git a/test/files/run/si5045.scala b/test/files/run/t5045.scala index b0c3a4ddc4..b0c3a4ddc4 100644 --- a/test/files/run/si5045.scala +++ b/test/files/run/t5045.scala diff --git a/test/files/run/t5415.scala b/test/files/run/t5415.scala index c12e209bb7..65de86245b 100644 --- a/test/files/run/t5415.scala +++ b/test/files/run/t5415.scala @@ -8,5 +8,5 @@ object Test extends App{ import scala.reflect.runtime.{currentMirror => cm} import scala.tools.reflect.ToolBox val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(code.tree) + val ttree = toolbox.typecheck(code.tree) } diff --git a/test/files/run/t5418b.scala b/test/files/run/t5418b.scala index 08e8bb163b..c6172613d5 100644 --- a/test/files/run/t5418b.scala +++ b/test/files/run/t5418b.scala @@ -5,7 +5,7 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() val untyped = reify(new Object().getClass).tree - val typed = tb.typeCheck(untyped) + val typed = tb.typecheck(untyped) println(typed) println(showRaw(typed.tpe)) }
\ No newline at end of file diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check index 188f39ff82..760a92567c 100644 --- a/test/files/run/t5603.check +++ b/test/files/run/t5603.check @@ -10,10 +10,10 @@ [87:209]class C extends [94:209][151:159]Greeting { [119:139]val nameElse = _; [95:101]<paramaccessor> private[this] val i: [98:101]Int = _; - <119:139>def <init>([95]i: [98]Int) = <119:139>{ + <95:139>def <init>(<95:101>i: [98]Int) = <95:139>{ <119:139>val nameElse = <134:139>"Bob"; [NoPosition][NoPosition][NoPosition]super.<init>(); - [94]() + <95:139>() }; [168:184]val name = [179:184]"avc"; [191:203][191:198]println([199:202]msg) diff --git a/test/files/run/t5704.scala b/test/files/run/t5704.scala index ddcbcc27b3..495a82e4f0 100644 --- a/test/files/run/t5704.scala +++ b/test/files/run/t5704.scala @@ -8,7 +8,7 @@ object Test extends App { def findUserByName( name:String ) = { val tree = reify{ "test" == name }.tree val toolbox = cm.mkToolBox() - toolbox.typeCheck(tree) match{ + toolbox.typecheck(tree) match{ case Apply(Select(lhs,op),rhs::Nil) => println(rhs.tpe) } diff --git a/test/files/run/t5713/Impls_Macros_1.scala b/test/files/run/t5713/Impls_Macros_1.scala index bfe2fc4efd..7b04197cfa 100644 --- a/test/files/run/t5713/Impls_Macros_1.scala +++ b/test/files/run/t5713/Impls_Macros_1.scala @@ -1,7 +1,7 @@ package m import language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Level extends Enumeration { val Error = Value(5) @@ -13,7 +13,7 @@ object Logger { private object LoggerMacros { - type LoggerContext = BlackboxContext { type PrefixType = Logger.type } + type LoggerContext = Context { type PrefixType = Logger.type } def error(c: LoggerContext)(message: c.Expr[String]): c.Expr[Unit] = log(c)(c.universe.reify(Level.Error), message) diff --git a/test/files/run/t5753_1/Impls_Macros_1.scala b/test/files/run/t5753_1/Impls_Macros_1.scala index 3ddff56c38..ce07138852 100644 --- a/test/files/run/t5753_1/Impls_Macros_1.scala +++ b/test/files/run/t5753_1/Impls_Macros_1.scala @@ -1,8 +1,8 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros trait Impls { - def impl(c: BlackboxContext)(x: c.Expr[Any]) = x + def impl(c: Context)(x: c.Expr[Any]) = x } object Macros extends Impls { diff --git a/test/files/run/t5753_2/Impls_Macros_1.scala b/test/files/run/t5753_2/Impls_Macros_1.scala index c95c9a41b3..d446d37bdf 100644 --- a/test/files/run/t5753_2/Impls_Macros_1.scala +++ b/test/files/run/t5753_2/Impls_Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.{BlackboxContext => Ctx} +import scala.reflect.macros.blackbox.Context trait Macro_T { - def foo[T](c: Ctx)(s: c.Expr[T]) = s + def foo[T](c: Context)(s: c.Expr[T]) = s } object Macros { diff --git a/test/files/run/t5816.scala b/test/files/run/t5816.scala index f0279e5703..e8367ea81e 100644 --- a/test/files/run/t5816.scala +++ b/test/files/run/t5816.scala @@ -6,7 +6,7 @@ object Test extends App { val toolbox = cm.mkToolBox() def printSource[T](expr: Expr[T]) { - val ttree = toolbox typeCheck expr.tree + val ttree = toolbox typecheck expr.tree println(ttree.toString) } diff --git a/test/files/run/t5894.scala b/test/files/run/t5894.scala index 5d482333f5..6e118fd396 100644 --- a/test/files/run/t5894.scala +++ b/test/files/run/t5894.scala @@ -1,10 +1,11 @@ -import language.experimental.macros +import scala.reflect.macros.blackbox.Context +import scala.language.experimental.macros class Test object Test { def foo: Unit = macro fooImpl - def fooImpl(c: reflect.macros.BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } + def fooImpl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def main(args: Array[String]) { try { diff --git a/test/files/run/t5903a/Macros_1.scala b/test/files/run/t5903a/Macros_1.scala index ce1b035260..5d084ceed5 100644 --- a/test/files/run/t5903a/Macros_1.scala +++ b/test/files/run/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/run/t5903b/Macros_1.scala b/test/files/run/t5903b/Macros_1.scala index 97f15cec3b..29a05f7fec 100644 --- a/test/files/run/t5903b/Macros_1.scala +++ b/test/files/run/t5903b/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[T: c.WeakTypeTag](c: WhiteboxContext)(x: c.Tree) = { + def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { import c.universe._ q""" new { diff --git a/test/files/run/t5903c/Macros_1.scala b/test/files/run/t5903c/Macros_1.scala index 979284a263..34fe1d8808 100644 --- a/test/files/run/t5903c/Macros_1.scala +++ b/test/files/run/t5903c/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[T: c.WeakTypeTag](c: WhiteboxContext)(x: c.Tree) = { + def unapplyImpl[T: c.WeakTypeTag](c: Context)(x: c.Tree) = { import c.universe._ q""" new { diff --git a/test/files/run/t5903d/Macros_1.scala b/test/files/run/t5903d/Macros_1.scala index dc1989462b..f1f8dc1fde 100644 --- a/test/files/run/t5903d/Macros_1.scala +++ b/test/files/run/t5903d/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/run/t5912.scala b/test/files/run/t5912.scala index 9418e946d0..fc879a0537 100644 --- a/test/files/run/t5912.scala +++ b/test/files/run/t5912.scala @@ -3,5 +3,5 @@ object Test extends App{ import scala.reflect.runtime.{currentMirror=>cm} import scala.tools.reflect._ import scala.reflect.runtime.universe._ - val tree = cm.mkToolBox().typeCheck( Literal(Constant("test")) ) + val tree = cm.mkToolBox().typecheck( Literal(Constant("test")) ) } diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala index 445392ff95..9aa7a02708 100644 --- a/test/files/run/t5923a/Macros_1.scala +++ b/test/files/run/t5923a/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import language.experimental.macros case class C[T](t: String) @@ -7,7 +7,7 @@ object C { } object Macros { - def impl[T](c: WhiteboxContext)(ttag: c.WeakTypeTag[T]) = { + def impl[T](c: Context)(ttag: c.WeakTypeTag[T]) = { import c.universe._ val ttag0 = ttag; { diff --git a/test/files/run/t5923d/Macros_1.scala b/test/files/run/t5923d/Macros_1.scala index b6e7134b95..1400674d4b 100644 --- a/test/files/run/t5923d/Macros_1.scala +++ b/test/files/run/t5923d/Macros_1.scala @@ -1,9 +1,9 @@ import scala.language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context trait MappedRow trait RowMapper[T <: MappedRow] object RowMapper { implicit def mapper[T <: MappedRow]: RowMapper[T] = macro impl[T] - def impl[T <: MappedRow : c.WeakTypeTag](c: BlackboxContext) = c.universe.reify(new RowMapper[T]{}) + def impl[T <: MappedRow : c.WeakTypeTag](c: Context) = c.universe.reify(new RowMapper[T]{}) }
\ No newline at end of file diff --git a/test/files/run/t5940.scala b/test/files/run/t5940.scala index 062f11c467..7b025b43af 100644 --- a/test/files/run/t5940.scala +++ b/test/files/run/t5940.scala @@ -4,15 +4,15 @@ object Test extends DirectTest { def code = ??? def macros_1 = """ - 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"()") } } object Macros { //import Impls._ - def impl(c: BlackboxContext) = { import c.universe._; c.Expr[Unit](q"()") } + def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo: Unit = macro impl } """ diff --git a/test/files/run/t5943a1.scala b/test/files/run/t5943a1.scala index 00f4afa808..6bb828de85 100644 --- a/test/files/run/t5943a1.scala +++ b/test/files/run/t5943a1.scala @@ -5,5 +5,5 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() val expr = tb.parse("1 to 3 map (_+1)") - println(tb.typeCheck(expr)) + println(tb.typecheck(expr)) }
\ No newline at end of file diff --git a/test/files/run/t6023.scala b/test/files/run/t6023.scala index 07af3685a5..2753b93ac4 100644 --- a/test/files/run/t6023.scala +++ b/test/files/run/t6023.scala @@ -9,7 +9,7 @@ object Test extends App { // test 2: import and typecheck val toolbox = cm.mkToolBox() - val ttree = toolbox.typeCheck(tree) + val ttree = toolbox.typecheck(tree) println(ttree.toString) // test 3: import and compile diff --git a/test/files/run/t6187.check b/test/files/run/t6187.check index c833b45443..97ee68271a 100644 --- a/test/files/run/t6187.check +++ b/test/files/run/t6187.check @@ -1,15 +1,15 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> import language.experimental.macros, reflect.macros.BlackboxContext -import language.experimental.macros -import reflect.macros.BlackboxContext +scala> import scala.language.experimental.macros, scala.reflect.macros.blackbox.Context +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context -scala> def macroImpl[T: c.WeakTypeTag](c: BlackboxContext)(t: c.Expr[T]): c.Expr[List[T]] = { +scala> def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = { val r = c.universe.reify { List(t.splice) } c.Expr[List[T]]( c.resetLocalAttrs(r.tree) ) } -macroImpl: [T](c: scala.reflect.macros.BlackboxContext)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]] +macroImpl: [T](c: scala.reflect.macros.blackbox.Context)(t: c.Expr[T])(implicit evidence$1: c.WeakTypeTag[T])c.Expr[List[T]] scala> def demo[T](t: T): List[T] = macro macroImpl[T] defined term macro demo: [T](t: T)List[T] diff --git a/test/files/run/t6187.scala b/test/files/run/t6187.scala index fc6fa6e9a7..7d84419b8a 100644 --- a/test/files/run/t6187.scala +++ b/test/files/run/t6187.scala @@ -2,8 +2,8 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { override def code = """ -import language.experimental.macros, reflect.macros.BlackboxContext -def macroImpl[T: c.WeakTypeTag](c: BlackboxContext)(t: c.Expr[T]): c.Expr[List[T]] = { +import scala.language.experimental.macros, scala.reflect.macros.blackbox.Context +def macroImpl[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[List[T]] = { val r = c.universe.reify { List(t.splice) } c.Expr[List[T]]( c.resetLocalAttrs(r.tree) ) } diff --git a/test/files/run/t6221/Macros_1.scala b/test/files/run/t6221/Macros_1.scala index 60ed0aa3e3..b5c28360fa 100644 --- a/test/files/run/t6221/Macros_1.scala +++ b/test/files/run/t6221/Macros_1.scala @@ -1,6 +1,6 @@ import language.experimental.macros import language.implicitConversions -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import scala.reflect.runtime.universe.Tree class ReflectiveClosure[A, B](val tree: Tree, fn: A => B) extends (A => B) { @@ -12,7 +12,7 @@ object ReflectiveClosure { } object Macros { - def reflectiveClosureImpl[A, B](c: BlackboxContext)(f: c.Expr[A => B]): c.Expr[ReflectiveClosure[A, B]] = { + def reflectiveClosureImpl[A, B](c: Context)(f: c.Expr[A => B]): c.Expr[ReflectiveClosure[A, B]] = { import c.universe._ val u = treeBuild.mkRuntimeUniverseRef val m = EmptyTree diff --git a/test/files/run/t6355.check b/test/files/run/t6355.check new file mode 100644 index 0000000000..ce74ab38a2 --- /dev/null +++ b/test/files/run/t6355.check @@ -0,0 +1,2 @@ +bippy(x: Int) called with x = 42 +bippy(x: String) called with x = "42" diff --git a/test/files/run/t6355.scala b/test/files/run/t6355.scala new file mode 100644 index 0000000000..f1921391a3 --- /dev/null +++ b/test/files/run/t6355.scala @@ -0,0 +1,17 @@ +import scala.language.dynamics + +class A extends Dynamic { + def applyDynamic(method: String): B = new B(method) +} +class B(method: String) { + def apply(x: Int) = s"$method(x: Int) called with x = $x" + def apply(x: String) = s"""$method(x: String) called with x = "$x"""" +} + +object Test { + def main(args: Array[String]): Unit = { + val x = new A + println(x.bippy(42)) + println(x.bippy("42")) + } +} diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check index ef08d0da09..4ed11d59ff 100644 --- a/test/files/run/t6381.check +++ b/test/files/run/t6381.check @@ -1,14 +1,14 @@ Type in expressions to have them evaluated. Type :help for more information. -scala> import language.experimental.macros -import language.experimental.macros +scala> import scala.language.experimental.macros +import scala.language.experimental.macros -scala> def pos_impl(c: reflect.macros.BlackboxContext): c.Expr[String] = { +scala> def pos_impl(c: scala.reflect.macros.blackbox.Context): c.Expr[String] = { import c.universe._ c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString))) } -pos_impl: (c: scala.reflect.macros.BlackboxContext)c.Expr[String] +pos_impl: (c: scala.reflect.macros.blackbox.Context)c.Expr[String] scala> def pos: String = macro pos_impl defined term macro pos: String diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala index c78dc13ed7..5a687c10c1 100644 --- a/test/files/run/t6381.scala +++ b/test/files/run/t6381.scala @@ -2,8 +2,8 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ - |import language.experimental.macros - |def pos_impl(c: reflect.macros.BlackboxContext): c.Expr[String] = { + |import scala.language.experimental.macros + |def pos_impl(c: scala.reflect.macros.blackbox.Context): c.Expr[String] = { | import c.universe._ | c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString))) |} diff --git a/test/files/run/t6392b.scala b/test/files/run/t6392b.scala index f69a5aaf45..e43c1a2b03 100644 --- a/test/files/run/t6392b.scala +++ b/test/files/run/t6392b.scala @@ -5,5 +5,5 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() val c = tb.parse("object C") - println(showRaw(tb.typeCheck(c), printKinds = true)) + println(showRaw(tb.typecheck(c), printKinds = true)) }
\ No newline at end of file diff --git a/test/files/run/t6394a/Macros_1.scala b/test/files/run/t6394a/Macros_1.scala index b934b5ebb1..376d85ba67 100644 --- a/test/files/run/t6394a/Macros_1.scala +++ b/test/files/run/t6394a/Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c:BlackboxContext): c.Expr[Any] = { + def impl(c:Context): c.Expr[Any] = { import c.universe._ val selfTree = This(c.enclosingImpl.symbol.asModule.moduleClass) diff --git a/test/files/run/t6394b/Macros_1.scala b/test/files/run/t6394b/Macros_1.scala index 01fbc4f09e..53215e63aa 100644 --- a/test/files/run/t6394b/Macros_1.scala +++ b/test/files/run/t6394b/Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c:BlackboxContext): c.Expr[Any] = { + def impl(c:Context): c.Expr[Any] = { import c.universe._ val selfTree = This(tpnme.EMPTY) diff --git a/test/files/run/t6662/Macro_1.scala b/test/files/run/t6662/Macro_1.scala index cecf242f66..419859772d 100644 --- a/test/files/run/t6662/Macro_1.scala +++ b/test/files/run/t6662/Macro_1.scala @@ -1,8 +1,8 @@ import language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Demo { def id[T](a: T): T = macro idImpl[T] - def idImpl[T: c.WeakTypeTag](c: BlackboxContext)(a: c.Expr[T]): c.Expr[T] = a + def idImpl[T: c.WeakTypeTag](c: Context)(a: c.Expr[T]): c.Expr[T] = a } diff --git a/test/files/run/t6992/Macros_1.scala b/test/files/run/t6992/Macros_1.scala index 25566dddbf..d101efdda3 100644 --- a/test/files/run/t6992/Macros_1.scala +++ b/test/files/run/t6992/Macros_1.scala @@ -1,5 +1,5 @@ import scala.language.experimental.macros -import scala.reflect.macros.Context +import scala.reflect.macros.whitebox.Context object Macros { def foo(name: String): Any = macro foo_impl diff --git a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala index 0ce5daf0d0..7049ed6490 100644 --- a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala +++ b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala @@ -1,8 +1,8 @@ import language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ val decls = c.typeOf[ScalaClassWithCheckedExceptions_1[_]].declarations.toList val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) diff --git a/test/files/run/t7008/Impls_Macros_2.scala b/test/files/run/t7008/Impls_Macros_2.scala index 6da9dca913..9dfa66a20a 100644 --- a/test/files/run/t7008/Impls_Macros_2.scala +++ b/test/files/run/t7008/Impls_Macros_2.scala @@ -1,8 +1,8 @@ import language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ val decls = c.typeOf[JavaClassWithCheckedExceptions_1[_]].declarations.toList val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) diff --git a/test/files/run/t7047/Impls_Macros_1.scala b/test/files/run/t7047/Impls_Macros_1.scala index 0d64729791..787ea6cfe8 100644 --- a/test/files/run/t7047/Impls_Macros_1.scala +++ b/test/files/run/t7047/Impls_Macros_1.scala @@ -1,10 +1,10 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros class Foo object Macros { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ try { c.inferImplicitValue(typeOf[Foo], silent = false) diff --git a/test/files/run/t7157/Impls_Macros_1.scala b/test/files/run/t7157/Impls_Macros_1.scala index e48fbcaed3..cc258b016a 100644 --- a/test/files/run/t7157/Impls_Macros_1.scala +++ b/test/files/run/t7157/Impls_Macros_1.scala @@ -1,9 +1,9 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros object Macros { object AImpl { - def a(ctx: BlackboxContext)(args: ctx.Expr[Any]*): ctx.Expr[Unit] = { + def a(ctx: Context)(args: ctx.Expr[Any]*): ctx.Expr[Unit] = { import ctx.universe._ ctx.Expr[Unit](Apply(Ident(TermName("println")), List(Literal(Constant(1))))) } diff --git a/test/files/run/t7185.check b/test/files/run/t7185.check index 38449b3497..ebf85b731f 100644 --- a/test/files/run/t7185.check +++ b/test/files/run/t7185.check @@ -21,7 +21,7 @@ tree: reflect.runtime.universe.Apply = } }() -scala> {val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typeCheck(tree): Any} +scala> {val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typecheck(tree): Any} res0: Any = { { diff --git a/test/files/run/t7185.scala b/test/files/run/t7185.scala index d9d913e78a..62d64246bc 100644 --- a/test/files/run/t7185.scala +++ b/test/files/run/t7185.scala @@ -7,6 +7,6 @@ import scala.reflect.runtime.universe._ object O { def apply() = 0 } val ORef = reify { O }.tree val tree = Apply(Block(Nil, Block(Nil, ORef)), Nil) -{val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typeCheck(tree): Any} +{val tb = reflect.runtime.currentMirror.mkToolBox(); tb.typecheck(tree): Any} """ } diff --git a/test/files/run/t7240/Macros_1.scala b/test/files/run/t7240/Macros_1.scala index 84ad231043..019ddf7cd6 100644 --- a/test/files/run/t7240/Macros_1.scala +++ b/test/files/run/t7240/Macros_1.scala @@ -1,7 +1,7 @@ package bakery import scala.language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context trait FailureCake { implicit def liftAnyFails[T: Manifest]: Any = ??? @@ -13,7 +13,7 @@ trait FailureCake { object Bakery { def failure: Any = macro failureImpl - def failureImpl(c: BlackboxContext): c.Expr[Any] = { + def failureImpl(c: Context): c.Expr[Any] = { import c.universe._ def dslTrait(dslName: String) = { diff --git a/test/files/run/t7375b/Macros_1.scala b/test/files/run/t7375b/Macros_1.scala index bcd8e52172..b6090e730b 100644 --- a/test/files/run/t7375b/Macros_1.scala +++ b/test/files/run/t7375b/Macros_1.scala @@ -1,5 +1,5 @@ import language.experimental.macros -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context class C1(val n: Int) extends AnyVal class C2(val n: Int) extends AnyRef @@ -9,7 +9,7 @@ object Macros { type F2 = C2 def foo = macro impl - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ def test[T: c.TypeTag] = reify(println(c.Expr[String](Literal(Constant(c.reifyRuntimeClass(c.typeOf[T]).toString))).splice)).tree def tests = Block(List(test[C1], test[C2], test[F1], test[F2]), Literal(Constant(()))) diff --git a/test/files/run/t7406.check b/test/files/run/t7406.check new file mode 100644 index 0000000000..f599e28b8a --- /dev/null +++ b/test/files/run/t7406.check @@ -0,0 +1 @@ +10 diff --git a/test/files/run/t7406.scala b/test/files/run/t7406.scala new file mode 100644 index 0000000000..a8b35c91c9 --- /dev/null +++ b/test/files/run/t7406.scala @@ -0,0 +1,14 @@ +class Arne[@specialized(Long) T](x: T) { + val regularVal = x + lazy val lazyVal = x + + def apply(f: (T, T) => T): T = f(regularVal, lazyVal) +} + +object Test { + val arne = new Arne(5L) + def f = arne(_ + _) + def main(args: Array[String]): Unit = { + println(f) + } +} diff --git a/test/files/run/t7617a/Macros_1.scala b/test/files/run/t7617a/Macros_1.scala index d19f112bf4..77b18c20e2 100644 --- a/test/files/run/t7617a/Macros_1.scala +++ b/test/files/run/t7617a/Macros_1.scala @@ -1,12 +1,12 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros object Macros { - def getValueImpl[T](c: BlackboxContext): c.Expr[T] = { + def getValueImpl[T](c: Context): c.Expr[T] = { import c.universe._ c.Expr[T](Apply(Select(c.prefix.tree, newTermName("getVal")), Nil)) } - def setValueImpl[T](c: BlackboxContext)(value: c.Expr[T]): c.Expr[Unit] = { + def setValueImpl[T](c: Context)(value: c.Expr[T]): c.Expr[Unit] = { import c.universe._ c.Expr[Unit](Apply(Select(c.prefix.tree, newTermName("setVal")), List(value.tree))) } diff --git a/test/files/run/t7617b/Macros_1.scala b/test/files/run/t7617b/Macros_1.scala index b1406f30bb..90fcfda47d 100644 --- a/test/files/run/t7617b/Macros_1.scala +++ b/test/files/run/t7617b/Macros_1.scala @@ -1,7 +1,7 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context object Macros { - def impl(c: BlackboxContext)(name: c.Expr[String])(value: c.Expr[Any]) = { + def impl(c: Context)(name: c.Expr[String])(value: c.Expr[Any]) = { import c.universe._ reify(println(s"${name.splice} = ${value.splice}")) } diff --git a/test/files/run/t7657/Macros_1.scala b/test/files/run/t7657/Macros_1.scala index 9aac02031d..a883f76bc3 100644 --- a/test/files/run/t7657/Macros_1.scala +++ b/test/files/run/t7657/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 } abstract class A extends T { override 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(()) } class C extends A { override def t(): Unit = macro Macro.t } diff --git a/test/files/run/t7777.check b/test/files/run/t7777.check new file mode 100644 index 0000000000..162ff2d2a2 --- /dev/null +++ b/test/files/run/t7777.check @@ -0,0 +1,7 @@ +foo(1, 2) +bar(4, 5) +foo(3) +bar(7) +apply(6) +apply(9) +foo(8) diff --git a/test/files/run/t7777/Macros_1.scala b/test/files/run/t7777/Macros_1.scala new file mode 100644 index 0000000000..1dc6d6740c --- /dev/null +++ b/test/files/run/t7777/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.language.experimental.macros +import scala.language.dynamics +import scala.reflect.macros.whitebox.Context + +class DynMacro extends Dynamic { + def applyDynamic(s: String)(xs: Any*): DynMacro = + macro DynMacro.applyDynamicMacro +} + +object DynMacro extends DynMacro { + def applyDynamicMacro(c: Context)(s: c.Expr[String])(xs: c.Expr[Any]*): c.Expr[DynMacro] = { + import c.universe._ + val Literal(Constant(n: String)) = s.tree + val args = xs.map(_.tree.toString).mkString("(", ", ", ")") + c.Expr(q"println(${ n + args }); ${c.prefix.tree}") + } +}
\ No newline at end of file diff --git a/test/files/run/t7777/Test_2.scala b/test/files/run/t7777/Test_2.scala new file mode 100644 index 0000000000..1fe8b63bab --- /dev/null +++ b/test/files/run/t7777/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + DynMacro.foo(1, 2) // prints "foo(1, 2)" + DynMacro.foo(3).bar(4, 5) // prints "bar(4, 5)", then "foo(3)" + DynMacro(6).bar(7) // prints "bar(7)", then "apply(6)" + DynMacro.foo(8)(9) // Fails! +}
\ No newline at end of file diff --git a/test/files/run/t7871/Macros_1.scala b/test/files/run/t7871/Macros_1.scala index 801a6af4e7..dca2508128 100644 --- a/test/files/run/t7871/Macros_1.scala +++ b/test/files/run/t7871/Macros_1.scala @@ -1,4 +1,4 @@ -import scala.reflect.macros.Context +import scala.reflect.macros.whitebox.Context import language.experimental.macros trait Tree diff --git a/test/files/run/t7880.scala b/test/files/run/t7880.scala new file mode 100644 index 0000000000..9fbc337f87 --- /dev/null +++ b/test/files/run/t7880.scala @@ -0,0 +1,7 @@ +object Test extends App { + // This should terminate in one way or another, but it shouldn't loop forever. + try { + val buffer = collection.mutable.ArrayBuffer.fill(Int.MaxValue / 2 + 1)(0) + buffer append 1 + } catch { case _: OutOfMemoryError => } +} diff --git a/test/files/run/t7974.check b/test/files/run/t7974.check new file mode 100644 index 0000000000..0be496d8d0 --- /dev/null +++ b/test/files/run/t7974.check @@ -0,0 +1,104 @@ +public class Symbols { + + // compiled from: Symbols.scala + + + + // access flags 0x12 + private final Lscala/Symbol; someSymbol3 + + // access flags 0xA + private static Lscala/Symbol; symbol$1 + + // access flags 0xA + private static Lscala/Symbol; symbol$2 + + // access flags 0xA + private static Lscala/Symbol; symbol$3 + + // access flags 0x9 + public static <clinit>()V + L0 + LINENUMBER 2 L0 + GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$; + LDC "Symbolic1" + INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol; + PUTSTATIC Symbols.symbol$1 : Lscala/Symbol; + L1 + LINENUMBER 3 L1 + GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$; + LDC "Symbolic2" + INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol; + PUTSTATIC Symbols.symbol$2 : Lscala/Symbol; + L2 + LINENUMBER 5 L2 + GETSTATIC scala/Symbol$.MODULE$ : Lscala/Symbol$; + LDC "Symbolic3" + INVOKEVIRTUAL scala/Symbol$.apply (Ljava/lang/String;)Lscala/Symbol; + PUTSTATIC Symbols.symbol$3 : Lscala/Symbol; + RETURN + MAXSTACK = 2 + MAXLOCALS = 0 + + // access flags 0x1 + public someSymbol1()Lscala/Symbol; + L0 + LINENUMBER 2 L0 + GETSTATIC Symbols.symbol$1 : Lscala/Symbol; + ARETURN + L1 + LOCALVARIABLE this LSymbols; L0 L1 0 + MAXSTACK = 1 + MAXLOCALS = 1 + + // access flags 0x1 + public someSymbol2()Lscala/Symbol; + L0 + LINENUMBER 3 L0 + GETSTATIC Symbols.symbol$2 : Lscala/Symbol; + ARETURN + L1 + LOCALVARIABLE this LSymbols; L0 L1 0 + MAXSTACK = 1 + MAXLOCALS = 1 + + // access flags 0x1 + public sameSymbol1()Lscala/Symbol; + L0 + LINENUMBER 4 L0 + GETSTATIC Symbols.symbol$1 : Lscala/Symbol; + ARETURN + L1 + LOCALVARIABLE this LSymbols; L0 L1 0 + MAXSTACK = 1 + MAXLOCALS = 1 + + // access flags 0x1 + public someSymbol3()Lscala/Symbol; + L0 + LINENUMBER 5 L0 + ALOAD 0 + GETFIELD Symbols.someSymbol3 : Lscala/Symbol; + ARETURN + L1 + LOCALVARIABLE this LSymbols; L0 L1 0 + MAXSTACK = 1 + MAXLOCALS = 1 + + // access flags 0x1 + public <init>()V + L0 + LINENUMBER 6 L0 + ALOAD 0 + INVOKESPECIAL java/lang/Object.<init> ()V + L1 + LINENUMBER 5 L1 + ALOAD 0 + GETSTATIC Symbols.symbol$3 : Lscala/Symbol; + PUTFIELD Symbols.someSymbol3 : Lscala/Symbol; + RETURN + L2 + LOCALVARIABLE this LSymbols; L0 L2 0 + MAXSTACK = 2 + MAXLOCALS = 1 +} diff --git a/test/files/run/t7974/Symbols.scala b/test/files/run/t7974/Symbols.scala new file mode 100644 index 0000000000..2363b724eb --- /dev/null +++ b/test/files/run/t7974/Symbols.scala @@ -0,0 +1,6 @@ +class Symbols { + def someSymbol1 = 'Symbolic1 + def someSymbol2 = 'Symbolic2 + def sameSymbol1 = 'Symbolic1 + val someSymbol3 = 'Symbolic3 +} diff --git a/test/files/run/t7974/Test.scala b/test/files/run/t7974/Test.scala new file mode 100644 index 0000000000..9403ea332b --- /dev/null +++ b/test/files/run/t7974/Test.scala @@ -0,0 +1,20 @@ +import java.io.PrintWriter; + +import scala.tools.partest.BytecodeTest +import scala.tools.asm.util._ +import scala.tools.nsc.util.stringFromWriter + +object Test extends BytecodeTest { + def show { + val classNode = loadClassNode("Symbols", skipDebugInfo = false) + val textifier = new Textifier + classNode.accept(new TraceClassVisitor(null, textifier, null)) + + val classString = stringFromWriter(w => textifier.print(w)) + val result = + classString.split('\n') + .dropWhile(elem => elem != "public class Symbols {") + .filterNot(elem => elem.startsWith(" @Lscala/reflect/ScalaSignature") || elem.startsWith(" ATTRIBUTE ScalaSig")) + result foreach println + } +} diff --git a/test/files/run/t8046.check b/test/files/run/t8046.check new file mode 100644 index 0000000000..905b0b35ca --- /dev/null +++ b/test/files/run/t8046.check @@ -0,0 +1,2 @@ +List(trait Op, trait Function1, class Object, class Any) +BTS(T,Three.this.Op[Int],Int => Int,Object,Any) diff --git a/test/files/run/t8046/Test.scala b/test/files/run/t8046/Test.scala new file mode 100644 index 0000000000..f6b525d1b5 --- /dev/null +++ b/test/files/run/t8046/Test.scala @@ -0,0 +1,18 @@ +import scala.tools.partest._ + +object Test extends DirectTest { + override def code = "" + override def extraSettings: String = "-usejavacp" + + override def show() { + val c = newCompiler() + new c.Run + import c._ + + val f4 = typeOf[Three].member(newTermName("f4")) + val f4ParamInfo = f4.paramss.head.head.info + println(f4ParamInfo.baseClasses) + println(f4ParamInfo.baseTypeSeq) + } +} + diff --git a/test/files/run/t8046/t8046c.scala b/test/files/run/t8046/t8046c.scala new file mode 100644 index 0000000000..0b484da530 --- /dev/null +++ b/test/files/run/t8046/t8046c.scala @@ -0,0 +1,13 @@ +import language._ + +trait One { + type Op[A] + type Alias[A] = Op[A] +} + +trait Three extends One { + trait Op[A] extends (A => A) + + def f4[T <: Alias[Int]](f: T) = 0 +} + diff --git a/test/files/run/t8047.check b/test/files/run/t8047.check new file mode 100644 index 0000000000..a6b83a4a16 --- /dev/null +++ b/test/files/run/t8047.check @@ -0,0 +1,7 @@ +doWhile$1(){ + 1; + if (true) + doWhile$1() + else + () +} diff --git a/test/files/run/t8047.scala b/test/files/run/t8047.scala new file mode 100644 index 0000000000..f5660541e8 --- /dev/null +++ b/test/files/run/t8047.scala @@ -0,0 +1,31 @@ +object Test extends App { + import scala.reflect.runtime.universe._ + // + // x's owner is outer Test scope. Previosly the quasiquote expansion + // looked like: + // + // object Test { + // build.withFreshTermName("doWhile")(n => + // LabelDef(n, List(), + // Block( + // List({ val x = 1; x }), + // If(Literal(Constant(true)), Apply(Ident(n), List()), Literal(Constant(()))))) + // } + // + // Here the proper owner is anonymous function, not the Test. Hence + // symbol corruption. In new encoding this is represented as: + // + // object Test { + // { + // val n = build.freshTermName("doWhile") + // LabelDef(n, List(), + // Block( + // List({ val x = 1; x }), + // If(Literal(Constant(true)), Apply(Ident(n), List()), Literal(Constant(())))) + // } + // } + // + // Owner stays the same and life is good again. + // + println(q"do ${ val x = 1; x } while(true)") +} diff --git a/test/files/run/t8048a/Macros_1.scala b/test/files/run/t8048a/Macros_1.scala index f48e84f1de..d13e851d90 100644 --- a/test/files/run/t8048a/Macros_1.scala +++ b/test/files/run/t8048a/Macros_1.scala @@ -1,8 +1,8 @@ -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context import scala.language.experimental.macros object Macros { - def impl(c: WhiteboxContext) = { + def impl(c: Context) = { import c.universe._ q"if (true) Some(2) else None" } diff --git a/test/files/run/t8048b/Macros_1.scala b/test/files/run/t8048b/Macros_1.scala index b113af86ea..520a6fac06 100644 --- a/test/files/run/t8048b/Macros_1.scala +++ b/test/files/run/t8048b/Macros_1.scala @@ -6,10 +6,10 @@ // * https://groups.google.com/forum/#!topic/scala-internals/eXQt-BPm4i8 import scala.language.experimental.macros -import scala.reflect.macros.WhiteboxContext +import scala.reflect.macros.whitebox.Context object Macros { - def impl1(c: WhiteboxContext) = { + def impl1(c: Context) = { import c.universe._ q""" trait Foo { def x = 2 } @@ -18,7 +18,7 @@ object Macros { } def foo1: Any = macro impl1 - def impl2(c: WhiteboxContext) = { + def impl2(c: Context) = { import c.universe._ q""" class Foo { def x = 2 } @@ -27,7 +27,7 @@ object Macros { } def foo2: Any = macro impl2 - def impl3(c: WhiteboxContext) = { + def impl3(c: Context) = { import c.universe._ q""" new { def x = 2 } diff --git a/test/files/run/t8091.check b/test/files/run/t8091.check new file mode 100644 index 0000000000..4c4e91774f --- /dev/null +++ b/test/files/run/t8091.check @@ -0,0 +1 @@ +börk börk diff --git a/test/files/run/t8091.scala b/test/files/run/t8091.scala new file mode 100644 index 0000000000..cd412d4c2a --- /dev/null +++ b/test/files/run/t8091.scala @@ -0,0 +1,4 @@ +object Test extends App { + val result = "börk börk" flatMap (ch ⇒ if (ch > 127) f"&#x${ch}%04x;" else "" + ch) + println(result) +}
\ No newline at end of file diff --git a/test/files/run/t8104.check b/test/files/run/t8104.check new file mode 100644 index 0000000000..c2593eb199 --- /dev/null +++ b/test/files/run/t8104.check @@ -0,0 +1 @@ +TypeTag[(Int, Int)] diff --git a/test/files/run/t8104/Macros_1.scala b/test/files/run/t8104/Macros_1.scala new file mode 100644 index 0000000000..2ad4bc5a99 --- /dev/null +++ b/test/files/run/t8104/Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.whitebox.Context + +object Macros { + 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 } + val Repr = appliedType(TupleClass(fields.length).asType.toType, fields.map(_.typeSignature)) + q"new Generic[$T]{ type Repr = $Repr }" + } +}
\ No newline at end of file diff --git a/test/files/run/t8104/Test_2.scala b/test/files/run/t8104/Test_2.scala new file mode 100644 index 0000000000..630176f175 --- /dev/null +++ b/test/files/run/t8104/Test_2.scala @@ -0,0 +1,16 @@ +trait Generic[T] { type Repr } +object Generic { + type Aux[T, Repr0] = Generic[T] { type Repr = Repr0 } + import scala.language.experimental.macros + implicit def materializeGeneric[T, Repr]: Generic.Aux[T, Repr] = macro Macros.impl[T] +} + +object Test extends App { + case class C(x: Int, y: Int) + + import scala.reflect.runtime.universe._ + def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: TypeTag[Repr]) = println(tag) + reprify(C(40, 2)) + + implicitly[Generic.Aux[C, (Int, Int)]] +} diff --git a/test/files/run/toolbox_current_run_compiles.scala b/test/files/run/toolbox_current_run_compiles.scala index 31e0a45eea..6ec7074643 100644 --- a/test/files/run/toolbox_current_run_compiles.scala +++ b/test/files/run/toolbox_current_run_compiles.scala @@ -1,9 +1,9 @@ package pkg { - import scala.reflect.macros.BlackboxContext + import scala.reflect.macros.blackbox.Context import scala.language.experimental.macros object Macros { - def impl[T: c.WeakTypeTag](c: BlackboxContext) = { + def impl[T: c.WeakTypeTag](c: Context) = { import c.universe._ val sym = c.weakTypeOf[T].typeSymbol val g = c.universe.asInstanceOf[scala.tools.nsc.Global] diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.scala b/test/files/run/toolbox_typecheck_implicitsdisabled.scala index 95a7056279..8c1a6e580c 100644 --- a/test/files/run/toolbox_typecheck_implicitsdisabled.scala +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.scala @@ -10,7 +10,7 @@ object Test extends App { Import(Select(Ident(TermName("scala")), TermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) ) - val ttree1 = toolbox.typeCheck(tree1, withImplicitViewsDisabled = false) + val ttree1 = toolbox.typecheck(tree1, withImplicitViewsDisabled = false) println(ttree1) try { @@ -18,7 +18,7 @@ object Test extends App { Import(Select(Ident(TermName("scala")), TermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1)))), Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) ) - val ttree2 = toolbox.typeCheck(tree2, withImplicitViewsDisabled = true) + val ttree2 = toolbox.typecheck(tree2, withImplicitViewsDisabled = true) println(ttree2) } catch { case ex: Throwable => diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check index 3de296f1ad..d9e79cdd19 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled.check @@ -1,4 +1,4 @@ -{ +({ val $u: ru.type = ru; val $m: $u.Mirror = ru.runtimeMirror({ final class $anon extends scala.AnyRef { @@ -37,5 +37,5 @@ }; new $typecreator2() })) -} +}: ru.Expr[Int]) ru.reify[Int](2) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala index 1f7fda8575..4cbeefd6e0 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -16,10 +16,10 @@ object Test extends App { build.setTypeSignature(ru, rutpe) val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) - val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) + val ttree1 = toolbox.typecheck(tree1, withMacrosDisabled = false) println(ttree1) val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) - val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) + val ttree2 = toolbox.typecheck(tree2, withMacrosDisabled = true) println(ttree2) } diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check index 9810946024..8e554a6c8f 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -1,4 +1,4 @@ -{ +({ val $u: ru.type = ru; val $m: $u.Mirror = ru.runtimeMirror({ final class $anon extends scala.AnyRef { @@ -37,5 +37,5 @@ }; new $typecreator2() })) -} +}: ru.Expr[Array[Int]]) ru.reify[Array[Int]](scala.Array.apply(2)) diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.scala b/test/files/run/toolbox_typecheck_macrosdisabled2.scala index 7bfe3ba8a4..2fbd8f7c7a 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.scala +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.scala @@ -16,10 +16,10 @@ object Test extends App { build.setTypeSignature(ru, rutpe) val tree1 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) - val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) + val ttree1 = toolbox.typecheck(tree1, withMacrosDisabled = false) println(ttree1) val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) - val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) + val ttree2 = toolbox.typecheck(tree2, withMacrosDisabled = true) println(ttree2) } diff --git a/test/files/run/typed-annotated/Macros_1.scala b/test/files/run/typed-annotated/Macros_1.scala index 42478cb988..d805d82f39 100644 --- a/test/files/run/typed-annotated/Macros_1.scala +++ b/test/files/run/typed-annotated/Macros_1.scala @@ -1,10 +1,10 @@ -import scala.reflect.macros.BlackboxContext +import scala.reflect.macros.blackbox.Context import language.experimental.macros class ann extends scala.annotation.StaticAnnotation object Macros { - def impl(c: BlackboxContext) = { + def impl(c: Context) = { import c.universe._ // val tpt = Annotated(Apply(Select(New(Ident(newTypeName("ann"))), nme.CONSTRUCTOR), List()), Ident(newTypeName("Int"))) val tpt = Annotated(Apply(Select(New(Ident(newTypeName("ann"))), nme.CONSTRUCTOR), List()), TypeTree(weakTypeOf[Int])) |