diff options
Diffstat (limited to 'tests/disabled/macro/pos')
56 files changed, 547 insertions, 0 deletions
diff --git a/tests/disabled/macro/pos/attachments-typed-another-ident/Impls_1.scala b/tests/disabled/macro/pos/attachments-typed-another-ident/Impls_1.scala new file mode 100644 index 000000000..98062a9c7 --- /dev/null +++ b/tests/disabled/macro/pos/attachments-typed-another-ident/Impls_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.macros.blackbox.Context +import language.experimental.macros + +object MyAttachment + +object Macros { + def impl(c: Context) = { + import c.universe._ + import internal._ + val ident = updateAttachment(Ident(TermName("bar")), MyAttachment) + assert(attachments(ident).get[MyAttachment.type].isDefined, attachments(ident)) + val typed = c.typecheck(ident) + assert(attachments(typed).get[MyAttachment.type].isDefined, attachments(typed)) + c.Expr[Int](typed) + } + + def foo = macro impl +} diff --git a/tests/disabled/macro/pos/attachments-typed-another-ident/Macros_Test_2.scala b/tests/disabled/macro/pos/attachments-typed-another-ident/Macros_Test_2.scala new file mode 100644 index 000000000..022639bfe --- /dev/null +++ b/tests/disabled/macro/pos/attachments-typed-another-ident/Macros_Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + def bar = 2 + Macros.foo +} + diff --git a/tests/disabled/macro/pos/attachments-typed-ident/Impls_1.scala b/tests/disabled/macro/pos/attachments-typed-ident/Impls_1.scala new file mode 100644 index 000000000..98062a9c7 --- /dev/null +++ b/tests/disabled/macro/pos/attachments-typed-ident/Impls_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.macros.blackbox.Context +import language.experimental.macros + +object MyAttachment + +object Macros { + def impl(c: Context) = { + import c.universe._ + import internal._ + val ident = updateAttachment(Ident(TermName("bar")), MyAttachment) + assert(attachments(ident).get[MyAttachment.type].isDefined, attachments(ident)) + val typed = c.typecheck(ident) + assert(attachments(typed).get[MyAttachment.type].isDefined, attachments(typed)) + c.Expr[Int](typed) + } + + def foo = macro impl +} diff --git a/tests/disabled/macro/pos/attachments-typed-ident/Macros_Test_2.scala b/tests/disabled/macro/pos/attachments-typed-ident/Macros_Test_2.scala new file mode 100644 index 000000000..45a0609de --- /dev/null +++ b/tests/disabled/macro/pos/attachments-typed-ident/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def bar = 2 + Macros.foo +} diff --git a/tests/disabled/macro/pos/liftcode_polymorphic.scala b/tests/disabled/macro/pos/liftcode_polymorphic.scala new file mode 100644 index 000000000..249f5a056 --- /dev/null +++ b/tests/disabled/macro/pos/liftcode_polymorphic.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ + +object Append extends App { + + def append[A](l1: List[A], l2: List[A]):List[A] = + l1 match { + case Nil => l2 + case x::xs => x :: append(xs, l2) + } + + println(reify(append _).tree) +} diff --git a/tests/disabled/macro/pos/macro-bundle-disambiguate-bundle.check b/tests/disabled/macro/pos/macro-bundle-disambiguate-bundle.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/disabled/macro/pos/macro-bundle-disambiguate-bundle.check diff --git a/tests/disabled/macro/pos/macro-bundle-disambiguate-bundle.scala b/tests/disabled/macro/pos/macro-bundle-disambiguate-bundle.scala new file mode 100644 index 000000000..40d965b0e --- /dev/null +++ b/tests/disabled/macro/pos/macro-bundle-disambiguate-bundle.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: Context) { + def impl = ??? +} + +object Macros { + def impl(c: Context)(x: c.Tree) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +} diff --git a/tests/disabled/macro/pos/macro-bundle-disambiguate-nonbundle.check b/tests/disabled/macro/pos/macro-bundle-disambiguate-nonbundle.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/disabled/macro/pos/macro-bundle-disambiguate-nonbundle.check diff --git a/tests/disabled/macro/pos/macro-bundle-disambiguate-nonbundle.scala b/tests/disabled/macro/pos/macro-bundle-disambiguate-nonbundle.scala new file mode 100644 index 000000000..185177607 --- /dev/null +++ b/tests/disabled/macro/pos/macro-bundle-disambiguate-nonbundle.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +class Macros(val c: Context) { + def impl(x: c.Tree) = ??? +} + +object Macros { + def impl(c: Context) = ??? +} + +object Test extends App { + def foo: Unit = macro Macros.impl +} diff --git a/tests/disabled/macro/pos/macro-implicit-invalidate-on-error.check b/tests/disabled/macro/pos/macro-implicit-invalidate-on-error.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/disabled/macro/pos/macro-implicit-invalidate-on-error.check diff --git a/tests/disabled/macro/pos/macro-implicit-invalidate-on-error.scala b/tests/disabled/macro/pos/macro-implicit-invalidate-on-error.scala new file mode 100644 index 000000000..bb83e3cc3 --- /dev/null +++ b/tests/disabled/macro/pos/macro-implicit-invalidate-on-error.scala @@ -0,0 +1,25 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +trait LegacyLiftable[T] { + def apply(universe: scala.reflect.api.Universe, value: T): universe.Tree +} + +object LegacyLiftable { + implicit def liftCaseClass[T <: Product]: LegacyLiftable[T] = macro liftCaseClassImpl[T] + + def liftCaseClassImpl[T: c.WeakTypeTag](c: Context): c.Expr[LegacyLiftable[T]] = { + import c.universe._ + val tpe = weakTypeOf[T] + if (!tpe.typeSymbol.asClass.isCaseClass) c.abort(c.enclosingPosition, "denied") + val p = List(q"Literal(Constant(1))") + c.Expr[LegacyLiftable[T]] { q""" + new LegacyLiftable[$tpe] { + def apply(universe: scala.reflect.api.Universe, value: $tpe): universe.Tree = { + import universe._ + Apply(Select(Ident(TermName("C")), TermName("apply")), List(..$p)) + } + } + """ } + } +} diff --git a/tests/disabled/macro/pos/macro-qmarkqmarkqmark.scala b/tests/disabled/macro/pos/macro-qmarkqmarkqmark.scala new file mode 100644 index 000000000..de94d69d5 --- /dev/null +++ b/tests/disabled/macro/pos/macro-qmarkqmarkqmark.scala @@ -0,0 +1,7 @@ +import language.experimental.macros + +object Macros { + def foo1 = macro ??? + def foo2(x: Int) = macro ??? + def foo3[T] = macro ??? +} diff --git a/tests/disabled/macro/pos/t5223.scala b/tests/disabled/macro/pos/t5223.scala new file mode 100644 index 000000000..bfd1e153c --- /dev/null +++ b/tests/disabled/macro/pos/t5223.scala @@ -0,0 +1,6 @@ +import scala.reflect.runtime.universe._ + +object Foo extends App { + reify{def printf(format: String, args: Any*): String = null } + reify{def printf(format: String, args: Any*): String = ("abc": @deprecated)} +} diff --git a/tests/disabled/macro/pos/t5692a/Macros_1.scala b/tests/disabled/macro/pos/t5692a/Macros_1.scala new file mode 100644 index 000000000..6e5069aff --- /dev/null +++ b/tests/disabled/macro/pos/t5692a/Macros_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl[T](c: Context) = { import c.universe._; c.Expr[Unit](q"()") } + def foo[T] = macro impl[T] +} diff --git a/tests/disabled/macro/pos/t5692a/Test_2.scala b/tests/disabled/macro/pos/t5692a/Test_2.scala new file mode 100644 index 000000000..72ecd9576 --- /dev/null +++ b/tests/disabled/macro/pos/t5692a/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def x = Macros.foo +} diff --git a/tests/disabled/macro/pos/t5692b/Macros_1.scala b/tests/disabled/macro/pos/t5692b/Macros_1.scala new file mode 100644 index 000000000..82109075f --- /dev/null +++ b/tests/disabled/macro/pos/t5692b/Macros_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.macros.blackbox.Context + +object Macros { + def impl[T, U](c: Context) = { import c.universe._; c.Expr[Unit](q"()") } + def foo[T, U] = macro impl[T, U] +} diff --git a/tests/disabled/macro/pos/t5692b/Test_2.scala b/tests/disabled/macro/pos/t5692b/Test_2.scala new file mode 100644 index 000000000..72ecd9576 --- /dev/null +++ b/tests/disabled/macro/pos/t5692b/Test_2.scala @@ -0,0 +1,3 @@ +class Test { + def x = Macros.foo +} diff --git a/tests/disabled/macro/pos/t5706.flags b/tests/disabled/macro/pos/t5706.flags new file mode 100644 index 000000000..cd66464f2 --- /dev/null +++ b/tests/disabled/macro/pos/t5706.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/tests/disabled/macro/pos/t5706.scala b/tests/disabled/macro/pos/t5706.scala new file mode 100644 index 000000000..6f0207366 --- /dev/null +++ b/tests/disabled/macro/pos/t5706.scala @@ -0,0 +1,15 @@ +import scala.reflect.macros.blackbox.{Context => BlackboxContext} +import scala.reflect.macros.whitebox.{Context => WhiteboxContext} + +class Logger { + def error1(message: String) = macro Impls.error1 + def error2(message: String) = macro Impls.error2 +} + +object Impls { + type LoggerContext1 = BlackboxContext { type PrefixType = Logger } + def error1(c: LoggerContext1)(message: c.Expr[String]): c.Expr[Unit] = ??? + + type LoggerContext2 = WhiteboxContext { type PrefixType = Logger } + def error2(c: LoggerContext2)(message: c.Expr[String]): c.Expr[Unit] = ??? +} diff --git a/tests/disabled/macro/pos/t5744/Macros_1.scala b/tests/disabled/macro/pos/t5744/Macros_1.scala new file mode 100644 index 000000000..11da37f17 --- /dev/null +++ b/tests/disabled/macro/pos/t5744/Macros_1.scala @@ -0,0 +1,22 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def foo[U: Numeric](x: U) = macro foo_impl[U] + def bar[U: Numeric : Equiv, Y <% String](x: U)(implicit s: String) = macro bar_impl[U, Y] + + def foo_impl[U](c: Context)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]]) = { + import c.universe._ + val plusOne = Apply(Select(numeric.tree, newTermName("plus")), List(x.tree, Literal(Constant(1)))) + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusOne)) + c.Expr[Unit](body) + } + + def bar_impl[U, Y](c: Context)(x: c.Expr[U])(numeric: c.Expr[Numeric[U]], equiv: c.Expr[Equiv[U]], viewAsString: c.Expr[Y => String], s: c.Expr[String]) = { + import c.universe._ + val plusOne = Apply(Select(numeric.tree, newTermName("plus")), List(x.tree, Literal(Constant(1)))) + val plusLen = Apply(Select(numeric.tree, newTermName("plus")), List(plusOne, Select(s.tree, newTermName("length")))) + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusLen)) + c.Expr[Unit](body) + } +} diff --git a/tests/disabled/macro/pos/t5744/Test_2.scala b/tests/disabled/macro/pos/t5744/Test_2.scala new file mode 100644 index 000000000..dc3de03e4 --- /dev/null +++ b/tests/disabled/macro/pos/t5744/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import Macros._ + foo(42) + implicit val s = "" + bar(43) +} diff --git a/tests/disabled/macro/pos/t6047.flags b/tests/disabled/macro/pos/t6047.flags new file mode 100644 index 000000000..cd66464f2 --- /dev/null +++ b/tests/disabled/macro/pos/t6047.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/tests/disabled/macro/pos/t6047.scala b/tests/disabled/macro/pos/t6047.scala new file mode 100644 index 000000000..e7d0c38c6 --- /dev/null +++ b/tests/disabled/macro/pos/t6047.scala @@ -0,0 +1,20 @@ +import scala.reflect.macros.blackbox.Context +import java.io.InputStream + +object Macros { + def unpack[A](input: InputStream): A = macro unpack_impl[A] + + def unpack_impl[A: c.WeakTypeTag](c: Context)(input: c.Expr[InputStream]): c.Expr[A] = { + import c.universe._ + + def unpackcode(tpe: c.Type): c.Expr[_] = { + if (tpe <:< implicitly[c.WeakTypeTag[Traversable[_]]].tpe) { + + } + ??? + } + + unpackcode(implicitly[c.WeakTypeTag[A]].tpe) + ??? + } + } diff --git a/tests/disabled/macro/pos/t6386.scala b/tests/disabled/macro/pos/t6386.scala new file mode 100644 index 000000000..4031ae267 --- /dev/null +++ b/tests/disabled/macro/pos/t6386.scala @@ -0,0 +1,5 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + reify(manifest[Some[_]]) +} diff --git a/tests/disabled/macro/pos/t6447.scala b/tests/disabled/macro/pos/t6447.scala new file mode 100644 index 000000000..6ef69d485 --- /dev/null +++ b/tests/disabled/macro/pos/t6447.scala @@ -0,0 +1,18 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +class X { type T } + +object X { + // this works + def foo(x: X): x.T = macro fooImpl + def fooImpl(c: Context)(x: c.Expr[X]): c.Expr[x.value.T] = ??? + + // this doesn't + def bar(x: X, y: X): (x.T, y.T) = macro barImpl + def barImpl(c: Context)(x: c.Expr[X], y: c.Expr[X]): c.Expr[(x.value.T, y.value.T)] = ??? + + // neither does this + def baz(x: X)(xs: List[x.T]): Unit = macro bazImpl + def bazImpl(c: Context)(x: c.Expr[X])(xs: c.Expr[List[x.value.T]]): c.Expr[Unit] = ??? +} diff --git a/tests/disabled/macro/pos/t6485a/Macros_1.scala b/tests/disabled/macro/pos/t6485a/Macros_1.scala new file mode 100644 index 000000000..cc7dc3d3e --- /dev/null +++ b/tests/disabled/macro/pos/t6485a/Macros_1.scala @@ -0,0 +1,5 @@ +import scala.reflect.macros.blackbox.Context + +object Macros { + def crash(c: Context): c.Expr[Unit] = c.universe.reify(()) +} diff --git a/tests/disabled/macro/pos/t6485a/Test_2.scala b/tests/disabled/macro/pos/t6485a/Test_2.scala new file mode 100644 index 000000000..54e260ac7 --- /dev/null +++ b/tests/disabled/macro/pos/t6485a/Test_2.scala @@ -0,0 +1,5 @@ +import scala.language.experimental.macros + +final class Ops[T](val x: T) extends AnyVal { + def f = macro Macros.crash +} diff --git a/tests/disabled/macro/pos/t6485b/Test.scala b/tests/disabled/macro/pos/t6485b/Test.scala new file mode 100644 index 000000000..46d707073 --- /dev/null +++ b/tests/disabled/macro/pos/t6485b/Test.scala @@ -0,0 +1,10 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +final class Ops[T](val x: T) extends AnyVal { + def f = macro Macros.crash +} + +object Macros { + def crash(c: Context): c.Expr[Unit] = c.universe.reify(()) +} diff --git a/tests/disabled/macro/pos/t6516.scala b/tests/disabled/macro/pos/t6516.scala new file mode 100644 index 000000000..2980d83eb --- /dev/null +++ b/tests/disabled/macro/pos/t6516.scala @@ -0,0 +1,19 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context +import scala.collection.TraversableLike + +// This one compiles +object Test { + type Alias[T, CC[_]] = Context { type PrefixType = TraversableLike[T, CC[T]] } + def f() = macro f_impl + def f_impl(c: Alias[Int, List])() = ??? +} + +// This one doesn't +object Test2 { + type Ctx = scala.reflect.macros.blackbox.Context + type Alias[T, CC[_]] = Ctx { type PrefixType = TraversableLike[T, CC[T]] } + + def f() = macro f_impl + def f_impl(c: Alias[Int, List])() = ??? +} diff --git a/tests/disabled/macro/pos/t7190.scala b/tests/disabled/macro/pos/t7190.scala new file mode 100644 index 000000000..449e5c83f --- /dev/null +++ b/tests/disabled/macro/pos/t7190.scala @@ -0,0 +1,26 @@ +import scala.language.experimental.macros +import scala.reflect.macros._ + +trait A[T] { + def min[U >: T](implicit ord: Numeric[U]): T = macro A.min[T, U] +} + +object A { + def min[T: c.WeakTypeTag, U >: T: c.WeakTypeTag](c: Context)(ord: c.Expr[Numeric[U]]): c.Expr[T] = { + c.universe.reify { + ord.splice.zero.asInstanceOf[T] + } + } +} + +class B extends A[Int] { + override def min[U >: Int](implicit ord: Numeric[U]): Int = macro B.min[U] +} + +object B { + def min[U >: Int: c.WeakTypeTag](c: Context)(ord: c.Expr[Numeric[U]]): c.Expr[Int] = { + c.universe.reify { + ord.splice.zero.asInstanceOf[Int] + } + } +} diff --git a/tests/disabled/macro/pos/t7377/Client_2.scala b/tests/disabled/macro/pos/t7377/Client_2.scala new file mode 100644 index 000000000..5728956cc --- /dev/null +++ b/tests/disabled/macro/pos/t7377/Client_2.scala @@ -0,0 +1,11 @@ +object Test { + M.noop(List(1) match { case Nil => 0; case (x::xs) => x }) + + case class Foo(a: Int) + val FooAlias: Foo.type = Foo + M.noop(Foo(0) match { case FooAlias(_) => 0 }) + + case class Bar() + val BarAlias: Bar.type = Bar + M.noop(Bar() match { case BarAlias() => 0 }) +} diff --git a/tests/disabled/macro/pos/t7377/Macro_1.scala b/tests/disabled/macro/pos/t7377/Macro_1.scala new file mode 100644 index 000000000..b38687c8b --- /dev/null +++ b/tests/disabled/macro/pos/t7377/Macro_1.scala @@ -0,0 +1,7 @@ +import language.experimental._ +import scala.reflect.macros.blackbox.Context + +object M { + def noopImpl[A](c: Context)(expr: c.Expr[A]): c.Expr[A] = c.Expr(c.typecheck(c.untypecheck(expr.tree))) + def noop[A](expr: A): A = macro noopImpl[A] +} diff --git a/tests/disabled/macro/pos/t7461/Macros_1.scala b/tests/disabled/macro/pos/t7461/Macros_1.scala new file mode 100644 index 000000000..74ebf5af9 --- /dev/null +++ b/tests/disabled/macro/pos/t7461/Macros_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.macros.blackbox.Context +import language.experimental.macros + +object Macros { + def impl(c: Context) = { + import c.universe._ + val wut = c.typecheck(Select(Literal(Constant(10)), newTermName("$minus")), silent = true) + // println(showRaw(wut, printIds = true, printTypes = true)) + c.Expr[Unit](q"()") + } + + def foo = macro impl +} diff --git a/tests/disabled/macro/pos/t7461/Test_2.scala b/tests/disabled/macro/pos/t7461/Test_2.scala new file mode 100644 index 000000000..866e3dc6f --- /dev/null +++ b/tests/disabled/macro/pos/t7461/Test_2.scala @@ -0,0 +1,3 @@ +class C { + def foo = Macros.foo +} diff --git a/tests/disabled/macro/pos/t7516/A_1.scala b/tests/disabled/macro/pos/t7516/A_1.scala new file mode 100644 index 000000000..3bd477dcd --- /dev/null +++ b/tests/disabled/macro/pos/t7516/A_1.scala @@ -0,0 +1,9 @@ +import scala.reflect._,macros._, scala.language.experimental.macros + +object A { + def impl[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.untypecheck(r.tree) ) + } + def demo[T](t: T): List[T] = macro impl[T] +} diff --git a/tests/disabled/macro/pos/t7516/B_2.scala b/tests/disabled/macro/pos/t7516/B_2.scala new file mode 100644 index 000000000..1b8531bc8 --- /dev/null +++ b/tests/disabled/macro/pos/t7516/B_2.scala @@ -0,0 +1,4 @@ +object B { + final case class CV(p: Int = 3, g: Int = 2) + A.demo { val d = 4; CV(g = d); "a" } +} diff --git a/tests/disabled/macro/pos/t7649.flags b/tests/disabled/macro/pos/t7649.flags new file mode 100644 index 000000000..fcf951d90 --- /dev/null +++ b/tests/disabled/macro/pos/t7649.flags @@ -0,0 +1 @@ +-Yrangepos
\ No newline at end of file diff --git a/tests/disabled/macro/pos/t7649.scala b/tests/disabled/macro/pos/t7649.scala new file mode 100644 index 000000000..d70dc05ea --- /dev/null +++ b/tests/disabled/macro/pos/t7649.scala @@ -0,0 +1,20 @@ +object Test { + val c: scala.reflect.macros.blackbox.Context = ??? + import c.universe._ + reify { + // The lookup of the implicit WeakTypeTag[Any] + // was triggering an unpositioned tree. + c.Expr[Any](q"0").splice + } + + import scala.reflect.ClassTag + def ct[A: ClassTag]: Expr[A] = ??? + def tt[A: TypeTag]: Expr[A] = ??? + def wtt[A: WeakTypeTag]: Expr[A] = ??? + + reify { + ct[String].splice + tt[String].splice + wtt[String].splice + } +} diff --git a/tests/disabled/macro/pos/t7776.check b/tests/disabled/macro/pos/t7776.check new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/disabled/macro/pos/t7776.check diff --git a/tests/disabled/macro/pos/t7776.scala b/tests/disabled/macro/pos/t7776.scala new file mode 100644 index 000000000..627d20dd6 --- /dev/null +++ b/tests/disabled/macro/pos/t7776.scala @@ -0,0 +1,20 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +class MacroErasure { + def app(f: Any => Any, x: Any): Any = macro MacroErasure.appMacro + def app[A](f: A => Any, x: Any): Any = macro MacroErasure.appMacroA[A] +} + +object MacroErasure { + def appMacro(c: Context)( + f: c.Expr[Any => Any], x: c.Expr[Any]): c.Expr[Any] = { + import c.universe._ + c.Expr(q"$f($x)") + } + def appMacroA[A](c: Context)(f: c.Expr[A => Any], x: c.Expr[Any])( + implicit tt: c.WeakTypeTag[A]): c.Expr[Any] = { + import c.universe._ + c.Expr(q"$f[${tt.tpe}]($x)") + } +} diff --git a/tests/disabled/macro/pos/t7987/Macro_1.scala b/tests/disabled/macro/pos/t7987/Macro_1.scala new file mode 100644 index 000000000..81f717b9c --- /dev/null +++ b/tests/disabled/macro/pos/t7987/Macro_1.scala @@ -0,0 +1,6 @@ +import scala.language.experimental._ + +object Macro { + def apply[A](a: A): A = macro impl[A] + def impl[A](c: reflect.macros.Context)(a: c.Expr[A]): c.Expr[A] = a +} diff --git a/tests/disabled/macro/pos/t7987/Test_2.scala b/tests/disabled/macro/pos/t7987/Test_2.scala new file mode 100644 index 000000000..aaa21ec4c --- /dev/null +++ b/tests/disabled/macro/pos/t7987/Test_2.scala @@ -0,0 +1,12 @@ +class C[T] { + def foo = 0 +} + +object Test { + implicit def AnyToC[T](a: Any): C[T] = new C[T] + // was: "macro not expanded" + Macro { + "".foo + () + } +} diff --git a/tests/disabled/macro/pos/t8001/Macros_1.scala b/tests/disabled/macro/pos/t8001/Macros_1.scala new file mode 100644 index 000000000..077082a9c --- /dev/null +++ b/tests/disabled/macro/pos/t8001/Macros_1.scala @@ -0,0 +1,10 @@ +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macros { + def foo: Unit = macro impl + def impl(c: Context) = { + import c.universe._ + q"()" + } +} diff --git a/tests/disabled/macro/pos/t8001/Test_2.scala b/tests/disabled/macro/pos/t8001/Test_2.scala new file mode 100644 index 000000000..55024506e --- /dev/null +++ b/tests/disabled/macro/pos/t8001/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo + (): Unit +} diff --git a/tests/disabled/macro/pos/t8013/inpervolated_2.scala b/tests/disabled/macro/pos/t8013/inpervolated_2.scala new file mode 100644 index 000000000..90e571b42 --- /dev/null +++ b/tests/disabled/macro/pos/t8013/inpervolated_2.scala @@ -0,0 +1,11 @@ +/* + * scalac: -Xfatal-warnings -Xlint + */ +package t8013 + +// unsuspecting user of perverse macro +trait User { + import Perverse.Impervolator + val foo = "bar" + Console println p"Hello, $foo" +} diff --git a/tests/disabled/macro/pos/t8013/inpervolator_1.scala b/tests/disabled/macro/pos/t8013/inpervolator_1.scala new file mode 100644 index 000000000..612e1d727 --- /dev/null +++ b/tests/disabled/macro/pos/t8013/inpervolator_1.scala @@ -0,0 +1,33 @@ + +package t8013 + +// perverse macro to confuse Xlint + +import scala.language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Perverse { + + implicit class Impervolator(sc: StringContext) { + def p(args: Any*): String = macro pImpl + } + + // turn a nice interpolation into something that looks + // nothing like an interpolation or anything we might + // recognize, but which includes a "$id" in an apply. + def pImpl(c: Context)(args: c.Expr[Any]*): c.Expr[String] = { + import c.universe._ + val macroPos = c.macroApplication.pos + val text = macroPos.source.lineToString(macroPos.line - 1) substring macroPos.column + val tt = Literal(Constant(text)) + val tree = q"t8013.Perverse.pervert($tt)" + c.Expr[String](tree) + } + + // identity doesn't seem very perverse in this context + //def pervert(text: String): String = text + def pervert(text: String): String = { + Console println s"Perverting [$text]" + text + } +} diff --git a/tests/disabled/macro/pos/t8064/Client_2.scala b/tests/disabled/macro/pos/t8064/Client_2.scala new file mode 100644 index 000000000..42c9b21ce --- /dev/null +++ b/tests/disabled/macro/pos/t8064/Client_2.scala @@ -0,0 +1,8 @@ +object Test { + Macro { + def s = "" + Macro(s): @unchecked + ??? + } +} +// Was: a range position validation error (unpositioned tree) diff --git a/tests/disabled/macro/pos/t8064/Macro_1.scala b/tests/disabled/macro/pos/t8064/Macro_1.scala new file mode 100644 index 000000000..9f1e6955b --- /dev/null +++ b/tests/disabled/macro/pos/t8064/Macro_1.scala @@ -0,0 +1,10 @@ +import language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macro { + def apply(a: Any): Any = macro impl + + def impl(c: Context)(a: c.Tree): c.Tree = { + c.untypecheck(a) + } +} diff --git a/tests/disabled/macro/pos/t8064b/Client_2.scala b/tests/disabled/macro/pos/t8064b/Client_2.scala new file mode 100644 index 000000000..055b7a606 --- /dev/null +++ b/tests/disabled/macro/pos/t8064b/Client_2.scala @@ -0,0 +1,6 @@ +object Test { + Macro { + "".reverse + } +} +// Was: a range position validation error (tree with offset position enclosing tree with range position) diff --git a/tests/disabled/macro/pos/t8064b/Macro_1.scala b/tests/disabled/macro/pos/t8064b/Macro_1.scala new file mode 100644 index 000000000..60996bfec --- /dev/null +++ b/tests/disabled/macro/pos/t8064b/Macro_1.scala @@ -0,0 +1,11 @@ +import language.experimental.macros +import scala.reflect.macros.blackbox.Context + +object Macro { + def apply(a: Any): Any = macro impl + def impl(c: Context)(a: c.Tree): c.Tree = { + import c.universe._ + + q"{$a; true}" + } +} diff --git a/tests/disabled/macro/pos/t8209a/Macros_1.scala b/tests/disabled/macro/pos/t8209a/Macros_1.scala new file mode 100644 index 000000000..5d7852cb7 --- /dev/null +++ b/tests/disabled/macro/pos/t8209a/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.language.experimental.macros +import scala.language.implicitConversions +import scala.reflect.macros.blackbox.Context + +class A +object A { implicit def a2b(a: A): B = ??? } +class B +class C extends A + +object Macros { + def impl(c: Context) = { + import c.universe._ + q"new C" + } + + def foo: A = macro impl +} diff --git a/tests/disabled/macro/pos/t8209a/Test_2.scala b/tests/disabled/macro/pos/t8209a/Test_2.scala new file mode 100644 index 000000000..bedef776f --- /dev/null +++ b/tests/disabled/macro/pos/t8209a/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val a: A = Macros.foo + val b: B = Macros.foo +} diff --git a/tests/disabled/macro/pos/t8209b/Macros_1.scala b/tests/disabled/macro/pos/t8209b/Macros_1.scala new file mode 100644 index 000000000..fa521d38d --- /dev/null +++ b/tests/disabled/macro/pos/t8209b/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.language.experimental.macros +import scala.language.implicitConversions +import scala.reflect.macros.whitebox.Context + +class A +object A { implicit def a2b(a: A): B = ??? } +class B +class C extends A + +object Macros { + def impl(c: Context) = { + import c.universe._ + q"new C" + } + + def foo: A = macro impl +} diff --git a/tests/disabled/macro/pos/t8209b/Test_2.scala b/tests/disabled/macro/pos/t8209b/Test_2.scala new file mode 100644 index 000000000..bedef776f --- /dev/null +++ b/tests/disabled/macro/pos/t8209b/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val a: A = Macros.foo + val b: B = Macros.foo +} diff --git a/tests/disabled/macro/pos/t8352/Macros_1.scala b/tests/disabled/macro/pos/t8352/Macros_1.scala new file mode 100644 index 000000000..c1c63e57b --- /dev/null +++ b/tests/disabled/macro/pos/t8352/Macros_1.scala @@ -0,0 +1,7 @@ +import scala.reflect.macros.whitebox._ +import scala.language.experimental.macros + +object Macros { + def impl(c: Context)(x: c.Expr[Boolean]): c.Expr[Boolean] = x + def foo(x: Boolean): Boolean = macro impl +} diff --git a/tests/disabled/macro/pos/t8352/Test_2.scala b/tests/disabled/macro/pos/t8352/Test_2.scala new file mode 100644 index 000000000..1f84c3ca1 --- /dev/null +++ b/tests/disabled/macro/pos/t8352/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + def expectUnit(): Unit = { + Macros.foo(true) + } +} |