diff options
Diffstat (limited to 'test/files/neg/macro-override-method-overrides-macro')
-rw-r--r-- | test/files/neg/macro-override-method-overrides-macro/Impls_1.scala | 15 | ||||
-rw-r--r-- | test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala | 14 |
2 files changed, 14 insertions, 15 deletions
diff --git a/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala b/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala index ec93dd4111..f3917e3093 100644 --- a/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala +++ b/test/files/neg/macro-override-method-overrides-macro/Impls_1.scala @@ -1,15 +1,14 @@ -import scala.reflect.macros.{Context => 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), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) - c.Expr[Unit](body) + c.Expr[Unit](q"println($tag, ${prefix.toString}, $x)") } - def fooBString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBString", x) - def fooBInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooBInt", x) - def fooDInt(c: Ctx)(x: c.Expr[_]) = impl(c)("fooDInt", x) - def fooZString(c: Ctx)(x: c.Expr[_]) = impl(c)("fooZString", x) + def fooBString(c: Context)(x: c.Expr[_]) = impl(c)("fooBString", x) + def fooBInt(c: Context)(x: c.Expr[_]) = impl(c)("fooBInt", x) + def fooDInt(c: Context)(x: c.Expr[_]) = impl(c)("fooDInt", x) + def fooZString(c: Context)(x: c.Expr[_]) = impl(c)("fooZString", x) }
\ No newline at end of file diff --git a/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala b/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala index 36821b05d8..d47157766e 100644 --- a/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala +++ b/test/files/neg/macro-override-method-overrides-macro/Macros_Test_2.scala @@ -1,15 +1,15 @@ class B { - def foo(x: String) = macro Impls.fooBString - def foo(x: Int) = macro Impls.fooBInt - def foo(x: Boolean) = println("fooBBoolean") + def foo(x: String): Unit = macro Impls.fooBString + def foo(x: Int): Unit = macro Impls.fooBInt + def foo(x: Boolean): Unit = println("fooBBoolean") } class D extends B { - override def foo(x: String) = println("fooDString") - override def foo(x: Int) = macro Impls.fooDInt + override def foo(x: String): Unit = println("fooDString") + override def foo(x: Int): Unit = macro Impls.fooDInt } class Z extends D { - override def foo(x: String) = macro Impls.fooZString - override def foo(x: Boolean) = println("fooZBoolean") + override def foo(x: String): Unit = macro Impls.fooZString + override def foo(x: Boolean): Unit = println("fooZBoolean") } |