diff options
author | Martin Odersky <odersky@gmail.com> | 2012-04-12 18:55:13 -0700 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2012-04-12 18:55:13 -0700 |
commit | 6061a22fcd3480e18e60254ad06c8a46b2f1ce53 (patch) | |
tree | 12e7d3a1798a186d641e3de21430fc6de0470727 /test/files/run | |
parent | f7a0558059559305a88ffa2c28506b29b2bc57f2 (diff) | |
parent | 39a88f5680c3a16bf7ca856683989a2f5481bf69 (diff) | |
download | scala-6061a22fcd3480e18e60254ad06c8a46b2f1ce53.tar.gz scala-6061a22fcd3480e18e60254ad06c8a46b2f1ce53.tar.bz2 scala-6061a22fcd3480e18e60254ad06c8a46b2f1ce53.zip |
Merge branch 'master' into topic/sip18
Conflicts:
src/compiler/scala/reflect/internal/Definitions.scala
Various improvements to SIP 18 reporting. Made scala library and compiler feature-clean.
Diffstat (limited to 'test/files/run')
616 files changed, 4721 insertions, 1108 deletions
diff --git a/test/files/run/classtags_contextbound.check b/test/files/run/classtags_contextbound.check new file mode 100644 index 0000000000..4104d544ba --- /dev/null +++ b/test/files/run/classtags_contextbound.check @@ -0,0 +1 @@ +class [I
diff --git a/test/files/run/classtags_contextbound.scala b/test/files/run/classtags_contextbound.scala new file mode 100644 index 0000000000..5bb0ae8d80 --- /dev/null +++ b/test/files/run/classtags_contextbound.scala @@ -0,0 +1,5 @@ +object Test extends App { + def mkArray[T: ClassTag] = Array[T]() + def foo[T: ClassTag] = mkArray[T] + println(foo[Int].getClass) +}
\ No newline at end of file diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check new file mode 100644 index 0000000000..ce5a893b08 --- /dev/null +++ b/test/files/run/classtags_core.check @@ -0,0 +1,30 @@ +true
+ClassTag(byte)
+true
+ClassTag(short)
+true
+ClassTag(char)
+true
+ClassTag(int)
+true
+ClassTag(long)
+true
+ClassTag(float)
+true
+ClassTag(double)
+true
+ClassTag(boolean)
+true
+ClassTag(void)
+true
+ClassTag(class java.lang.Object)
+true
+ClassTag(class java.lang.Object)
+true
+ClassTag(class java.lang.Object)
+true
+ClassTag(class java.lang.Object)
+true
+ClassTag(class java.lang.Object)
+true
+ClassTag(class java.lang.Object)
diff --git a/test/files/run/classtags_core.scala b/test/files/run/classtags_core.scala new file mode 100644 index 0000000000..45c54b1fe0 --- /dev/null +++ b/test/files/run/classtags_core.scala @@ -0,0 +1,32 @@ +object Test extends App { + println(implicitly[ClassTag[Byte]] eq ClassTag.Byte) + println(implicitly[ClassTag[Byte]]) + println(implicitly[ClassTag[Short]] eq ClassTag.Short) + println(implicitly[ClassTag[Short]]) + println(implicitly[ClassTag[Char]] eq ClassTag.Char) + println(implicitly[ClassTag[Char]]) + println(implicitly[ClassTag[Int]] eq ClassTag.Int) + println(implicitly[ClassTag[Int]]) + println(implicitly[ClassTag[Long]] eq ClassTag.Long) + println(implicitly[ClassTag[Long]]) + println(implicitly[ClassTag[Float]] eq ClassTag.Float) + println(implicitly[ClassTag[Float]]) + println(implicitly[ClassTag[Double]] eq ClassTag.Double) + println(implicitly[ClassTag[Double]]) + println(implicitly[ClassTag[Boolean]] eq ClassTag.Boolean) + println(implicitly[ClassTag[Boolean]]) + println(implicitly[ClassTag[Unit]] eq ClassTag.Unit) + println(implicitly[ClassTag[Unit]]) + println(implicitly[ClassTag[Any]] eq ClassTag.Any) + println(implicitly[ClassTag[Any]]) + println(implicitly[ClassTag[Object]] eq ClassTag.Object) + println(implicitly[ClassTag[Object]]) + println(implicitly[ClassTag[AnyVal]] eq ClassTag.AnyVal) + println(implicitly[ClassTag[AnyVal]]) + println(implicitly[ClassTag[AnyRef]] eq ClassTag.AnyRef) + println(implicitly[ClassTag[AnyRef]]) + println(implicitly[ClassTag[Null]] eq ClassTag.Null) + println(implicitly[ClassTag[Null]]) + println(implicitly[ClassTag[Nothing]] eq ClassTag.Nothing) + println(implicitly[ClassTag[Nothing]]) +}
\ No newline at end of file diff --git a/test/files/run/compiler-asSeenFrom.check b/test/files/run/compiler-asSeenFrom.check index f198e61072..96e257d303 100644 --- a/test/files/run/compiler-asSeenFrom.check +++ b/test/files/run/compiler-asSeenFrom.check @@ -187,69 +187,69 @@ class J { D[A1]#J[T4] Z.dZ.J[P] D[A1]#J[P] } class D { // after parser - private val cD: ll.C[List[T3]] + private[this] val cD: ll.C[List[T3]] val cD: ll.C[List[T3]] } class D { // after uncurry - private val cD: ll.C[List[T3]] + private[this] val cD: ll.C[List[T3]] val cD(): ll.C[List[T3]] } class D { // after erasure - private val cD: ll.C + private[this] val cD: ll.C val cD(): ll.C } object Z { // after parser def kz[P <: ll.Z.dZ.J[ll.A2]]: ll.Z.dZ.J[P] - private val jZ: ll.Z.dZ.J[ll.A2] + private[this] val jZ: ll.Z.dZ.J[ll.A2] val jZ: ll.Z.dZ.J[ll.A2] - private val dZ: ll.D[ll.A1] + private[this] val dZ: ll.D[ll.A1] val dZ: ll.D[ll.A1] } object Z { // after uncurry def kz[P <: ll.Z.dZ.J[ll.A2]](): ll.Z.dZ.J[P] - private val jZ: ll.Z.dZ.J[ll.A2] + private[this] val jZ: ll.Z.dZ.J[ll.A2] val jZ(): ll.Z.dZ.J[ll.A2] - private val dZ: ll.D[ll.A1] + private[this] val dZ: ll.D[ll.A1] val dZ(): ll.D[ll.A1] } object Z { // after erasure def kz(): ll.D#J - private val jZ: ll.D#J + private[this] val jZ: ll.D#J val jZ(): ll.D#J - private val dZ: ll.D + private[this] val dZ: ll.D val dZ(): ll.D } object Z { // after flatten def kz(): ll.D#D$J - private val jZ: ll.D#D$J + private[this] val jZ: ll.D#D$J val jZ(): ll.D#D$J - private val dZ: ll.D + private[this] val dZ: ll.D val dZ(): ll.D } value dZ { // after parser - private val cD: ll.C[List[T3]] + private[this] val cD: ll.C[List[T3]] val cD: ll.C[List[T3]] } value dZ { // after parser - private val cD: ll.C[List[T3]] + private[this] val cD: ll.C[List[T3]] val cD: ll.C[List[T3]] } value dZ { // after uncurry - private val cD: ll.C[List[T3]] + private[this] val cD: ll.C[List[T3]] val cD(): ll.C[List[T3]] } value dZ { // after erasure - private val cD: ll.C + private[this] val cD: ll.C val cD(): ll.C } @@ -307,17 +307,17 @@ method kz { // after parser } value $outer { // after parser - private val cD: ll.C[List[T3]] + private[this] val cD: ll.C[List[T3]] val cD: ll.C[List[T3]] } value $outer { // after uncurry - private val cD: ll.C[List[T3]] + private[this] val cD: ll.C[List[T3]] val cD(): ll.C[List[T3]] } value $outer { // after erasure - private val cD: ll.C + private[this] val cD: ll.C val cD(): ll.C } diff --git a/test/files/run/existentials3.check b/test/files/run/existentials3.check.temporarily.disabled index 36a458dacc..36a458dacc 100644 --- a/test/files/run/existentials3.check +++ b/test/files/run/existentials3.check.temporarily.disabled diff --git a/test/files/run/existentials3.scala b/test/files/run/existentials3.scala.temporarily.disabled index bb80d366cc..bb80d366cc 100644 --- a/test/files/run/existentials3.scala +++ b/test/files/run/existentials3.scala.temporarily.disabled diff --git a/test/files/run/groundtypetags_core.check b/test/files/run/groundtypetags_core.check new file mode 100644 index 0000000000..62fcb481ae --- /dev/null +++ b/test/files/run/groundtypetags_core.check @@ -0,0 +1,30 @@ +true
+ConcreteTypeTag[Byte]
+true
+ConcreteTypeTag[Short]
+true
+ConcreteTypeTag[Char]
+true
+ConcreteTypeTag[Int]
+true
+ConcreteTypeTag[Long]
+true
+ConcreteTypeTag[Float]
+true
+ConcreteTypeTag[Double]
+true
+ConcreteTypeTag[Boolean]
+true
+ConcreteTypeTag[Unit]
+true
+ConcreteTypeTag[Any]
+true
+ConcreteTypeTag[Object]
+true
+ConcreteTypeTag[AnyVal]
+true
+ConcreteTypeTag[AnyRef]
+true
+ConcreteTypeTag[Null]
+true
+ConcreteTypeTag[Nothing]
diff --git a/test/files/run/groundtypetags_core.scala b/test/files/run/groundtypetags_core.scala new file mode 100644 index 0000000000..8b81a0c795 --- /dev/null +++ b/test/files/run/groundtypetags_core.scala @@ -0,0 +1,32 @@ +object Test extends App { + println(implicitly[ConcreteTypeTag[Byte]] eq ConcreteTypeTag.Byte) + println(implicitly[ConcreteTypeTag[Byte]]) + println(implicitly[ConcreteTypeTag[Short]] eq ConcreteTypeTag.Short) + println(implicitly[ConcreteTypeTag[Short]]) + println(implicitly[ConcreteTypeTag[Char]] eq ConcreteTypeTag.Char) + println(implicitly[ConcreteTypeTag[Char]]) + println(implicitly[ConcreteTypeTag[Int]] eq ConcreteTypeTag.Int) + println(implicitly[ConcreteTypeTag[Int]]) + println(implicitly[ConcreteTypeTag[Long]] eq ConcreteTypeTag.Long) + println(implicitly[ConcreteTypeTag[Long]]) + println(implicitly[ConcreteTypeTag[Float]] eq ConcreteTypeTag.Float) + println(implicitly[ConcreteTypeTag[Float]]) + println(implicitly[ConcreteTypeTag[Double]] eq ConcreteTypeTag.Double) + println(implicitly[ConcreteTypeTag[Double]]) + println(implicitly[ConcreteTypeTag[Boolean]] eq ConcreteTypeTag.Boolean) + println(implicitly[ConcreteTypeTag[Boolean]]) + println(implicitly[ConcreteTypeTag[Unit]] eq ConcreteTypeTag.Unit) + println(implicitly[ConcreteTypeTag[Unit]]) + println(implicitly[ConcreteTypeTag[Any]] eq ConcreteTypeTag.Any) + println(implicitly[ConcreteTypeTag[Any]]) + println(implicitly[ConcreteTypeTag[Object]] eq ConcreteTypeTag.Object) + println(implicitly[ConcreteTypeTag[Object]]) + println(implicitly[ConcreteTypeTag[AnyVal]] eq ConcreteTypeTag.AnyVal) + println(implicitly[ConcreteTypeTag[AnyVal]]) + println(implicitly[ConcreteTypeTag[AnyRef]] eq ConcreteTypeTag.AnyRef) + println(implicitly[ConcreteTypeTag[AnyRef]]) + println(implicitly[ConcreteTypeTag[Null]] eq ConcreteTypeTag.Null) + println(implicitly[ConcreteTypeTag[Null]]) + println(implicitly[ConcreteTypeTag[Nothing]] eq ConcreteTypeTag.Nothing) + println(implicitly[ConcreteTypeTag[Nothing]]) +}
\ No newline at end of file diff --git a/test/files/run/implicitclasses.scala b/test/files/run/implicitclasses.scala new file mode 100644 index 0000000000..886d4dede0 --- /dev/null +++ b/test/files/run/implicitclasses.scala @@ -0,0 +1,10 @@ +object Test extends App { + + implicit class C(s: String) { + def nElems = s.length + } + + assert("abc".nElems == 3) + +} + diff --git a/test/files/run/is-valid-num.scala b/test/files/run/is-valid-num.scala index 9c43e98911..402eff99d6 100644 --- a/test/files/run/is-valid-num.scala +++ b/test/files/run/is-valid-num.scala @@ -3,95 +3,310 @@ object Test { def y = BigDecimal("" + (Short.MaxValue + 1) + ".0") def y1 = BigDecimal("0.1") def y2 = BigDecimal("0.5") - + def l1 = Int.MaxValue.toLong + 1 def l2 = Int.MinValue.toLong - 1 def main(args: Array[String]): Unit = { +// assert(x.isWhole, x) assert(!x.isValidDouble, x) assert(!x.isValidFloat, x) assert(!x.isValidLong, x) assert(!x.isValidInt, x) assert(!x.isValidChar, x) + assert(!x.isValidShort, x) assert(!x.isValidByte, x) +// assert(y.isWhole, y) assert(!y.isValidShort, y) assert(y.isValidChar, y) assert(y.isValidInt, y) assert(y.isValidFloat, y) assert(y.isValidDouble, y) + assert(y.isValidLong, y) + assert(!y.isValidByte, y) +// assert(!y1.isWhole) assert(!y1.isValidLong, y1) assert(!y1.isValidFloat, y1) assert(!y1.isValidDouble, y1) + assert(!y1.isValidInt, y1) + assert(!y1.isValidChar, y1) + assert(!y1.isValidShort, y1) + assert(!y1.isValidByte, y1) assert(!y2.isValidLong, y2) assert(y2.isValidFloat, y2) assert(y2.isValidDouble, y2) - testBigIntIsFloat() - testBigIntIsDouble() - assert(!l1.isValidInt && (l1 - 1).isValidInt, l1) assert(!l2.isValidInt && (l2 + 1).isValidInt, l2) + + testBigInts() + testNonWholeDoubles() + testNaNs() + } + + def testBigInts() { + def biExp2(e: Int) = BigInt(1) << e + def checkBigInt2(bi: BigInt) { checkBigInt(-bi); checkBigInt(bi) } + + val pf = 24 + val pd = 53 + + checkBigInt(BigInt(0)) + checkBigInt2(biExp2(0)) + + checkBigInt2(biExp2(7) - 1) + checkBigInt2(biExp2(7)) + checkBigInt2(biExp2(7) + 1) + + checkBigInt2(biExp2(8) - 1) + checkBigInt2(biExp2(8)) + checkBigInt2(biExp2(8) + 1) + + checkBigInt2(biExp2(15) - 1) + checkBigInt2(biExp2(15)) + checkBigInt2(biExp2(15) + 1) + + checkBigInt2(biExp2(16) - 1) + checkBigInt2(biExp2(16)) + checkBigInt2(biExp2(16) + 1) + + checkBigInt2(biExp2(pf) - 1) + checkBigInt2(biExp2(pf)) + checkBigInt2(biExp2(pf) + 1) + checkBigInt2(biExp2(pf) + 2) + checkBigInt2(biExp2(pf) - 2) + checkBigInt2(biExp2(pf + 1) - 1) + checkBigInt2(biExp2(pf + 1)) + checkBigInt2(biExp2(pf + 1) + 1) + checkBigInt2(biExp2(pf + 1) + 2) + checkBigInt2(biExp2(pf + 1) + 3) + checkBigInt2(biExp2(pf + 1) + 4) + + checkBigInt2(biExp2(31) - 1) + checkBigInt2(biExp2(31)) + checkBigInt2(biExp2(31) + 1) + + checkBigInt2(biExp2(32) - 1) + checkBigInt2(biExp2(32)) + checkBigInt2(biExp2(32) + 1) + checkBigInt2(biExp2(32) + biExp2(64 - pf)) + checkBigInt2(biExp2(32) + biExp2(64 - pf + 1)) + + checkBigInt2(biExp2(pd) - 1) + checkBigInt2(biExp2(pd)) + checkBigInt2(biExp2(pd) + 1) + checkBigInt2(biExp2(pd) + 2) + checkBigInt2(biExp2(pd + 1) - 2) + checkBigInt2(biExp2(pd + 1) - 1) + checkBigInt2(biExp2(pd + 1)) + checkBigInt2(biExp2(pd + 1) + 1) + checkBigInt2(biExp2(pd + 1) + 2) + checkBigInt2(biExp2(pd + 1) + 3) + checkBigInt2(biExp2(pd + 1) + 4) + + checkBigInt2(biExp2(63) - 1) + checkBigInt2(biExp2(63)) + checkBigInt2(biExp2(63) + 1) + checkBigInt2(biExp2(63) + biExp2(63 - pd)) + checkBigInt2(biExp2(63) + biExp2(63 - pd + 1)) + checkBigInt2(biExp2(63) + biExp2(63 - pf)) + checkBigInt2(biExp2(63) + biExp2(63 - pf + 1)) + + checkBigInt2(biExp2(64) - 1) + checkBigInt2(biExp2(64)) + checkBigInt2(biExp2(64) + 1) + checkBigInt2(biExp2(64) + biExp2(64 - pd)) + checkBigInt2(biExp2(64) + biExp2(64 - pd + 1)) + checkBigInt2(biExp2(64) + biExp2(64 - pf)) + checkBigInt2(biExp2(64) + biExp2(64 - pf + 1)) + + checkBigInt2(biExp2(127)) + checkBigInt2(biExp2(128) - biExp2(128 - pf)) + checkBigInt2(biExp2(128) - biExp2(128 - pf - 1)) + checkBigInt2(biExp2(128)) + + checkBigInt2(biExp2(1023)) + checkBigInt2(biExp2(1024) - biExp2(1024 - pd)) + checkBigInt2(biExp2(1024) - biExp2(1024 - pd - 1)) + checkBigInt2(biExp2(1024)) + } + + def testNonWholeDoubles() { + checkNonWholeDouble(0.5) + checkNonWholeDouble(-math.E) + checkNonWholeDouble((1L << 51).toDouble + 0.5) + checkNonWholeDouble((1L << 23).toDouble + 0.5) + checkNonWholeDouble(Double.PositiveInfinity) + checkNonWholeDouble(Double.NegativeInfinity) } - def biExp2(e: Int) = BigInt(1) << e + def testNaNs() { + assert(!Double.NaN.isWhole, Double.NaN) +// assert(!Double.NaN.isValidDouble, Double.NaN) +// assert(!Double.NaN.isValidFloat, Double.NaN) +// assert(!Double.NaN.isValidLong, Double.NaN) + assert(!Double.NaN.isValidInt, Double.NaN) + assert(!Double.NaN.isValidChar, Double.NaN) + assert(!Double.NaN.isValidShort, Double.NaN) + assert(!Double.NaN.isValidByte, Double.NaN) - def testBigIntIsFloat() { - val prec = 24 - def checkFloatT(x: BigInt) = { - assert(x.isValidFloat, x) - assert((-x).isValidFloat, -x) + assert(!Float.NaN.isWhole, Float.NaN) +// assert(!Float.NaN.isValidDouble, Float.NaN) +// assert(!Float.NaN.isValidFloat, Float.NaN) +// assert(!Float.NaN.isValidLong, Float.NaN) + assert(!Float.NaN.isValidInt, Float.NaN) + assert(!Float.NaN.isValidChar, Float.NaN) + assert(!Float.NaN.isValidShort, Float.NaN) + assert(!Float.NaN.isValidByte, Float.NaN) + } + + def checkNonWholeDouble(d: Double) { + val f = d.toFloat + val isFloat = f == d + + if (!d.isInfinity) { + val bd = BigDecimal(new java.math.BigDecimal(d)) +// assert(!bd.isWhole, bd) + assert(bd.isValidDouble, bd) + assert(bd.isValidFloat == isFloat, bd) + assert(!bd.isValidLong, bd) + assert(!bd.isValidInt, bd) + assert(!bd.isValidChar, bd) + assert(!bd.isValidShort, bd) + assert(!bd.isValidByte, bd) + } + + assert(!d.isWhole, d) +// assert(d.isValidDouble, d) +// assert(d.isValidFloat == isFloat, d) +// assert(!d.isValidLong, d) + assert(!d.isValidInt, d) + assert(!d.isValidChar, d) + assert(!d.isValidShort, d) + assert(!d.isValidByte, d) + + if (isFloat) { + assert(!f.isWhole, f) +// assert(f.isValidDouble, f) +// assert(f.isValidFloat == isFloat, f) +// assert(!f.isValidLong, f) + assert(!f.isValidInt, f) + assert(!f.isValidChar, f) + assert(!f.isValidShort, f) + assert(!f.isValidByte, f) } - def checkFloatF(x: BigInt) = { - assert(!x.isValidFloat, x) - assert(!(-x).isValidFloat, -x) - } - checkFloatT(biExp2(prec) - 1) - checkFloatT(biExp2(prec)) - checkFloatF(biExp2(prec) + 1) - checkFloatT(biExp2(prec) + 2) - checkFloatT(biExp2(prec) - 2) - checkFloatF(biExp2(prec + 1) - 1) - checkFloatT(biExp2(prec + 1)) - checkFloatF(biExp2(prec + 1) + 1) - checkFloatF(biExp2(prec + 1) + 2) - checkFloatF(biExp2(prec + 1) + 3) - checkFloatT(biExp2(prec + 1) + 4) - checkFloatT(biExp2(64)) - checkFloatF(biExp2(64) + biExp2(64 - prec)) - checkFloatT(biExp2(64) + biExp2(64 - prec + 1)) - checkFloatT(biExp2(127)) - checkFloatT(biExp2(128) - biExp2(128 - prec)) - checkFloatF(biExp2(128) - biExp2(128 - prec - 1)) - checkFloatF(biExp2(128)) } - def testBigIntIsDouble() { - val prec = 53 - def checkDoubleT(x: BigInt) = { - assert(x.isValidDouble, x) - assert((-x).isValidDouble, -x) + def checkBigInt(bi: BigInt) { + val bd = BigDecimal(bi, java.math.MathContext.UNLIMITED) + val isByte = bi >= Byte.MinValue && bi <= Byte.MaxValue + val isShort = bi >= Short.MinValue && bi <= Short.MaxValue + val isChar = bi >= Char.MinValue && bi <= Char.MaxValue + val isInt = bi >= Int.MinValue && bi <= Int.MaxValue + val isLong = bi >= Long.MinValue && bi <= Long.MaxValue + val isFloat = !bi.toFloat.isInfinity && bd.compare(BigDecimal(new java.math.BigDecimal(bi.toFloat))) == 0 + val isDouble = !bi.toDouble.isInfinity && bd.compare(BigDecimal(new java.math.BigDecimal(bi.toDouble))) == 0 + +// assert(bd.isWhole, bd) + assert(bd.isValidDouble == isDouble, bd) + assert(bd.isValidFloat == isFloat, bd) + assert(bd.isValidLong == isLong, bd) + assert(bd.isValidInt == isInt, bd) + assert(bd.isValidChar == isChar, bd) + assert(bd.isValidShort == isShort, bd) + assert(bd.isValidByte == isByte, bd) + +// assert(bi.isWhole, bi) + assert(bi.isValidDouble == isDouble, bi) + assert(bi.isValidFloat == isFloat, bi) + assert(bi.isValidLong == isLong, bi) + assert(bi.isValidInt == isInt, bi) + assert(bi.isValidChar == isChar, bi) + assert(bi.isValidShort == isShort, bi) + assert(bi.isValidByte == isByte, bi) + + if (isDouble) { + val d = bi.toDouble + assert(d.isWhole, d) +// assert(d.isValidDouble == isDouble, d) +// assert(d.isValidFloat == isFloat, d) +// assert(d.isValidLong == isLong, d) + assert(d.isValidInt == isInt, d) + assert(d.isValidChar == isChar, d) + assert(d.isValidShort == isShort, d) + assert(d.isValidByte == isByte, d) + } + + if (isFloat) { + val f = bi.toFloat + assert(f.isWhole, f) +// assert(f.isValidDouble == isDouble, f) +// assert(f.isValidFloat == isFloat, f) +// assert(f.isValidLong == isLong, f) + assert(f.isValidInt == isInt, f) + assert(f.isValidChar == isChar, f) + assert(f.isValidShort == isShort, f) + assert(f.isValidByte == isByte, f) + } + + if (isLong) { + val l = bi.toLong + assert(l.isWhole, l) +// assert(l.isValidDouble == isDouble, l) +// assert(l.isValidFloat == isFloat, l) +// assert(l.isValidLong == isLong, l) + assert(l.isValidInt == isInt, l) + assert(l.isValidChar == isChar, l) + assert(l.isValidShort == isShort, l) + assert(l.isValidByte == isByte, l) + } + + if (isInt) { + val i = bi.toInt + assert(i.isWhole, i) +// assert(i.isValidDouble == isDouble, i) +// assert(i.isValidFloat == isFloat, i) +// assert(i.isValidLong == isLong, i) + assert(i.isValidInt == isInt, i) + assert(i.isValidChar == isChar, i) + assert(i.isValidShort == isShort, i) + assert(i.isValidByte == isByte, i) } - def checkDoubleF(x: BigInt) = { - assert(!x.isValidDouble, x) - assert(!(-x).isValidDouble, -x) + + if (isChar) { + val c = bi.toChar + assert(c.isWhole, c) +// assert(c.isValidDouble == isDouble, c) +// assert(c.isValidFloat == isFloat, c) +// assert(c.isValidLong == isLong, c) + assert(c.isValidInt == isInt, c) + assert(c.isValidChar == isChar, c) + assert(c.isValidShort == isShort, c) + assert(c.isValidByte == isByte, c) + } + + if (isShort) { + val s = bi.toShort + assert(s.isWhole, s) +// assert(s.isValidDouble == isDouble, s) +// assert(s.isValidFloat == isFloat, s) +// assert(s.isValidLong == isLong, s) + assert(s.isValidInt == isInt, s) + assert(s.isValidChar == isChar, s) + assert(s.isValidShort == isShort, s) + assert(s.isValidByte == isByte, s) + } + + if (isByte) { + val b = bi.toByte + assert(b.isWhole, b) +// assert(b.isValidDouble == isDouble, b) +// assert(b.isValidFloat == isFloat, b) +// assert(b.isValidLong == isLong, b) + assert(b.isValidInt == isInt, b) + assert(b.isValidChar == isChar, b) + assert(b.isValidShort == isShort, b) + assert(b.isValidByte == isByte, b) } - checkDoubleT(biExp2(prec) - 1) - checkDoubleT(biExp2(prec)) - checkDoubleF(biExp2(prec) + 1) - checkDoubleT(biExp2(prec) + 2) - checkDoubleT(biExp2(prec + 1) - 2) - checkDoubleF(biExp2(prec + 1) - 1) - checkDoubleT(biExp2(prec + 1)) - checkDoubleF(biExp2(prec + 1) + 1) - checkDoubleF(biExp2(prec + 1) + 2) - checkDoubleF(biExp2(prec + 1) + 3) - checkDoubleT(biExp2(prec + 1) + 4) - checkDoubleT(biExp2(64)) - checkDoubleF(biExp2(64) + biExp2(64 - prec)) - checkDoubleT(biExp2(64) + biExp2(64 - prec + 1)) - checkDoubleT(biExp2(1023)) - checkDoubleT(biExp2(1024) - biExp2(1024 - prec)) - checkDoubleF(biExp2(1024) - biExp2(1024 - prec - 1)) - checkDoubleF(biExp2(1024)) } } diff --git a/test/files/run/macro-abort-fresh.check b/test/files/run/macro-abort-fresh.check new file mode 100644 index 0000000000..28057c2883 --- /dev/null +++ b/test/files/run/macro-abort-fresh.check @@ -0,0 +1,6 @@ +$1$
+qwe1
+qwe2
+reflective compilation has failed:
+
+blargh
diff --git a/test/files/run/macro-abort-fresh.flags b/test/files/run/macro-abort-fresh.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-abort-fresh.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-abort-fresh/Macros_1.scala b/test/files/run/macro-abort-fresh/Macros_1.scala new file mode 100644 index 0000000000..4186c4c4a6 --- /dev/null +++ b/test/files/run/macro-abort-fresh/Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.makro.Context + +object Impls { + def impl(c: Context) = { + import c.mirror._ + println(c.fresh()) + println(c.fresh("qwe")) + println(c.fresh(newTypeName("qwe"))) + c.abort(NoPosition, "blargh") + } +} + +object Macros { + def foo = macro Impls.impl +}
\ No newline at end of file diff --git a/test/files/run/macro-abort-fresh/Test_2.scala b/test/files/run/macro-abort-fresh/Test_2.scala new file mode 100644 index 0000000000..f389231ca6 --- /dev/null +++ b/test/files/run/macro-abort-fresh/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Select(Ident("Macros"), newTermName("foo")) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +}
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-md-mi.check b/test/files/run/macro-basic-ma-md-mi.check new file mode 100644 index 0000000000..b74e882ae3 --- /dev/null +++ b/test/files/run/macro-basic-ma-md-mi.check @@ -0,0 +1 @@ +31
\ No newline at end of file diff --git a/test/files/run/macro-basic.flags b/test/files/run/macro-basic-ma-md-mi.flags index 06a7b31f11..06a7b31f11 100644 --- a/test/files/run/macro-basic.flags +++ b/test/files/run/macro-basic-ma-md-mi.flags 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 new file mode 100644 index 0000000000..3f23e349d5 --- /dev/null +++ b/test/files/run/macro-basic-ma-md-mi/Impls_1.scala @@ -0,0 +1,21 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr[Int](body) + } + + def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + Expr[Int](body) + } + + def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + Expr[Int](body) + } +} diff --git a/test/files/run/macro-basic-ma-md-mi/Macros_2.scala b/test/files/run/macro-basic-ma-md-mi/Macros_2.scala new file mode 100644 index 0000000000..5279043746 --- /dev/null +++ b/test/files/run/macro-basic-ma-md-mi/Macros_2.scala @@ -0,0 +1,10 @@ +object Macros { + object Shmacros { + def foo(x: Int): Int = macro Impls.foo + } + def bar(x: Int): Int = macro Impls.bar +} + +class Macros { + def quux(x: Int): Int = macro Impls.quux +}
\ No newline at end of file diff --git a/test/files/run/macro-basic/Test_2.scala b/test/files/run/macro-basic-ma-md-mi/Test_3.scala index e9a10e20c9..e9a10e20c9 100644 --- a/test/files/run/macro-basic/Test_2.scala +++ b/test/files/run/macro-basic-ma-md-mi/Test_3.scala diff --git a/test/files/run/macro-basic-ma-mdmi.check b/test/files/run/macro-basic-ma-mdmi.check new file mode 100644 index 0000000000..b74e882ae3 --- /dev/null +++ b/test/files/run/macro-basic-ma-mdmi.check @@ -0,0 +1 @@ +31
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-mdmi.flags b/test/files/run/macro-basic-ma-mdmi.flags new file mode 100644 index 0000000000..06a7b31f11 --- /dev/null +++ b/test/files/run/macro-basic-ma-mdmi.flags @@ -0,0 +1 @@ +-Xmacros 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 new file mode 100644 index 0000000000..44bfe861e3 --- /dev/null +++ b/test/files/run/macro-basic-ma-mdmi/Impls_Macros_1.scala @@ -0,0 +1,32 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr[Int](body) + } + + def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + Expr[Int](body) + } + + def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + Expr[Int](body) + } +} + +object Macros { + object Shmacros { + def foo(x: Int): Int = macro Impls.foo + } + def bar(x: Int): Int = macro Impls.bar +} + +class Macros { + def quux(x: Int): Int = macro Impls.quux +}
\ No newline at end of file diff --git a/test/files/run/macro-basic-ma-mdmi/Test_2.scala b/test/files/run/macro-basic-ma-mdmi/Test_2.scala new file mode 100644 index 0000000000..e9a10e20c9 --- /dev/null +++ b/test/files/run/macro-basic-ma-mdmi/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + import Macros.Shmacros._ + println(foo(2) + Macros.bar(2) * new Macros().quux(4)) +}
\ No newline at end of file diff --git a/test/files/run/macro-basic-mamd-mi.check b/test/files/run/macro-basic-mamd-mi.check new file mode 100644 index 0000000000..b74e882ae3 --- /dev/null +++ b/test/files/run/macro-basic-mamd-mi.check @@ -0,0 +1 @@ +31
\ No newline at end of file diff --git a/test/files/run/macro-basic-mamd-mi.flags b/test/files/run/macro-basic-mamd-mi.flags new file mode 100644 index 0000000000..06a7b31f11 --- /dev/null +++ b/test/files/run/macro-basic-mamd-mi.flags @@ -0,0 +1 @@ +-Xmacros diff --git a/test/files/run/macro-basic-mamd-mi/Impls_1.scala b/test/files/run/macro-basic-mamd-mi/Impls_1.scala new file mode 100644 index 0000000000..eadb63fa8e --- /dev/null +++ b/test/files/run/macro-basic-mamd-mi/Impls_1.scala @@ -0,0 +1,19 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + } + + def bar(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + } + + def quux(c: Ctx)(x: c.Expr[Int]): c.Expr[Int] = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + Expr[Int](body) + } +} diff --git a/test/files/run/macro-basic-mamd-mi/Macros_Test_2.scala b/test/files/run/macro-basic-mamd-mi/Macros_Test_2.scala new file mode 100644 index 0000000000..d3746894f0 --- /dev/null +++ b/test/files/run/macro-basic-mamd-mi/Macros_Test_2.scala @@ -0,0 +1,15 @@ +object Macros { + object Shmacros { + def foo(x: Int): Int = macro Impls.foo + } + def bar(x: Int): Int = macro Impls.bar +} + +class Macros { + def quux(x: Int): Int = macro Impls.quux +} + +object Test extends App { + import Macros.Shmacros._ + println(foo(2) + Macros.bar(2) * new Macros().quux(4)) +}
\ No newline at end of file diff --git a/test/files/run/macro-basic.check b/test/files/run/macro-basic.check deleted file mode 100644 index d434014897..0000000000 --- a/test/files/run/macro-basic.check +++ /dev/null @@ -1 +0,0 @@ -10
diff --git a/test/files/run/macro-basic/Macros_1.scala b/test/files/run/macro-basic/Macros_1.scala deleted file mode 100644 index c2ea183abe..0000000000 --- a/test/files/run/macro-basic/Macros_1.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Macros { - object Shmacros { - def macro foo(x: Int): Int = x - } - def macro bar(x: Int): Int = x -} - -class Macros { - def macro quux(x: Int): Int = x -}
\ No newline at end of file diff --git a/test/files/run/macro-bodyexpandstoimpl.check b/test/files/run/macro-bodyexpandstoimpl.check new file mode 100644 index 0000000000..f70d7bba4a --- /dev/null +++ b/test/files/run/macro-bodyexpandstoimpl.check @@ -0,0 +1 @@ +42
\ No newline at end of file diff --git a/test/files/run/macro-bodyexpandstoimpl.flags b/test/files/run/macro-bodyexpandstoimpl.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-bodyexpandstoimpl.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala new file mode 100644 index 0000000000..5c5ec2c999 --- /dev/null +++ b/test/files/run/macro-bodyexpandstoimpl/Impls_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = x + + def refToFoo(dummy: Int) = macro refToFoo_impl + def refToFoo_impl(c: Ctx)(dummy: c.Expr[Int]) = { + import c.mirror._ + val body = Select(Ident(newTermName("Impls")), newTermName("foo")) + Expr[Int](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala b/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala new file mode 100644 index 0000000000..2934201a16 --- /dev/null +++ b/test/files/run/macro-bodyexpandstoimpl/Macros_Test_2.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def foo(x: Int) = macro Impls.refToFoo(42) +} + +object Test extends App { + import Macros._ + println(foo(42)) +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation.check b/test/files/run/macro-declared-in-annotation.check new file mode 100644 index 0000000000..1ea14b4e20 --- /dev/null +++ b/test/files/run/macro-declared-in-annotation.check @@ -0,0 +1 @@ +it works
diff --git a/test/files/run/macro-declared-in-annotation.flags b/test/files/run/macro-declared-in-annotation.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-annotation.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation/Impls_1.scala b/test/files/run/macro-declared-in-annotation/Impls_1.scala new file mode 100644 index 0000000000..a1234a7374 --- /dev/null +++ b/test/files/run/macro-declared-in-annotation/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Literal(Constant("this is deprecated"))) + Expr[String](body) + } +} diff --git a/test/files/run/macro-declared-in-annotation/Macros_2.scala b/test/files/run/macro-declared-in-annotation/Macros_2.scala new file mode 100644 index 0000000000..a565849aa9 --- /dev/null +++ b/test/files/run/macro-declared-in-annotation/Macros_2.scala @@ -0,0 +1,8 @@ +class foo(val bar: String) extends StaticAnnotation + +object Api { + // foo in ann must have a different name + // otherwise, we get bitten by https://issues.scala-lang.org/browse/SI-5544 + @foo({def fooInAnn = macro Impls.foo; fooInAnn}) + def foo = println("it works") +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-annotation/Test_3.scala b/test/files/run/macro-declared-in-annotation/Test_3.scala new file mode 100644 index 0000000000..866487f028 --- /dev/null +++ b/test/files/run/macro-declared-in-annotation/Test_3.scala @@ -0,0 +1,3 @@ +object Test extends App { + Api.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-anonymous.check b/test/files/run/macro-declared-in-anonymous.check new file mode 100644 index 0000000000..09b8d015a6 --- /dev/null +++ b/test/files/run/macro-declared-in-anonymous.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](Test.this.macros) +it works diff --git a/test/files/run/macro-declared-in-anonymous.flags b/test/files/run/macro-declared-in-anonymous.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-anonymous.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-anonymous/Impls_1.scala b/test/files/run/macro-declared-in-anonymous/Impls_1.scala new file mode 100644 index 0000000000..c0827ace31 --- /dev/null +++ b/test/files/run/macro-declared-in-anonymous/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-anonymous/Macros_Test_2.scala b/test/files/run/macro-declared-in-anonymous/Macros_Test_2.scala new file mode 100644 index 0000000000..8bd8c172c9 --- /dev/null +++ b/test/files/run/macro-declared-in-anonymous/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val macros = new { def foo = macro Impls.foo } + macros.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-block.check b/test/files/run/macro-declared-in-block.check new file mode 100644 index 0000000000..a61fd13087 --- /dev/null +++ b/test/files/run/macro-declared-in-block.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](<empty>)
+it works
diff --git a/test/files/run/macro-declared-in-block.flags b/test/files/run/macro-declared-in-block.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-block.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-block/Impls_1.scala b/test/files/run/macro-declared-in-block/Impls_1.scala new file mode 100644 index 0000000000..c0827ace31 --- /dev/null +++ b/test/files/run/macro-declared-in-block/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-block/Macros_Test_2.scala b/test/files/run/macro-declared-in-block/Macros_Test_2.scala new file mode 100644 index 0000000000..69088e24bc --- /dev/null +++ b/test/files/run/macro-declared-in-block/Macros_Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + { + def foo = macro Impls.foo + foo + } +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-class.check b/test/files/run/macro-declared-in-class-class.check new file mode 100644 index 0000000000..480c2f906f --- /dev/null +++ b/test/files/run/macro-declared-in-class-class.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](new Test.this.outer.Macros())
+it works
diff --git a/test/files/run/macro-declared-in-class-class.flags b/test/files/run/macro-declared-in-class-class.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-class-class.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-class/Impls_1.scala b/test/files/run/macro-declared-in-class-class/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-class-class/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-class-class/Macros_Test_2.scala b/test/files/run/macro-declared-in-class-class/Macros_Test_2.scala new file mode 100644 index 0000000000..871857a97f --- /dev/null +++ b/test/files/run/macro-declared-in-class-class/Macros_Test_2.scala @@ -0,0 +1,10 @@ +class Macros { + class Macros { + def foo = macro Impls.foo + } +} + +object Test extends App { + val outer = new Macros() + new outer.Macros().foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-object.check b/test/files/run/macro-declared-in-class-object.check new file mode 100644 index 0000000000..f7ba5a53cb --- /dev/null +++ b/test/files/run/macro-declared-in-class-object.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](Test.this.outer.Macros)
+it works
diff --git a/test/files/run/macro-declared-in-class-object.flags b/test/files/run/macro-declared-in-class-object.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-class-object.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class-object/Impls_1.scala b/test/files/run/macro-declared-in-class-object/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-class-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-class-object/Macros_Test_2.scala b/test/files/run/macro-declared-in-class-object/Macros_Test_2.scala new file mode 100644 index 0000000000..994f9fe935 --- /dev/null +++ b/test/files/run/macro-declared-in-class-object/Macros_Test_2.scala @@ -0,0 +1,10 @@ +class Macros { + object Macros { + def foo = macro Impls.foo + } +} + +object Test extends App { + val outer = new Macros() + outer.Macros.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class.check b/test/files/run/macro-declared-in-class.check new file mode 100644 index 0000000000..946851e4bb --- /dev/null +++ b/test/files/run/macro-declared-in-class.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](new Macros())
+it works
diff --git a/test/files/run/macro-declared-in-class.flags b/test/files/run/macro-declared-in-class.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-class.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-class/Impls_1.scala b/test/files/run/macro-declared-in-class/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-class/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-class/Macros_Test_2.scala b/test/files/run/macro-declared-in-class/Macros_Test_2.scala new file mode 100644 index 0000000000..1b9d13e775 --- /dev/null +++ b/test/files/run/macro-declared-in-class/Macros_Test_2.scala @@ -0,0 +1,7 @@ +class Macros { + def foo = macro Impls.foo +} + +object Test extends App { + new Macros().foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-default-param.check b/test/files/run/macro-declared-in-default-param.check new file mode 100644 index 0000000000..00052ad018 --- /dev/null +++ b/test/files/run/macro-declared-in-default-param.check @@ -0,0 +1,5 @@ +prefix = Expr[Nothing](<empty>)
+it works
+it works
+prefix = Expr[Nothing](<empty>)
+it works
diff --git a/test/files/run/macro-declared-in-default-param.flags b/test/files/run/macro-declared-in-default-param.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-default-param.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-default-param/Impls_1.scala b/test/files/run/macro-declared-in-default-param/Impls_1.scala new file mode 100644 index 0000000000..e45095812a --- /dev/null +++ b/test/files/run/macro-declared-in-default-param/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Literal(Constant("it works"))) + Expr[String](body) + } +} diff --git a/test/files/run/macro-declared-in-default-param/Macros_Test_2.scala b/test/files/run/macro-declared-in-default-param/Macros_Test_2.scala new file mode 100644 index 0000000000..356029e63e --- /dev/null +++ b/test/files/run/macro-declared-in-default-param/Macros_Test_2.scala @@ -0,0 +1,7 @@ +object Test extends App { + def foo(bar: String = { def foo = macro Impls.foo; foo }) = println(bar) + + foo() + foo("it works") + foo() +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-implicit-class.check b/test/files/run/macro-declared-in-implicit-class.check new file mode 100644 index 0000000000..b3640ceaa7 --- /dev/null +++ b/test/files/run/macro-declared-in-implicit-class.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](Macros.foo("2"))
+Some(2)
diff --git a/test/files/run/macro-declared-in-implicit-class.flags b/test/files/run/macro-declared-in-implicit-class.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-implicit-class.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala b/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala new file mode 100644 index 0000000000..8605d4a8be --- /dev/null +++ b/test/files/run/macro-declared-in-implicit-class/Impls_Macros_1.scala @@ -0,0 +1,19 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def toOptionOfInt(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, newTermName("x")), newTermName("toInt"))))) + Expr[Option[Int]](body) + } +} + +object Macros { + implicit def foo(x: String): Foo = new Foo(x) + + class Foo(val x: String) { + def toOptionOfInt = macro Impls.toOptionOfInt + } +} diff --git a/test/files/run/macro-declared-in-implicit-class/Test_2.scala b/test/files/run/macro-declared-in-implicit-class/Test_2.scala new file mode 100644 index 0000000000..d0bc9cc38c --- /dev/null +++ b/test/files/run/macro-declared-in-implicit-class/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + import Macros._ + println("2".toOptionOfInt) +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method.check b/test/files/run/macro-declared-in-method.check new file mode 100644 index 0000000000..a61fd13087 --- /dev/null +++ b/test/files/run/macro-declared-in-method.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](<empty>)
+it works
diff --git a/test/files/run/macro-declared-in-method.flags b/test/files/run/macro-declared-in-method.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-method.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-method/Impls_1.scala b/test/files/run/macro-declared-in-method/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-method/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-method/Macros_Test_2.scala b/test/files/run/macro-declared-in-method/Macros_Test_2.scala new file mode 100644 index 0000000000..ed5c8b7c43 --- /dev/null +++ b/test/files/run/macro-declared-in-method/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + def bar() = { + def foo = macro Impls.foo + foo + } + + bar() +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class.check b/test/files/run/macro-declared-in-object-class.check new file mode 100644 index 0000000000..480c2f906f --- /dev/null +++ b/test/files/run/macro-declared-in-object-class.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](new Test.this.outer.Macros())
+it works
diff --git a/test/files/run/macro-declared-in-object-class.flags b/test/files/run/macro-declared-in-object-class.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-object-class.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-class/Impls_1.scala b/test/files/run/macro-declared-in-object-class/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-object-class/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-object-class/Macros_Test_2.scala b/test/files/run/macro-declared-in-object-class/Macros_Test_2.scala new file mode 100644 index 0000000000..204deed61c --- /dev/null +++ b/test/files/run/macro-declared-in-object-class/Macros_Test_2.scala @@ -0,0 +1,10 @@ +object Macros { + class Macros { + def foo = macro Impls.foo + } +} + +object Test extends App { + val outer = Macros + new outer.Macros().foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object.check b/test/files/run/macro-declared-in-object-object.check new file mode 100644 index 0000000000..f7ba5a53cb --- /dev/null +++ b/test/files/run/macro-declared-in-object-object.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](Test.this.outer.Macros)
+it works
diff --git a/test/files/run/macro-declared-in-object-object.flags b/test/files/run/macro-declared-in-object-object.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-object-object.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object-object/Impls_1.scala b/test/files/run/macro-declared-in-object-object/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-object-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-object-object/Macros_Test_2.scala b/test/files/run/macro-declared-in-object-object/Macros_Test_2.scala new file mode 100644 index 0000000000..e261a50f3d --- /dev/null +++ b/test/files/run/macro-declared-in-object-object/Macros_Test_2.scala @@ -0,0 +1,10 @@ +object Macros { + object Macros { + def foo = macro Impls.foo + } +} + +object Test extends App { + val outer = Macros + outer.Macros.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object.check b/test/files/run/macro-declared-in-object.check new file mode 100644 index 0000000000..05a8cc48ea --- /dev/null +++ b/test/files/run/macro-declared-in-object.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](Macros)
+it works
diff --git a/test/files/run/macro-declared-in-object.flags b/test/files/run/macro-declared-in-object.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-object.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-object/Impls_1.scala b/test/files/run/macro-declared-in-object/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-object/Macros_Test_2.scala b/test/files/run/macro-declared-in-object/Macros_Test_2.scala new file mode 100644 index 0000000000..a5a4862ba0 --- /dev/null +++ b/test/files/run/macro-declared-in-object/Macros_Test_2.scala @@ -0,0 +1,7 @@ +object Macros { + def foo = macro Impls.foo +} + +object Test extends App { + Macros.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object.check b/test/files/run/macro-declared-in-package-object.check new file mode 100644 index 0000000000..6f797f3c68 --- /dev/null +++ b/test/files/run/macro-declared-in-package-object.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](Macros.`package`)
+it works
diff --git a/test/files/run/macro-declared-in-package-object.flags b/test/files/run/macro-declared-in-package-object.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-package-object.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-package-object/Impls_1.scala b/test/files/run/macro-declared-in-package-object/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-package-object/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-package-object/Macros_Test_2.scala b/test/files/run/macro-declared-in-package-object/Macros_Test_2.scala new file mode 100644 index 0000000000..54a5962e80 --- /dev/null +++ b/test/files/run/macro-declared-in-package-object/Macros_Test_2.scala @@ -0,0 +1,8 @@ +package object Macros { + def foo = macro Impls.foo +} + +object Test extends App { + import Macros._ + foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement.check b/test/files/run/macro-declared-in-refinement.check new file mode 100644 index 0000000000..861cd43b01 --- /dev/null +++ b/test/files/run/macro-declared-in-refinement.check @@ -0,0 +1,2 @@ +prefix = Expr[Nothing](Test.this.macros)
+it works
diff --git a/test/files/run/macro-declared-in-refinement.flags b/test/files/run/macro-declared-in-refinement.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-refinement.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-refinement/Impls_1.scala b/test/files/run/macro-declared-in-refinement/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-refinement/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-refinement/Macros_Test_2.scala b/test/files/run/macro-declared-in-refinement/Macros_Test_2.scala new file mode 100644 index 0000000000..f746c2da57 --- /dev/null +++ b/test/files/run/macro-declared-in-refinement/Macros_Test_2.scala @@ -0,0 +1,6 @@ +class Base + +object Test extends App { + val macros = new Base { def foo = macro Impls.foo } + macros.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait.check b/test/files/run/macro-declared-in-trait.check new file mode 100644 index 0000000000..d5d9e4e457 --- /dev/null +++ b/test/files/run/macro-declared-in-trait.check @@ -0,0 +1,15 @@ +prefix = Expr[Nothing]({
+ final class $anon extends Object with Base {
+ def <init>(): anonymous class $anon = {
+ $anon.super.<init>();
+ ()
+ };
+ <empty>
+ };
+ new $anon()
+})
+it works
+prefix = Expr[Nothing](Macros)
+it works
+prefix = Expr[Nothing](new Macros())
+it works
diff --git a/test/files/run/macro-declared-in-trait.flags b/test/files/run/macro-declared-in-trait.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-declared-in-trait.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-declared-in-trait/Impls_1.scala b/test/files/run/macro-declared-in-trait/Impls_1.scala new file mode 100644 index 0000000000..c2e6933582 --- /dev/null +++ b/test/files/run/macro-declared-in-trait/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.{prefix => prefix} + import c.mirror._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(printPrefix, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works"))))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-declared-in-trait/Macros_Test_2.scala b/test/files/run/macro-declared-in-trait/Macros_Test_2.scala new file mode 100644 index 0000000000..f75906b636 --- /dev/null +++ b/test/files/run/macro-declared-in-trait/Macros_Test_2.scala @@ -0,0 +1,13 @@ +trait Base { + def foo = macro Impls.foo +} + +object Macros extends Base + +class Macros extends Base + +object Test extends App { + (new Base {}).foo + Macros.foo + new Macros().foo +}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a.check b/test/files/run/macro-def-infer-return-type-a.check new file mode 100644 index 0000000000..f70d7bba4a --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-a.check @@ -0,0 +1 @@ +42
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a.flags b/test/files/run/macro-def-infer-return-type-a.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-a.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-a/Impls_1.scala b/test/files/run/macro-def-infer-return-type-a/Impls_1.scala new file mode 100644 index 0000000000..2346a6106d --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-a/Impls_1.scala @@ -0,0 +1,5 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = x +} diff --git a/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala new file mode 100644 index 0000000000..60fe9dc1c2 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-a/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def foo(x: Int) = macro Impls.foo + println(foo(42)) +}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b.check b/test/files/run/macro-def-infer-return-type-b.check new file mode 100644 index 0000000000..f34d257c82 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-b.check @@ -0,0 +1,6 @@ +reflective compilation has failed:
+
+exception during macro expansion:
+java.lang.Error: an implementation is missing
+ at Impls$.foo(Impls_Macros_1.scala:5)
+
diff --git a/test/files/run/macro-def-infer-return-type-b.flags b/test/files/run/macro-def-infer-return-type-b.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-b.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b/Impls_Macros_1.scala b/test/files/run/macro-def-infer-return-type-b/Impls_Macros_1.scala new file mode 100644 index 0000000000..8640713846 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-b/Impls_Macros_1.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[T](c: Ctx)(x: c.Expr[T]) = + throw new Error("an implementation is missing") +} + +object Macros { + def foo[T](x: T) = macro Impls.foo[T] +}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-b/Test_2.scala b/test/files/run/macro-def-infer-return-type-b/Test_2.scala new file mode 100644 index 0000000000..8ff4494750 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-b/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +}
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-c.check b/test/files/run/macro-def-infer-return-type-c.check new file mode 100644 index 0000000000..f70d7bba4a --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-c.check @@ -0,0 +1 @@ +42
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-c.flags b/test/files/run/macro-def-infer-return-type-c.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-c.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-def-infer-return-type-c/Impls_1.scala b/test/files/run/macro-def-infer-return-type-c/Impls_1.scala new file mode 100644 index 0000000000..f3e53bbea7 --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-c/Impls_1.scala @@ -0,0 +1,5 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[T](c: Ctx)(x: c.Expr[T]): c.Expr[T] = x +} diff --git a/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala b/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala new file mode 100644 index 0000000000..967d16f6de --- /dev/null +++ b/test/files/run/macro-def-infer-return-type-c/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def foo[T](x: T) = macro Impls.foo[T] + println(foo(42)) +}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-a.check b/test/files/run/macro-def-path-dependent-a.check new file mode 100644 index 0000000000..1ea14b4e20 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-a.check @@ -0,0 +1 @@ +it works
diff --git a/test/files/run/macro-def-path-dependent-a.flags b/test/files/run/macro-def-path-dependent-a.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-a.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-a/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent-a/Impls_Macros_1.scala new file mode 100644 index 0000000000..d7167e671c --- /dev/null +++ b/test/files/run/macro-def-path-dependent-a/Impls_Macros_1.scala @@ -0,0 +1,21 @@ +import scala.reflect.makro.{Context => Ctx} + +trait Exprs { + self: Universe => + + class Expr[T] +} + +trait Reifiers { + self: Universe => + + type Expr[T] + + def reify[T](expr: T) = macro Impls.reify[T] +} + +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]] = ??? +} diff --git a/test/files/run/macro-def-path-dependent-a/Test_2.scala b/test/files/run/macro-def-path-dependent-a/Test_2.scala new file mode 100644 index 0000000000..7dffc5107d --- /dev/null +++ b/test/files/run/macro-def-path-dependent-a/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println("it works") +}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-b.check b/test/files/run/macro-def-path-dependent-b.check new file mode 100644 index 0000000000..1ea14b4e20 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-b.check @@ -0,0 +1 @@ +it works
diff --git a/test/files/run/macro-def-path-dependent-b.flags b/test/files/run/macro-def-path-dependent-b.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-b.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-b/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent-b/Impls_Macros_1.scala new file mode 100644 index 0000000000..44af6949a7 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-b/Impls_Macros_1.scala @@ -0,0 +1,20 @@ +import scala.reflect.makro.{Context => Ctx} + +trait Exprs { + self: Universe => + + class Expr[T] +} + +trait Reifiers { + self: Universe => + +} + +trait Universe extends Exprs with Reifiers { + def reify[T](expr: T) = macro Impls.reify[T] +} + +object Impls { + def reify[T](cc: Ctx{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? +} diff --git a/test/files/run/macro-def-path-dependent-b/Test_2.scala b/test/files/run/macro-def-path-dependent-b/Test_2.scala new file mode 100644 index 0000000000..7dffc5107d --- /dev/null +++ b/test/files/run/macro-def-path-dependent-b/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println("it works") +}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-c.check b/test/files/run/macro-def-path-dependent-c.check new file mode 100644 index 0000000000..1ea14b4e20 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-c.check @@ -0,0 +1 @@ +it works
diff --git a/test/files/run/macro-def-path-dependent-c.flags b/test/files/run/macro-def-path-dependent-c.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-c.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-c/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent-c/Impls_Macros_1.scala new file mode 100644 index 0000000000..305146c48b --- /dev/null +++ b/test/files/run/macro-def-path-dependent-c/Impls_Macros_1.scala @@ -0,0 +1,20 @@ +import scala.reflect.makro.{Context => Ctx} + +trait Exprs { + self: Universe => + + class Expr[T] +} + +trait Reifiers { + self: Universe => + +} + +trait Universe extends Exprs with Reifiers { + def reify[T](expr: T): Expr[T] = macro Impls.reify[T] +} + +object Impls { + def reify[T](cc: Ctx{ type PrefixType = Universe })(expr: cc.Expr[T]): cc.Expr[cc.prefix.value.Expr[T]] = ??? +} diff --git a/test/files/run/macro-def-path-dependent-c/Test_2.scala b/test/files/run/macro-def-path-dependent-c/Test_2.scala new file mode 100644 index 0000000000..7dffc5107d --- /dev/null +++ b/test/files/run/macro-def-path-dependent-c/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println("it works") +}
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d.check b/test/files/run/macro-def-path-dependent-d.check new file mode 100644 index 0000000000..1ea14b4e20 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-d.check @@ -0,0 +1 @@ +it works
diff --git a/test/files/run/macro-def-path-dependent-d.flags b/test/files/run/macro-def-path-dependent-d.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-def-path-dependent-d.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala b/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala new file mode 100644 index 0000000000..32f03e778e --- /dev/null +++ b/test/files/run/macro-def-path-dependent-d/Impls_Macros_1.scala @@ -0,0 +1,8 @@ +import scala.reflect.makro.Context +import scala.reflect.api.Universe + +object Test { + def materializeTypeTag[T](u: Universe)(e: T) = macro materializeTypeTag_impl[T] + + def materializeTypeTag_impl[T: c.TypeTag](c: Context)(u: c.Expr[Universe])(e: c.Expr[T]): c.Expr[u.value.TypeTag[T]] = ??? +} diff --git a/test/files/run/macro-def-path-dependent-d/Test_2.scala b/test/files/run/macro-def-path-dependent-d/Test_2.scala new file mode 100644 index 0000000000..7dffc5107d --- /dev/null +++ b/test/files/run/macro-def-path-dependent-d/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println("it works") +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit.check b/test/files/run/macro-expand-implicit-macro-has-implicit.check new file mode 100644 index 0000000000..2f562a182f --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-has-implicit.check @@ -0,0 +1 @@ +42
diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit.flags b/test/files/run/macro-expand-implicit-macro-has-implicit.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-has-implicit.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..39db275e1c --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(x.tree)) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala new file mode 100644 index 0000000000..ffb04dc80b --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-has-implicit/Macros_Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + implicit val x = 42 + def foo(implicit x: Int) = macro Impls.foo + foo +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit.check b/test/files/run/macro-expand-implicit-macro-is-implicit.check new file mode 100644 index 0000000000..42abf4579b --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-implicit.check @@ -0,0 +1,2 @@ +Some(2)
+2
diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit.flags b/test/files/run/macro-expand-implicit-macro-is-implicit.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-implicit.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..0262485994 --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-implicit/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = { + import c.mirror._ + val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt")))) + Expr[Option[Int]](body) + } +} diff --git a/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala new file mode 100644 index 0000000000..81ebd63c5f --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-implicit/Macros_Test_2.scala @@ -0,0 +1,10 @@ +object Macros { + implicit def foo(x: String): Option[Int] = macro Impls.foo +} + +object Test extends App { + import Macros._ + println("2": Option[Int]) + val s: Int = "2" getOrElse 0 + println(s) +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-val.check b/test/files/run/macro-expand-implicit-macro-is-val.check new file mode 100644 index 0000000000..78c6baefdd --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-val.check @@ -0,0 +1 @@ +2
diff --git a/test/files/run/macro-expand-implicit-macro-is-val.flags b/test/files/run/macro-expand-implicit-macro-is-val.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-val.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..510d8502f6 --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-val/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.mirror._ + val body = Literal(Constant(2)) + Expr[Int](body) + } +} diff --git a/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala new file mode 100644 index 0000000000..b91b1016c9 --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-val/Macros_Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + implicit def foo = macro Impls.foo + def bar(implicit x: Int) = println(x) + bar +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-implicit-macro-is-view.check b/test/files/run/macro-expand-implicit-macro-is-view.check new file mode 100644 index 0000000000..78c6baefdd --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-view.check @@ -0,0 +1 @@ +2
diff --git a/test/files/run/macro-expand-implicit-macro-is-view.flags b/test/files/run/macro-expand-implicit-macro-is-view.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-view.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..0262485994 --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-view/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[String]): c.Expr[Option[Int]] = { + import c.mirror._ + val body = Apply(Ident(definitions.SomeModule), List(Select(x.tree, newTermName("toInt")))) + Expr[Option[Int]](body) + } +} diff --git a/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala b/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala new file mode 100644 index 0000000000..0ff1fb80ca --- /dev/null +++ b/test/files/run/macro-expand-implicit-macro-is-view/Macros_Test_2.scala @@ -0,0 +1,9 @@ +object Macros { + implicit def foo(x: String): Option[Int] = macro Impls.foo +} + +object Test extends App { + import Macros._ + def bar[T <% Option[Int]](x: T) = println(x) + println("2") +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-multiple-arglists.check b/test/files/run/macro-expand-multiple-arglists.check new file mode 100644 index 0000000000..c24b6ae77d --- /dev/null +++ b/test/files/run/macro-expand-multiple-arglists.check @@ -0,0 +1 @@ +38
\ No newline at end of file diff --git a/test/files/run/macro-expand-multiple-arglists.flags b/test/files/run/macro-expand-multiple-arglists.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-multiple-arglists.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-multiple-arglists/Impls_1.scala b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala new file mode 100644 index 0000000000..ae1c50eace --- /dev/null +++ b/test/files/run/macro-expand-multiple-arglists/Impls_1.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = { + import c.mirror._ + val sum = Apply(Select(x.tree, newTermName("$minus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala b/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala new file mode 100644 index 0000000000..fa4504b0ea --- /dev/null +++ b/test/files/run/macro-expand-multiple-arglists/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def foo(x: Int)(y: Int) = macro Impls.foo + foo(40)(2) +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic.check b/test/files/run/macro-expand-nullary-generic.check new file mode 100644 index 0000000000..6dfe04af12 --- /dev/null +++ b/test/files/run/macro-expand-nullary-generic.check @@ -0,0 +1,6 @@ +it works ConcreteTypeTag[Int]
+it works ConcreteTypeTag[Int]
+it works ConcreteTypeTag[Int]
+it works ConcreteTypeTag[Int]
+it works ConcreteTypeTag[Int]
+kkthxbai
diff --git a/test/files/run/macro-expand-nullary-generic.flags b/test/files/run/macro-expand-nullary-generic.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-nullary-generic.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-generic/Impls_1.scala b/test/files/run/macro-expand-nullary-generic/Impls_1.scala new file mode 100644 index 0000000000..10352594f5 --- /dev/null +++ b/test/files/run/macro-expand-nullary-generic/Impls_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def impl[T: c.TypeTag](c: Ctx) = { + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works " + implicitly[c.TypeTag[T]])))) + Expr[Unit](body) + } + + def fooNullary[T: c.TypeTag](c: Ctx) = impl[T](c) + def fooEmpty[T: c.TypeTag](c: Ctx)() = impl[T](c) + def barNullary[T: c.TypeTag](c: Ctx)(x: c.Expr[Int]) = impl[T](c) + def barEmpty[T: c.TypeTag](c: Ctx)(x: c.Expr[Int])() = impl[T](c) +} diff --git a/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala b/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala new file mode 100644 index 0000000000..2d5cf53c3c --- /dev/null +++ b/test/files/run/macro-expand-nullary-generic/Macros_Test_2.scala @@ -0,0 +1,15 @@ +object Macros { + def foo1[T] = macro Impls.fooNullary[T] + def foo2[T]() = macro Impls.fooEmpty[T] + def bar1[T](x: Int) = macro Impls.barNullary[T] + def bar2[T](x: Int)() = macro Impls.barEmpty[T] +} + +object Test extends App { + Macros.foo1[Int] + Macros.foo2[Int] + Macros.foo2[Int]() + Macros.bar1[Int](42) + Macros.bar2[Int](42)() + println("kkthxbai") +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-nullary-nongeneric.check b/test/files/run/macro-expand-nullary-nongeneric.check new file mode 100644 index 0000000000..9ab5f3a2bc --- /dev/null +++ b/test/files/run/macro-expand-nullary-nongeneric.check @@ -0,0 +1,6 @@ +it works +it works +it works +it works +it works +kkthxbai diff --git a/test/files/run/macro-expand-nullary-nongeneric.flags b/test/files/run/macro-expand-nullary-nongeneric.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-nullary-nongeneric.flags @@ -0,0 +1 @@ +-Xmacros
\ 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 new file mode 100644 index 0000000000..7dc58abba8 --- /dev/null +++ b/test/files/run/macro-expand-nullary-nongeneric/Impls_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def impl(c: Ctx) = { + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + Expr[Unit](body) + } + + def fooNullary(c: Ctx) = impl(c) + def fooEmpty(c: Ctx)() = impl(c) + def barNullary(c: Ctx)(x: c.Expr[Int]) = impl(c) + def barEmpty(c: Ctx)(x: c.Expr[Int])() = impl(c) +} diff --git a/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala b/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala new file mode 100644 index 0000000000..1f6d717956 --- /dev/null +++ b/test/files/run/macro-expand-nullary-nongeneric/Macros_Test_2.scala @@ -0,0 +1,15 @@ +object Macros { + def foo1 = macro Impls.fooNullary + def foo2() = macro Impls.fooEmpty + def bar1(x: Int) = macro Impls.barNullary + def bar2(x: Int)() = macro Impls.barEmpty +} + +object Test extends App { + Macros.foo1 + Macros.foo2 + Macros.foo2() + Macros.bar1(42) + Macros.bar2(42)() + println("kkthxbai") +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-overload.check b/test/files/run/macro-expand-overload.check new file mode 100644 index 0000000000..9d9989d85f --- /dev/null +++ b/test/files/run/macro-expand-overload.check @@ -0,0 +1,6 @@ +(fooObjectString,Expr[Nothing](Macros),42)
+(fooObjectInt,Expr[Nothing](Macros),42)
+fooObjectBoolean
+(fooClassString,Expr[Nothing](new Macros()),42)
+(fooClassInt,Expr[Nothing](new Macros()),42)
+fooClassBoolean
diff --git a/test/files/run/macro-expand-overload.flags b/test/files/run/macro-expand-overload.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-overload.flags @@ -0,0 +1 @@ +-Xmacros
\ 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 new file mode 100644 index 0000000000..1dc4adc20e --- /dev/null +++ b/test/files/run/macro-expand-overload/Impls_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { + import c.{prefix => prefix} + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + 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) +} diff --git a/test/files/run/macro-expand-overload/Macros_Test_2.scala b/test/files/run/macro-expand-overload/Macros_Test_2.scala new file mode 100644 index 0000000000..7f61f85184 --- /dev/null +++ b/test/files/run/macro-expand-overload/Macros_Test_2.scala @@ -0,0 +1,20 @@ +object Macros { + def foo(x: String) = macro Impls.fooObjectString + def foo(x: Int) = macro Impls.fooObjectInt + def foo(x: Boolean) = println("fooObjectBoolean") +} + +class Macros { + def foo(x: String) = macro Impls.fooClassString + def foo(x: Int) = macro Impls.fooClassInt + def foo(x: Boolean) = println("fooClassBoolean") +} + +object Test extends App { + Macros.foo("42") + Macros.foo(42) + Macros.foo(true) + new Macros().foo("42") + new Macros().foo(42) + new Macros().foo(true) +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-override.check b/test/files/run/macro-expand-override.check new file mode 100644 index 0000000000..486bec7098 --- /dev/null +++ b/test/files/run/macro-expand-override.check @@ -0,0 +1,15 @@ +(fooBString,Expr[Nothing](Test.this.dd),42)
+(fooDInt,Expr[Nothing](Test.this.dd),42)
+fooBBoolean
+(fooBString,Expr[Nothing](Test.this.db),42)
+(fooBInt,Expr[Nothing](Test.this.db),42)
+fooBBoolean
+(fooZString,Expr[Nothing](Test.this.zz),42)
+(fooDInt,Expr[Nothing](Test.this.zz),42)
+fooZBoolean
+(fooBString,Expr[Nothing](Test.this.zd),42)
+(fooDInt,Expr[Nothing](Test.this.zd),42)
+fooZBoolean
+(fooBString,Expr[Nothing](Test.this.zb),42)
+(fooBInt,Expr[Nothing](Test.this.zb),42)
+fooZBoolean
diff --git a/test/files/run/macro-expand-override.flags b/test/files/run/macro-expand-override.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-override.flags @@ -0,0 +1 @@ +-Xmacros
\ 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 new file mode 100644 index 0000000000..0b127f5a59 --- /dev/null +++ b/test/files/run/macro-expand-override/Impls_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def impl(c: Ctx)(tag: String, x: c.Expr[_]) = { + import c.{prefix => prefix} + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(tag)), Literal(Constant(prefix.toString)), x.tree)) + 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) +} diff --git a/test/files/run/macro-expand-override/Macros_Test_2.scala b/test/files/run/macro-expand-override/Macros_Test_2.scala new file mode 100644 index 0000000000..f162773c95 --- /dev/null +++ b/test/files/run/macro-expand-override/Macros_Test_2.scala @@ -0,0 +1,43 @@ +class B { + def foo(x: String) = macro Impls.fooBString + def foo(x: Int) = macro Impls.fooBInt + def foo(x: Boolean) = println("fooBBoolean") +} + +class D extends B { + //override def foo(x: String) = println("fooDString") => method cannot override a macro + override def foo(x: Int) = macro Impls.fooDInt +} + +class Z extends D { + override def foo(x: String) = macro Impls.fooZString + override def foo(x: Boolean) = println("fooZBoolean") +} + +object Test extends App { + + val dd: D = new D() + dd.foo("42") + dd.foo(42) + dd.foo(true) + + val db: B = new D() + db.foo("42") + db.foo(42) + db.foo(true) + + val zz: Z = new Z() + zz.foo("42") + zz.foo(42) + zz.foo(true) + + val zd: D = new Z() + zd.foo("42") + zd.foo(42) + zd.foo(true) + + val zb: B = new Z() + zb.foo("42") + zb.foo(42) + zb.foo(true) +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-recursive.check b/test/files/run/macro-expand-recursive.check new file mode 100644 index 0000000000..1ea14b4e20 --- /dev/null +++ b/test/files/run/macro-expand-recursive.check @@ -0,0 +1 @@ +it works
diff --git a/test/files/run/macro-expand-recursive.flags b/test/files/run/macro-expand-recursive.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-recursive.flags @@ -0,0 +1 @@ +-Xmacros
\ 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 new file mode 100644 index 0000000000..6eff805989 --- /dev/null +++ b/test/files/run/macro-expand-recursive/Impls_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("it works")))) + Expr[Unit](body) + } + + def fooFoo(c: Ctx) = { + import c.mirror._ + val body = Select(Ident(newTermName("Macros")), newTermName("foo")) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-recursive/Macros_Test_2.scala b/test/files/run/macro-expand-recursive/Macros_Test_2.scala new file mode 100644 index 0000000000..6ff691bdb1 --- /dev/null +++ b/test/files/run/macro-expand-recursive/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Macros { + def foo = macro Impls.foo + def fooFoo = macro Impls.fooFoo +} + +object Test extends App { + Macros.fooFoo +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a.check b/test/files/run/macro-expand-tparams-bounds-a.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds-a.check diff --git a/test/files/run/macro-expand-tparams-bounds-a.flags b/test/files/run/macro-expand-tparams-bounds-a.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds-a.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala new file mode 100644 index 0000000000..4cd98c5838 --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds-a/Impls_1.scala @@ -0,0 +1,8 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[U <: String](c: Ctx): c.Expr[Unit] = { + import c.mirror._ + Literal(Constant(())) + } +} diff --git a/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala new file mode 100644 index 0000000000..b498e6f65b --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds-a/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Macros { + def foo[U <: String] = macro Impls.foo[U] +} + +object Test extends App { + import Macros._ + foo[String] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b.check b/test/files/run/macro-expand-tparams-bounds-b.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds-b.check diff --git a/test/files/run/macro-expand-tparams-bounds-b.flags b/test/files/run/macro-expand-tparams-bounds-b.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds-b.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala new file mode 100644 index 0000000000..9103ddb08a --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds-b/Impls_1.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +class C + +object Impls { + def foo[U <: C](c: Ctx): c.Expr[Unit] = { + import c.mirror._ + Literal(Constant(())) + } +} diff --git a/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala new file mode 100644 index 0000000000..1a261e9f73 --- /dev/null +++ b/test/files/run/macro-expand-tparams-bounds-b/Macros_Test_2.scala @@ -0,0 +1,10 @@ +class D extends C + +object Macros { + def foo[T <: D] = macro Impls.foo[T] +} + +object Test extends App { + import Macros._ + foo[D] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-explicit.check b/test/files/run/macro-expand-tparams-explicit.check new file mode 100644 index 0000000000..5670e27c4e --- /dev/null +++ b/test/files/run/macro-expand-tparams-explicit.check @@ -0,0 +1 @@ +ConcreteTypeTag[Int]
diff --git a/test/files/run/macro-expand-tparams-explicit.flags b/test/files/run/macro-expand-tparams-explicit.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-explicit.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-explicit/Impls_1.scala b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala new file mode 100644 index 0000000000..957d8331fc --- /dev/null +++ b/test/files/run/macro-expand-tparams-explicit/Impls_1.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[U: c.TypeTag](c: Ctx) = { + import c.mirror._ + val U = implicitly[c.TypeTag[U]] + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala new file mode 100644 index 0000000000..e72c27881a --- /dev/null +++ b/test/files/run/macro-expand-tparams-explicit/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def foo[U] = macro Impls.foo[U] + foo[Int] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-implicit.check b/test/files/run/macro-expand-tparams-implicit.check new file mode 100644 index 0000000000..e57fc1217b --- /dev/null +++ b/test/files/run/macro-expand-tparams-implicit.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[String]
diff --git a/test/files/run/macro-expand-tparams-implicit.flags b/test/files/run/macro-expand-tparams-implicit.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-implicit.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-implicit/Impls_1.scala b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala new file mode 100644 index 0000000000..c25d12be60 --- /dev/null +++ b/test/files/run/macro-expand-tparams-implicit/Impls_1.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = { + import c.mirror._ + val U = implicitly[c.TypeTag[U]] + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala new file mode 100644 index 0000000000..f8c573f509 --- /dev/null +++ b/test/files/run/macro-expand-tparams-implicit/Macros_Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + def foo[U](x: U) = macro Impls.foo[U] + foo(42) + foo("42") +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-only-in-impl.flags b/test/files/run/macro-expand-tparams-only-in-impl.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-only-in-impl.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala b/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala new file mode 100644 index 0000000000..4cd98c5838 --- /dev/null +++ b/test/files/run/macro-expand-tparams-only-in-impl/Impls_1.scala @@ -0,0 +1,8 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[U <: String](c: Ctx): c.Expr[Unit] = { + import c.mirror._ + Literal(Constant(())) + } +} diff --git a/test/files/run/macro-expand-tparams-only-in-impl/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-only-in-impl/Macros_Test_2.scala new file mode 100644 index 0000000000..218c7aec7f --- /dev/null +++ b/test/files/run/macro-expand-tparams-only-in-impl/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Macros { + def foo = macro Impls.foo[String] +} + +object Test extends App { + import Macros._ + foo +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-optional.check b/test/files/run/macro-expand-tparams-optional.check new file mode 100644 index 0000000000..3bacd7a4e0 --- /dev/null +++ b/test/files/run/macro-expand-tparams-optional.check @@ -0,0 +1 @@ +don't know U
diff --git a/test/files/run/macro-expand-tparams-optional.flags b/test/files/run/macro-expand-tparams-optional.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-optional.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-optional/Impls_1.scala b/test/files/run/macro-expand-tparams-optional/Impls_1.scala new file mode 100644 index 0000000000..37efb009c4 --- /dev/null +++ b/test/files/run/macro-expand-tparams-optional/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[U](c: Ctx) = { + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("don't know U")))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-tparams-optional/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-optional/Macros_Test_2.scala new file mode 100644 index 0000000000..e72c27881a --- /dev/null +++ b/test/files/run/macro-expand-tparams-optional/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def foo[U] = macro Impls.foo[U] + foo[Int] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a.check b/test/files/run/macro-expand-tparams-prefix-a.check new file mode 100644 index 0000000000..922be1a6dd --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-a.check @@ -0,0 +1,4 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[Int]
+ConcreteTypeTag[String]
+ConcreteTypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-a.flags b/test/files/run/macro-expand-tparams-prefix-a.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-a.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala new file mode 100644 index 0000000000..c25d12be60 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-a/Impls_1.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = { + import c.mirror._ + val U = implicitly[c.TypeTag[U]] + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(U.toString)))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala new file mode 100644 index 0000000000..81ccb7ff42 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-a/Macros_Test_2.scala @@ -0,0 +1,10 @@ +object Test extends App { + class C[T] { + def foo[U](x: U) = macro Impls.foo[U] + } + + new C[Int]().foo(42) + new C[Boolean]().foo(42) + new C[Int]().foo("42") + new C[String]().foo(true) +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b.check b/test/files/run/macro-expand-tparams-prefix-b.check new file mode 100644 index 0000000000..a336bb51ec --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-b.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Boolean] ConcreteTypeTag[Int]
+ConcreteTypeTag[Boolean] ConcreteTypeTag[String]
diff --git a/test/files/run/macro-expand-tparams-prefix-b.flags b/test/files/run/macro-expand-tparams-prefix-b.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-b.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala new file mode 100644 index 0000000000..8af3ecc9ae --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-b/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[T: c.TypeTag, U: c.TypeTag](c: Ctx)(x: c.Expr[U]) = { + import c.mirror._ + val T = implicitly[c.TypeTag[T]] + val U = implicitly[c.TypeTag[U]] + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala new file mode 100644 index 0000000000..a4a0acfe8b --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-b/Macros_Test_2.scala @@ -0,0 +1,10 @@ +object Test extends App { + class C[T] { + def foo[U](x: U) = macro Impls.foo[T, U] + } + + object D extends C[Boolean] + + D.foo(42) + D.foo("42") +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1.check b/test/files/run/macro-expand-tparams-prefix-c1.check new file mode 100644 index 0000000000..87f295aa49 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-c1.check @@ -0,0 +1,3 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[String]
+ConcreteTypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-c1.flags b/test/files/run/macro-expand-tparams-prefix-c1.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-c1.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala new file mode 100644 index 0000000000..bc880fdf77 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-c1/Impls_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { + import c.mirror._ + Block(List( + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), + Literal(Constant(()))) + } +} diff --git a/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala new file mode 100644 index 0000000000..4fa0c8cb33 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-c1/Macros_Test_2.scala @@ -0,0 +1,11 @@ +class D[T] { + class C[U] { + def foo[V] = macro Impls.foo[T, U, V] + } +} + +object Test extends App { + val outer1 = new D[Int] + val outer2 = new outer1.C[String] + outer2.foo[Boolean] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2.check b/test/files/run/macro-expand-tparams-prefix-c2.check new file mode 100644 index 0000000000..87f295aa49 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-c2.check @@ -0,0 +1,3 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[String]
+ConcreteTypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-c2.flags b/test/files/run/macro-expand-tparams-prefix-c2.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-c2.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala new file mode 100644 index 0000000000..c83e401afb --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-c2/Impls_Macros_1.scala @@ -0,0 +1,18 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { + import c.mirror._ + Block(List( + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), + Literal(Constant(()))) + } +} + +class D[T] { + class C[U] { + def foo[V] = macro Impls.foo[T, U, V] + } +} diff --git a/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala b/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala new file mode 100644 index 0000000000..e729d4a536 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-c2/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + val outer1 = new D[Int] + val outer2 = new outer1.C[String] + outer2.foo[Boolean] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1.check b/test/files/run/macro-expand-tparams-prefix-d1.check new file mode 100644 index 0000000000..ca7a220475 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-d1.check @@ -0,0 +1,3 @@ +TypeTag[T]
+TypeTag[U]
+ConcreteTypeTag[Boolean]
diff --git a/test/files/run/macro-expand-tparams-prefix-d1.flags b/test/files/run/macro-expand-tparams-prefix-d1.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-d1.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala new file mode 100644 index 0000000000..bc880fdf77 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-d1/Impls_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[T, U: c.TypeTag, V](c: Ctx)(implicit T: c.TypeTag[T], V: c.TypeTag[V]): c.Expr[Unit] = { + import c.mirror._ + Block(List( + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(T.toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(implicitly[c.TypeTag[U]].toString)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(V.toString))))), + Literal(Constant(()))) + } +} diff --git a/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala b/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala new file mode 100644 index 0000000000..8222a6d1e8 --- /dev/null +++ b/test/files/run/macro-expand-tparams-prefix-d1/Macros_Test_2.scala @@ -0,0 +1,11 @@ +object Test extends App { + class D[T] { + class C[U] { + def foo[V] = macro Impls.foo[T, U, V] + foo[Boolean] + } + } + + val outer1 = new D[Int] + new outer1.C[String] +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.check b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.check new file mode 100644 index 0000000000..fd1d654cf8 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.check @@ -0,0 +1,4 @@ +reflective compilation has failed:
+
+no `: _*' annotation allowed here +(such annotations are only allowed in arguments to *-parameters)
diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..d97f0af786 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(xs: c.Expr[Int]*) = { + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala new file mode 100644 index 0000000000..523c6b0645 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-bad/Macros_Test_2.scala @@ -0,0 +1,10 @@ +object Macros { + def foo(xs: Int*) = macro Impls.foo +} + +object Test extends App { + import scala.reflect.mirror._ + val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Typed(Apply(Ident(definitions.ListModule), List(Literal(Constant(1)), Literal(Constant(2)))), Ident(tpnme.WILDCARD_STAR)))) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.check b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.check new file mode 100644 index 0000000000..835137b4a2 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.check @@ -0,0 +1 @@ +List(1, 2, 3, 4, 5)
diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..f9667d78b8 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Impls_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(xs: c.Expr[Int]*) = { + import c.mirror._ + val stripped_xs = xs map (_.tree) toList match { + case List(Typed(stripped, Ident(wildstar))) if wildstar == tpnme.WILDCARD_STAR => List(stripped) + case _ => ??? + } + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), stripped_xs) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala new file mode 100644 index 0000000000..f127ebcde7 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-nonvarargs-good/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Macros { + def foo(xs: Int*) = macro Impls.foo +} + +object Test extends App { + val numbers = List(1, 2, 3, 4, 5) + Macros.foo(numbers: _*) +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs.check b/test/files/run/macro-expand-varargs-explicit-over-varargs.check new file mode 100644 index 0000000000..835137b4a2 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs.check @@ -0,0 +1 @@ +List(1, 2, 3, 4, 5)
diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs.flags b/test/files/run/macro-expand-varargs-explicit-over-varargs.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..8c609daa0e --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Impls_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def myprintln(xs: Int*) = { + println(xs) + } + + def foo(c: Ctx)(xs: c.Expr[Int]*) = { + import c.mirror._ + val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala new file mode 100644 index 0000000000..f127ebcde7 --- /dev/null +++ b/test/files/run/macro-expand-varargs-explicit-over-varargs/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Macros { + def foo(xs: Int*) = macro Impls.foo +} + +object Test extends App { + val numbers = List(1, 2, 3, 4, 5) + Macros.foo(numbers: _*) +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.check b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.check new file mode 100644 index 0000000000..0a6596858c --- /dev/null +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.check @@ -0,0 +1 @@ +(1,2,3,4,5)
diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..d97f0af786 --- /dev/null +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(xs: c.Expr[Int]*) = { + import c.mirror._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), xs.map(_.tree).toList) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala new file mode 100644 index 0000000000..2311ca0b95 --- /dev/null +++ b/test/files/run/macro-expand-varargs-implicit-over-nonvarargs/Macros_Test_2.scala @@ -0,0 +1,7 @@ +object Macros { + def foo(xs: Int*) = macro Impls.foo +} + +object Test extends App { + Macros.foo(1, 2, 3, 4, 5) +}
\ No newline at end of file diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs.check b/test/files/run/macro-expand-varargs-implicit-over-varargs.check new file mode 100644 index 0000000000..f25fa141d3 --- /dev/null +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs.check @@ -0,0 +1 @@ +WrappedArray(1, 2, 3, 4, 5)
diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs.flags b/test/files/run/macro-expand-varargs-implicit-over-varargs.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..8c609daa0e --- /dev/null +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Impls_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def myprintln(xs: Int*) = { + println(xs) + } + + def foo(c: Ctx)(xs: c.Expr[Int]*) = { + import c.mirror._ + val body = Apply(Select(Ident(newTermName("Impls")), newTermName("myprintln")), xs.map(_.tree).toList) + Expr[Unit](body) + } +} diff --git a/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala b/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala new file mode 100644 index 0000000000..2311ca0b95 --- /dev/null +++ b/test/files/run/macro-expand-varargs-implicit-over-varargs/Macros_Test_2.scala @@ -0,0 +1,7 @@ +object Macros { + def foo(xs: Int*) = macro Impls.foo +} + +object Test extends App { + Macros.foo(1, 2, 3, 4, 5) +}
\ No newline at end of file diff --git a/test/files/run/macro-impl-default-params.check b/test/files/run/macro-impl-default-params.check new file mode 100644 index 0000000000..eaf94458e6 --- /dev/null +++ b/test/files/run/macro-impl-default-params.check @@ -0,0 +1,5 @@ +foo_targs:
+invoking foo_targs...
+type of prefix is: Nothing
+type of prefix tree is: Macros[Int]
+U is: String
diff --git a/test/files/run/macro-impl-default-params.flags b/test/files/run/macro-impl-default-params.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-impl-default-params.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..cece1c09e4 --- /dev/null +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -0,0 +1,20 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo_targs[T, U: c.TypeTag](c: Ctx = null)(x: c.Expr[Int] = null) = { + import c.{prefix => prefix} + import c.mirror._ + val U = implicitly[c.TypeTag[U]] + val body = Block( + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo_targs...")))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix is: " + prefix.tpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("U is: " + U.tpe)))), + Literal(Constant(()))) + Expr[Unit](body) + } +} + +class Macros[T] { + def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U] +} diff --git a/test/files/run/macro-impl-default-params/Test_2.scala b/test/files/run/macro-impl-default-params/Test_2.scala new file mode 100644 index 0000000000..90e850df21 --- /dev/null +++ b/test/files/run/macro-impl-default-params/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println("foo_targs:") + new Macros[Int]().foo_targs[String](42) +}
\ No newline at end of file diff --git a/test/files/run/macro-impl-rename-context.check b/test/files/run/macro-impl-rename-context.check new file mode 100644 index 0000000000..753edcd970 --- /dev/null +++ b/test/files/run/macro-impl-rename-context.check @@ -0,0 +1,2 @@ +foo
+invoking foo...
diff --git a/test/files/run/macro-impl-rename-context.flags b/test/files/run/macro-impl-rename-context.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-impl-rename-context.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..000e351f4d --- /dev/null +++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala @@ -0,0 +1,15 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = { + import unconventionalName.mirror._ + val body = Block( + Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant("invoking foo...")))), + Literal(Constant(()))) + Expr[Unit](body) + } +} + +object Macros { + def foo(x: Int) = macro Impls.foo +} diff --git a/test/files/run/macro-impl-rename-context/Test_2.scala b/test/files/run/macro-impl-rename-context/Test_2.scala new file mode 100644 index 0000000000..bd9c493544 --- /dev/null +++ b/test/files/run/macro-impl-rename-context/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println("foo") + Macros.foo(42) +}
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.check b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.check new file mode 100644 index 0000000000..e21e05157a --- /dev/null +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.check @@ -0,0 +1,5 @@ +reflective compilation has failed:
+
+type mismatch; + found : String("42") + required: Int
diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..882867fcab --- /dev/null +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Impls_Macros_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx): c.Expr[Int] = { + import c.mirror._ + Literal(Constant("42")) + } +} + +object Macros { + def foo: Int = macro Impls.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala new file mode 100644 index 0000000000..f389231ca6 --- /dev/null +++ b/test/files/run/macro-invalidret-doesnt-conform-to-def-rettype/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Select(Ident("Macros"), newTermName("foo")) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +}
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check b/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check diff --git a/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags b/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable.check b/test/files/run/macro-invalidret-nontypeable.check new file mode 100644 index 0000000000..eee08528e2 --- /dev/null +++ b/test/files/run/macro-invalidret-nontypeable.check @@ -0,0 +1,3 @@ +reflective compilation has failed:
+
+not found: value IDoNotExist
diff --git a/test/files/run/macro-invalidret-nontypeable.flags b/test/files/run/macro-invalidret-nontypeable.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-invalidret-nontypeable.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala new file mode 100644 index 0000000000..f3a0476a35 --- /dev/null +++ b/test/files/run/macro-invalidret-nontypeable/Impls_Macros_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx) = { + import c.mirror._ + val body = Ident("IDoNotExist") + Expr[Int](body) + } +} + +object Macros { + def foo = macro Impls.foo +} diff --git a/test/files/run/macro-invalidret-nontypeable/Test_2.scala b/test/files/run/macro-invalidret-nontypeable/Test_2.scala new file mode 100644 index 0000000000..f389231ca6 --- /dev/null +++ b/test/files/run/macro-invalidret-nontypeable/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Select(Ident("Macros"), newTermName("foo")) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +}
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret.check b/test/files/run/macro-invalidusage-badret.check new file mode 100644 index 0000000000..5bdc484644 --- /dev/null +++ b/test/files/run/macro-invalidusage-badret.check @@ -0,0 +1,5 @@ +reflective compilation has failed:
+
+type mismatch; + found : Int(42) + required: String
diff --git a/test/files/run/macro-invalidusage-badret.flags b/test/files/run/macro-invalidusage-badret.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-invalidusage-badret.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala new file mode 100644 index 0000000000..c63ad01677 --- /dev/null +++ b/test/files/run/macro-invalidusage-badret/Impls_Macros_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = x +} + +object Macros { + def foo(x: Int) = macro Impls.foo +} diff --git a/test/files/run/macro-invalidusage-badret/Test_2.scala b/test/files/run/macro-invalidusage-badret/Test_2.scala new file mode 100644 index 0000000000..e171c9d05a --- /dev/null +++ b/test/files/run/macro-invalidusage-badret/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Typed(Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))), Ident(newTypeName("String"))) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +}
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-partialapplication.check b/test/files/run/macro-invalidusage-partialapplication.check new file mode 100644 index 0000000000..73f57b0b81 --- /dev/null +++ b/test/files/run/macro-invalidusage-partialapplication.check @@ -0,0 +1,3 @@ +reflective compilation has failed:
+
+macros cannot be partially applied
diff --git a/test/files/run/macro-invalidusage-partialapplication.flags b/test/files/run/macro-invalidusage-partialapplication.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-invalidusage-partialapplication.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala new file mode 100644 index 0000000000..449b91d074 --- /dev/null +++ b/test/files/run/macro-invalidusage-partialapplication/Impls_Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int])(y: c.Expr[Int]) = { + import c.mirror._ + val sum = Apply(Select(x.tree, newTermName("$plus")), List(y.tree)) + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(sum)) + Expr[Unit](body) + } +} + +object Macros { + def foo(x: Int)(y: Int) = macro Impls.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-partialapplication/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala new file mode 100644 index 0000000000..63371a4a82 --- /dev/null +++ b/test/files/run/macro-invalidusage-partialapplication/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(40)))) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +} diff --git a/test/files/run/macro-openmacros.check b/test/files/run/macro-openmacros.check new file mode 100644 index 0000000000..a4b06a1e1a --- /dev/null +++ b/test/files/run/macro-openmacros.check @@ -0,0 +1,3 @@ +List(MacroContext(foo@source-Test_2.scala,line-2,offset=35 +0))
+List(MacroContext(foo@source-Test_2.scala,line-2,offset=35 +1), MacroContext(foo@source-Test_2.scala,line-2,offset=35 +0))
+List(MacroContext(foo@source-Test_2.scala,line-2,offset=35 +2), MacroContext(foo@source-Test_2.scala,line-2,offset=35 +1), MacroContext(foo@source-Test_2.scala,line-2,offset=35 +0))
diff --git a/test/files/run/macro-openmacros.flags b/test/files/run/macro-openmacros.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-openmacros.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala new file mode 100644 index 0000000000..9fd658656e --- /dev/null +++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala @@ -0,0 +1,26 @@ +import scala.reflect.makro.Context + +object Macros { + 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 c.CompilationUnit(file, _, _) = c.enclosingUnit + val dir = file.getParentFile + def normalizePaths(s: String) = { + val base = (dir.getCanonicalPath + java.io.File.separator).replace('\\', '/') + var regex = """\Q%s\E""" format base + val isWin = System.getProperty("os.name", "") startsWith "Windows" + if (isWin) regex = "(?i)" + regex + s.replace('\\', '/').replaceAll(regex, "") + } + + import c.mirror._ + val next = if (c.enclosingMacros.length < 3) Expr[Unit](Select(Ident(staticModule("Macros")), newTermName("foo"))) else c.literalUnit + c.reify { + println(c.literal(normalizePaths(c.enclosingMacros.toString)).eval) + next.eval + } + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-openmacros/Test_2.scala b/test/files/run/macro-openmacros/Test_2.scala new file mode 100644 index 0000000000..5d19639cdd --- /dev/null +++ b/test/files/run/macro-openmacros/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo +} diff --git a/test/files/run/macro-quasiinvalidbody-c.check b/test/files/run/macro-quasiinvalidbody-c.check new file mode 100644 index 0000000000..f70d7bba4a --- /dev/null +++ b/test/files/run/macro-quasiinvalidbody-c.check @@ -0,0 +1 @@ +42
\ No newline at end of file diff --git a/test/files/run/macro-quasiinvalidbody-c.flags b/test/files/run/macro-quasiinvalidbody-c.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-quasiinvalidbody-c.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala b/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala new file mode 100644 index 0000000000..7cb810c86b --- /dev/null +++ b/test/files/run/macro-quasiinvalidbody-c/Impls_Macros_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + object Impls { + def foo(c: Ctx)(x: c.Expr[Any]) = x + } + + def foo(x: Any) = macro Impls.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-quasiinvalidbody-c/Test_2.scala b/test/files/run/macro-quasiinvalidbody-c/Test_2.scala new file mode 100644 index 0000000000..dec29aa857 --- /dev/null +++ b/test/files/run/macro-quasiinvalidbody-c/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + import Macros._ + println(foo(42)) +}
\ No newline at end of file diff --git a/test/files/run/macro-range/Common_1.scala b/test/files/run/macro-range/Common_1.scala new file mode 100644 index 0000000000..bd46e1f529 --- /dev/null +++ b/test/files/run/macro-range/Common_1.scala @@ -0,0 +1,48 @@ +import reflect.api.Modifier +import reflect.makro.Context + +abstract class RangeDefault { + val from, to: Int + def foreach(f: Int => Unit) = { + var i = from + while (i < to) { f(i); i += 1 } + } +} + +/** This class should go into reflect.macro once it is a bit more stable. */ +abstract class Utils { + val context: Context + import context.mirror._ + + class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer { + override def transform(tree: Tree): Tree = tree match { + case Ident(_) => + def subst(from: List[Symbol], to: List[Tree]): Tree = + if (from.isEmpty) tree + else if (tree.symbol == from.head) to.head.duplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`? + else subst(from.tail, to.tail); + subst(from, to) + case _ => + val tree1 = super.transform(tree) + if (tree1 ne tree) tree1.tpe = null + tree1 + } + } + def makeApply(fn: Tree, args: List[Tree]): Tree = fn match { + case Function(vparams, body) => + new TreeSubstituter(vparams map (_.symbol), args) transform body + case Block(stats, expr) => + Block(stats, makeApply(expr, args)) + case _ => + // todo. read the compiler config and print if -Ydebug is set + //println("no beta on "+fn+" "+fn.getClass) + Apply(fn, args) + } + def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = { + val continu = Apply(Ident(lname), Nil) + val rhs = If(cond, Block(List(body), continu), Literal(Constant())) + LabelDef(lname, Nil, rhs) + } + def makeBinop(left: Tree, op: String, right: Tree): Tree = + Apply(Select(left, newTermName(op)), List(right)) +} diff --git a/test/files/run/macro-range/Expansion_Impossible_2.scala b/test/files/run/macro-range/Expansion_Impossible_2.scala new file mode 100644 index 0000000000..7a093b74ee --- /dev/null +++ b/test/files/run/macro-range/Expansion_Impossible_2.scala @@ -0,0 +1,53 @@ +import reflect.api.Modifier +import reflect.makro.Context + +object Impls { + 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 } + import utils._ + import c.mirror._ + + val initName = newTermName("<init>") + // Either: + // scala"{ var i = $low; val h = $hi; while (i < h) { $f(i); i = i + 1 } } + // or: + // scala"($_this: RangeDefault).foreach($f)" + c.prefix.tree match { + case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => + val iname = newTermName("$i") + val hname = newTermName("$h") + def iref = Ident(iname) + def href = Ident(hname) + val labelname = newTermName("$while") + val cond = makeBinop(iref, "$less", href) + val body = Block( + List(makeApply(f, List(iref))), + Assign(iref, makeBinop(iref, "$plus", Literal(Constant(1))))) + val generated = + Block( + List( + ValDef(Modifiers(Set(Modifier.mutable)), iname, TypeTree(), lo), + ValDef(Modifiers(), hname, TypeTree(), hi)), + makeWhile(labelname, cond, body)) + // todo. read the compiler config and print if -Ydebug is set + //tools.nsc.util.trace("generated: ")(generated) + generated + case _ => + Apply( + Select( + Typed(c.prefix, Ident(newTypeName("RangeDefault"))), + newTermName("foreach")), + List(f)) + } + } +} + +class Range(val from: Int, val to: Int) extends RangeDefault { + override def foreach(f: Int => Unit): Unit = macro Impls.foreach +} + +object Test extends App { + new Range(1, 10) foreach println +}
\ No newline at end of file diff --git a/test/files/run/macro-range/Expansion_Possible_3.scala b/test/files/run/macro-range/Expansion_Possible_3.scala new file mode 100644 index 0000000000..e7ecbcc362 --- /dev/null +++ b/test/files/run/macro-range/Expansion_Possible_3.scala @@ -0,0 +1,7 @@ +class Range(val from: Int, val to: Int) extends RangeDefault { + override def foreach(f: Int => Unit): Unit = macro Impls.foreach +} + +object Test extends App { + new Range(1, 10) foreach println +}
\ No newline at end of file diff --git a/test/files/run/macro-range/macro_range_1.scala b/test/files/run/macro-range/macro_range_1.scala deleted file mode 100644 index fdfe7169ad..0000000000 --- a/test/files/run/macro-range/macro_range_1.scala +++ /dev/null @@ -1,99 +0,0 @@ -import reflect.api.Modifier -import reflect.macro.Context - -abstract class RangeDefault { - val from, to: Int - def foreach(f: Int => Unit) = { - var i = from - while (i < to) { f(i); i += 1 } - } -} - -/** This class should go into reflect.macro once it is a bit more stable. */ -abstract class Utils { - val context: Context - import context._ - - class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer { - override def transform(tree: Tree): Tree = tree match { - case Ident(_) => - def subst(from: List[Symbol], to: List[Tree]): Tree = - if (from.isEmpty) tree - else if (tree.symbol == from.head) to.head.duplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`? - else subst(from.tail, to.tail); - subst(from, to) - case _ => - val tree1 = super.transform(tree) - if (tree1 ne tree) tree1.tpe = null - tree1 - } - } - def makeApply(fn: Tree, args: List[Tree]): Tree = fn match { - case Function(vparams, body) => - new TreeSubstituter(vparams map (_.symbol), args) transform body - case Block(stats, expr) => - Block(stats, makeApply(expr, args)) - case _ => - // todo. read the compiler config and print if -Ydebug is set - //println("no beta on "+fn+" "+fn.getClass) - Apply(fn, args) - } - def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = { - val continu = Apply(Ident(lname), Nil) - val rhs = If(cond, Block(List(body), continu), Literal(Constant())) - LabelDef(lname, Nil, rhs) - } - def makeBinop(left: Tree, op: String, right: Tree): Tree = - Apply(Select(left, newTermName(op)), List(right)) -} - -class Range(val from: Int, val to: Int) extends RangeDefault { - override def macro foreach(f: Int => Unit): Unit = { - // todo. read the compiler config and print if -Ydebug is set - //println("macro-expand, _this = "+ _this) - import _context._ - object utils extends Utils { - val context: _context.type = _context - } - import utils._ - - val initName = newTermName("<init>") - // Either: - // scala"{ var i = $low; val h = $hi; while (i < h) { $f(i); i = i + 1 } } - // or: - // scala"($_this: RangeDefault).foreach($f)" - _this match { - case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => - val iname = newTermName("$i") - val hname = newTermName("$h") - def iref = Ident(iname) - def href = Ident(hname) - val labelname = newTermName("$while") - val cond = makeBinop(iref, "$less", href) - val body = Block( - List(makeApply(f, List(iref))), - Assign(iref, makeBinop(iref, "$plus", Literal(Constant(1))))) - val generated = - Block( - List( - ValDef(Modifiers(Set(Modifier.mutable)), iname, TypeTree(), lo), - ValDef(Modifiers(), hname, TypeTree(), hi)), - makeWhile(labelname, cond, body)) - // todo. read the compiler config and print if -Ydebug is set - //tools.nsc.util.trace("generated: ")(generated) - generated - case _ => - Apply( - Select( - Typed(_this, Ident(newTypeName("RangeDefault"))), - newTermName("foreach")), - List(f)) - } - } -} - -object Test extends App { - - new Range(1, 10) foreach println - -} diff --git a/test/files/run/macro-range/macro_range_2.scala b/test/files/run/macro-range/macro_range_2.scala deleted file mode 100644 index fdfe7169ad..0000000000 --- a/test/files/run/macro-range/macro_range_2.scala +++ /dev/null @@ -1,99 +0,0 @@ -import reflect.api.Modifier -import reflect.macro.Context - -abstract class RangeDefault { - val from, to: Int - def foreach(f: Int => Unit) = { - var i = from - while (i < to) { f(i); i += 1 } - } -} - -/** This class should go into reflect.macro once it is a bit more stable. */ -abstract class Utils { - val context: Context - import context._ - - class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer { - override def transform(tree: Tree): Tree = tree match { - case Ident(_) => - def subst(from: List[Symbol], to: List[Tree]): Tree = - if (from.isEmpty) tree - else if (tree.symbol == from.head) to.head.duplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`? - else subst(from.tail, to.tail); - subst(from, to) - case _ => - val tree1 = super.transform(tree) - if (tree1 ne tree) tree1.tpe = null - tree1 - } - } - def makeApply(fn: Tree, args: List[Tree]): Tree = fn match { - case Function(vparams, body) => - new TreeSubstituter(vparams map (_.symbol), args) transform body - case Block(stats, expr) => - Block(stats, makeApply(expr, args)) - case _ => - // todo. read the compiler config and print if -Ydebug is set - //println("no beta on "+fn+" "+fn.getClass) - Apply(fn, args) - } - def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = { - val continu = Apply(Ident(lname), Nil) - val rhs = If(cond, Block(List(body), continu), Literal(Constant())) - LabelDef(lname, Nil, rhs) - } - def makeBinop(left: Tree, op: String, right: Tree): Tree = - Apply(Select(left, newTermName(op)), List(right)) -} - -class Range(val from: Int, val to: Int) extends RangeDefault { - override def macro foreach(f: Int => Unit): Unit = { - // todo. read the compiler config and print if -Ydebug is set - //println("macro-expand, _this = "+ _this) - import _context._ - object utils extends Utils { - val context: _context.type = _context - } - import utils._ - - val initName = newTermName("<init>") - // Either: - // scala"{ var i = $low; val h = $hi; while (i < h) { $f(i); i = i + 1 } } - // or: - // scala"($_this: RangeDefault).foreach($f)" - _this match { - case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => - val iname = newTermName("$i") - val hname = newTermName("$h") - def iref = Ident(iname) - def href = Ident(hname) - val labelname = newTermName("$while") - val cond = makeBinop(iref, "$less", href) - val body = Block( - List(makeApply(f, List(iref))), - Assign(iref, makeBinop(iref, "$plus", Literal(Constant(1))))) - val generated = - Block( - List( - ValDef(Modifiers(Set(Modifier.mutable)), iname, TypeTree(), lo), - ValDef(Modifiers(), hname, TypeTree(), hi)), - makeWhile(labelname, cond, body)) - // todo. read the compiler config and print if -Ydebug is set - //tools.nsc.util.trace("generated: ")(generated) - generated - case _ => - Apply( - Select( - Typed(_this, Ident(newTypeName("RangeDefault"))), - newTermName("foreach")), - List(f)) - } - } -} - -object Test extends App { - - new Range(1, 10) foreach println - -} diff --git a/test/files/run/macro-reflective-ma-normal-mdmi.check b/test/files/run/macro-reflective-ma-normal-mdmi.check new file mode 100644 index 0000000000..ac4213d6e9 --- /dev/null +++ b/test/files/run/macro-reflective-ma-normal-mdmi.check @@ -0,0 +1 @@ +43
\ No newline at end of file diff --git a/test/files/run/macro-reflective-ma-normal-mdmi.flags b/test/files/run/macro-reflective-ma-normal-mdmi.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reflective-ma-normal-mdmi.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..f6caf89dca --- /dev/null +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Impls_Macros_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr[Int](body) + } +} + +object Macros { + def foo(x: Int) = macro Impls.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala new file mode 100644 index 0000000000..3c594aed75 --- /dev/null +++ b/test/files/run/macro-reflective-ma-normal-mdmi/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) + println(tree.eval) +} diff --git a/test/files/run/macro-reflective-mamd-normal-mi.check b/test/files/run/macro-reflective-mamd-normal-mi.check new file mode 100644 index 0000000000..ac4213d6e9 --- /dev/null +++ b/test/files/run/macro-reflective-mamd-normal-mi.check @@ -0,0 +1 @@ +43
\ No newline at end of file diff --git a/test/files/run/macro-reflective-mamd-normal-mi.flags b/test/files/run/macro-reflective-mamd-normal-mi.flags new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/macro-reflective-mamd-normal-mi.flags 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 new file mode 100644 index 0000000000..dc7d42d23e --- /dev/null +++ b/test/files/run/macro-reflective-mamd-normal-mi/Impls_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = { + import c.mirror._ + val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + Expr[Int](body) + } +} diff --git a/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala new file mode 100644 index 0000000000..7cbe425fc8 --- /dev/null +++ b/test/files/run/macro-reflective-mamd-normal-mi/Macros_Test_2.scala @@ -0,0 +1,16 @@ +//object Macros { +// def foo(x: Int) = macro Impls.foo +//} + +object Test extends App { + import scala.reflect.mirror._ + + val macrobody = Select(Ident(newTermName("Impls")), newTermName("foo")) + val macroparam = ValDef(NoMods, newTermName("x"), TypeTree(definitions.IntClass.asType), EmptyTree) + val macrodef = DefDef(Modifiers(Set(scala.reflect.api.Modifier.`macro`)), newTermName("foo"), Nil, List(List(macroparam)), TypeTree(), macrobody) + val modulector = DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(List()), TypeTree(), Block(Apply(Select(Super(This(EmptyTypeName), EmptyTypeName), nme.CONSTRUCTOR), List()))) + val module = ModuleDef(NoMods, newTermName("Macros"), Template(Nil, emptyValDef, List(modulector, macrodef))) + val macroapp = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) + val tree = Block(macrodef, module, macroapp) + println(tree.eval) +} diff --git a/test/files/run/macro-reify-basic.check b/test/files/run/macro-reify-basic.check new file mode 100644 index 0000000000..f35d3e67b4 --- /dev/null +++ b/test/files/run/macro-reify-basic.check @@ -0,0 +1 @@ +hello world
diff --git a/test/files/run/macro-reify-basic.flags b/test/files/run/macro-reify-basic.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-basic.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-reify-basic/Macros_1.scala b/test/files/run/macro-reify-basic/Macros_1.scala new file mode 100644 index 0000000000..b2243d131c --- /dev/null +++ b/test/files/run/macro-reify-basic/Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def foo(s: String) = macro Impls.foo + + object Impls { + def foo(c: Ctx)(s: c.Expr[String]) = c.reify { + println("hello " + s.eval) + } + } +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-basic/Test_2.scala b/test/files/run/macro-reify-basic/Test_2.scala new file mode 100644 index 0000000000..0a762f7ad7 --- /dev/null +++ b/test/files/run/macro-reify-basic/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo("world") +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-eval.check b/test/files/run/macro-reify-eval-eval.check new file mode 100644 index 0000000000..f35d3e67b4 --- /dev/null +++ b/test/files/run/macro-reify-eval-eval.check @@ -0,0 +1 @@ +hello world
diff --git a/test/files/run/macro-reify-eval-eval.flags b/test/files/run/macro-reify-eval-eval.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-eval-eval.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-eval/Macros_1.scala b/test/files/run/macro-reify-eval-eval/Macros_1.scala new file mode 100644 index 0000000000..6b8ac94f0e --- /dev/null +++ b/test/files/run/macro-reify-eval-eval/Macros_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.makro.{Context => Ctx} +import scala.reflect.{mirror => mr} + +object Macros { + def foo = macro Impls.foo + + object Impls { + def foo(c: Ctx) = c.reify { + { c.reify(c.reify("hello world")) }.eval.eval + } + } +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-eval/Test_2.scala b/test/files/run/macro-reify-eval-eval/Test_2.scala new file mode 100644 index 0000000000..f697da6020 --- /dev/null +++ b/test/files/run/macro-reify-eval-eval/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(Macros.foo) +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-outside-reify.check b/test/files/run/macro-reify-eval-outside-reify.check new file mode 100644 index 0000000000..2f562a182f --- /dev/null +++ b/test/files/run/macro-reify-eval-outside-reify.check @@ -0,0 +1 @@ +42
diff --git a/test/files/run/macro-reify-eval-outside-reify.flags b/test/files/run/macro-reify-eval-outside-reify.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-eval-outside-reify.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala new file mode 100644 index 0000000000..13b603d610 --- /dev/null +++ b/test/files/run/macro-reify-eval-outside-reify/Impls_Macros_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = c.literal(x.eval) +} + +object Macros { + def foo(x: Int) = macro Impls.foo +} diff --git a/test/files/run/macro-reify-eval-outside-reify/Test_2.scala b/test/files/run/macro-reify-eval-outside-reify/Test_2.scala new file mode 100644 index 0000000000..3c594aed75 --- /dev/null +++ b/test/files/run/macro-reify-eval-outside-reify/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) + println(tree.eval) +} diff --git a/test/files/run/macro-reify-freevars.check b/test/files/run/macro-reify-freevars.check new file mode 100644 index 0000000000..02a6a7436b --- /dev/null +++ b/test/files/run/macro-reify-freevars.check @@ -0,0 +1,3 @@ +reflective compilation has failed:
+
+macro expansion contains free term variable code defined by map in Macros_1.scala:8:9. have you forgot to use eval when splicing this variable into a reifee? if you have troubles tracking free term variables, consider using -Xlog-free-terms
diff --git a/test/files/run/macro-reify-freevars.flags b/test/files/run/macro-reify-freevars.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-freevars.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-reify-freevars/Macros_1.scala b/test/files/run/macro-reify-freevars/Macros_1.scala new file mode 100644 index 0000000000..3cc559a0af --- /dev/null +++ b/test/files/run/macro-reify-freevars/Macros_1.scala @@ -0,0 +1,19 @@ +package scala.collection.slick +object QueryableMacros{ + def map[T:c.TypeTag, S:c.TypeTag] + (c: scala.reflect.makro.Context) + (projection: c.mirror.Expr[T => S]) + : c.mirror.Expr[scala.collection.slick.Queryable[S]] = { + import c.mirror._ + val code = EmptyTree + c.reify{ + Queryable.factory[S]( code.asInstanceOf[reflect.mirror.Tree] ) + } + } +} +class Queryable[T]{ + def map[S]( projection: T => S ) : Queryable[S] = macro QueryableMacros.map[T,S] +} +object Queryable{ + def factory[S]( projection:scala.reflect.mirror.Tree ) : Queryable[S] = null +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-freevars/Test_2.scala b/test/files/run/macro-reify-freevars/Test_2.scala new file mode 100644 index 0000000000..55c677155a --- /dev/null +++ b/test/files/run/macro-reify-freevars/Test_2.scala @@ -0,0 +1,9 @@ +object Test extends App { + import scala.reflect.mirror._ + val q = New(AppliedTypeTree(Select(Select(Select(Ident("scala"), newTermName("collection")), newTermName("slick")), newTypeName("Queryable")), List(Ident("Int")))) + val x = ValDef(NoMods, newTermName("x"), Ident("Int"), EmptyTree) + val fn = Function(List(x), Apply(Select(Ident(newTermName("x")), newTermName("$plus")), List(Literal(Constant("5"))))) + val tree = Apply(Select(q, newTermName("map")), List(fn)) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-groundtypetag-notypeparams.check b/test/files/run/macro-reify-groundtypetag-notypeparams.check new file mode 100644 index 0000000000..d75b3c72b2 --- /dev/null +++ b/test/files/run/macro-reify-groundtypetag-notypeparams.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-groundtypetag-notypeparams/Test.scala b/test/files/run/macro-reify-groundtypetag-notypeparams/Test.scala new file mode 100644 index 0000000000..d2f8fab5ec --- /dev/null +++ b/test/files/run/macro-reify-groundtypetag-notypeparams/Test.scala @@ -0,0 +1,6 @@ +import scala.reflect.mirror._ + +object Test extends App { + println(implicitly[ConcreteTypeTag[Int]]) + println(implicitly[ConcreteTypeTag[List[Int]]]) +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-groundtypetag-typeparams-tags.check b/test/files/run/macro-reify-groundtypetag-typeparams-tags.check new file mode 100644 index 0000000000..d75b3c72b2 --- /dev/null +++ b/test/files/run/macro-reify-groundtypetag-typeparams-tags.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-groundtypetag-typeparams-tags/Test.scala b/test/files/run/macro-reify-groundtypetag-typeparams-tags/Test.scala new file mode 100644 index 0000000000..6d7eab5f9a --- /dev/null +++ b/test/files/run/macro-reify-groundtypetag-typeparams-tags/Test.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test extends App { + def fooTypeTag[T: ConcreteTypeTag] = { + println(implicitly[ConcreteTypeTag[T]]) + println(implicitly[ConcreteTypeTag[List[T]]]) + } + fooTypeTag[Int] +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-a.check b/test/files/run/macro-reify-nested-a.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/macro-reify-nested-a.check diff --git a/test/files/run/macro-reify-nested-a.flags b/test/files/run/macro-reify-nested-a.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-nested-a.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..1ce8f44671 --- /dev/null +++ b/test/files/run/macro-reify-nested-a/Impls_Macros_1.scala @@ -0,0 +1,43 @@ +import scala.reflect.makro.Context + +case class Utils[C <: Context]( c:C ) { + import c.mirror._ + import c.{Tree=>_} + object removeDoubleReify extends c.mirror.Transformer { + def apply( tree:Tree ) = transform(tree) + override def transform(tree: Tree): Tree = { + super.transform { + tree match { + case Apply(TypeApply(Select(_this, termname), _), reified::Nil ) + if termname.toString == "factory" => c.unreifyTree(reified) + case Apply(Select(_this, termname), reified::Nil ) + if termname.toString == "factory" => c.unreifyTree(reified) + case _ => tree + } + } + } + } +} +object QueryableMacros{ + def _helper[C <: Context,S:c.TypeTag]( c:C )( name:String, projection:c.mirror.Expr[_] ) = { + import c.mirror._ + val element_type = implicitly[c.TypeTag[S]].tpe + val foo = Expr[reflect.mirror.Expr[Queryable[S]]]( + c.reifyTree( c.reflectMirrorPrefix, c.typeCheck( + Utils[c.type](c).removeDoubleReify( + Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree )) + ).asInstanceOf[Tree] + ))) + c.reify{ Queryable.factory[S]( foo.eval )} + } + def map[T:c.TypeTag, S:c.TypeTag] + (c: scala.reflect.makro.Context) + (projection: c.mirror.Expr[T => S]): c.mirror.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) +} +class Queryable[T]{ + def _map[S]( projection: T => S ) : Queryable[S] = ??? + def map[S]( projection: T => S ) : Queryable[S] = macro QueryableMacros.map[T,S] +} +object Queryable{ + def factory[S]( projection:scala.reflect.mirror.Expr[Queryable[S]] ) : Queryable[S] = null +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-a/Test_2.scala b/test/files/run/macro-reify-nested-a/Test_2.scala new file mode 100644 index 0000000000..fa0eb378af --- /dev/null +++ b/test/files/run/macro-reify-nested-a/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App{ + val q : Queryable[Any] = new Queryable[Any] + q.map(e1 => q.map(e2=>e1)) +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-b.check b/test/files/run/macro-reify-nested-b.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/macro-reify-nested-b.check diff --git a/test/files/run/macro-reify-nested-b.flags b/test/files/run/macro-reify-nested-b.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-nested-b.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..1ce8f44671 --- /dev/null +++ b/test/files/run/macro-reify-nested-b/Impls_Macros_1.scala @@ -0,0 +1,43 @@ +import scala.reflect.makro.Context + +case class Utils[C <: Context]( c:C ) { + import c.mirror._ + import c.{Tree=>_} + object removeDoubleReify extends c.mirror.Transformer { + def apply( tree:Tree ) = transform(tree) + override def transform(tree: Tree): Tree = { + super.transform { + tree match { + case Apply(TypeApply(Select(_this, termname), _), reified::Nil ) + if termname.toString == "factory" => c.unreifyTree(reified) + case Apply(Select(_this, termname), reified::Nil ) + if termname.toString == "factory" => c.unreifyTree(reified) + case _ => tree + } + } + } + } +} +object QueryableMacros{ + def _helper[C <: Context,S:c.TypeTag]( c:C )( name:String, projection:c.mirror.Expr[_] ) = { + import c.mirror._ + val element_type = implicitly[c.TypeTag[S]].tpe + val foo = Expr[reflect.mirror.Expr[Queryable[S]]]( + c.reifyTree( c.reflectMirrorPrefix, c.typeCheck( + Utils[c.type](c).removeDoubleReify( + Apply(Select(c.prefix.tree, newTermName( name )), List( projection.tree )) + ).asInstanceOf[Tree] + ))) + c.reify{ Queryable.factory[S]( foo.eval )} + } + def map[T:c.TypeTag, S:c.TypeTag] + (c: scala.reflect.makro.Context) + (projection: c.mirror.Expr[T => S]): c.mirror.Expr[Queryable[S]] = _helper[c.type,S]( c )( "_map", projection ) +} +class Queryable[T]{ + def _map[S]( projection: T => S ) : Queryable[S] = ??? + def map[S]( projection: T => S ) : Queryable[S] = macro QueryableMacros.map[T,S] +} +object Queryable{ + def factory[S]( projection:scala.reflect.mirror.Expr[Queryable[S]] ) : Queryable[S] = null +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-nested-b/Test_2.scala b/test/files/run/macro-reify-nested-b/Test_2.scala new file mode 100644 index 0000000000..fa13f57ffb --- /dev/null +++ b/test/files/run/macro-reify-nested-b/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App{ + val q : Queryable[Any] = new Queryable[Any] + q.map(e1 => q.map(e2=>e1).map(e2=>e1)) +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-ref-to-packageless.check b/test/files/run/macro-reify-ref-to-packageless.check new file mode 100644 index 0000000000..2f562a182f --- /dev/null +++ b/test/files/run/macro-reify-ref-to-packageless.check @@ -0,0 +1 @@ +42
diff --git a/test/files/run/macro-reify-ref-to-packageless.flags b/test/files/run/macro-reify-ref-to-packageless.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-ref-to-packageless.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..2f2d05678d --- /dev/null +++ b/test/files/run/macro-reify-ref-to-packageless/Impls_1.scala @@ -0,0 +1,6 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + val `Answer to the Ultimate Question of Life, the Universe, and Everything` = 42 + def foo(c: Ctx) = c.reify { `Answer to the Ultimate Question of Life, the Universe, and Everything` } +} diff --git a/test/files/run/macro-reify-ref-to-packageless/Test_2.scala b/test/files/run/macro-reify-ref-to-packageless/Test_2.scala new file mode 100644 index 0000000000..9d475f756d --- /dev/null +++ b/test/files/run/macro-reify-ref-to-packageless/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def foo = macro Impls.foo + println(foo) +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagful-a.check b/test/files/run/macro-reify-tagful-a.check new file mode 100644 index 0000000000..8a701df6a5 --- /dev/null +++ b/test/files/run/macro-reify-tagful-a.check @@ -0,0 +1 @@ +List(hello world)
diff --git a/test/files/run/macro-reify-tagful-a.flags b/test/files/run/macro-reify-tagful-a.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-tagful-a.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagful-a/Macros_1.scala b/test/files/run/macro-reify-tagful-a/Macros_1.scala new file mode 100644 index 0000000000..2ff12091a1 --- /dev/null +++ b/test/files/run/macro-reify-tagful-a/Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def foo[T](s: T) = macro Impls.foo[T] + + object Impls { + def foo[T: c.TypeTag](c: Ctx)(s: c.Expr[T]) = c.reify { + List(s.eval) + } + } +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagful-a/Test_2.scala b/test/files/run/macro-reify-tagful-a/Test_2.scala new file mode 100644 index 0000000000..4d27166341 --- /dev/null +++ b/test/files/run/macro-reify-tagful-a/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val list: List[String] = Macros.foo("hello world") + println(list) +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagless-a.check b/test/files/run/macro-reify-tagless-a.check new file mode 100644 index 0000000000..b58cff19bc --- /dev/null +++ b/test/files/run/macro-reify-tagless-a.check @@ -0,0 +1,3 @@ +reflective compilation has failed:
+
+macro expansion contains free type variable T defined by foo in Impls_Macros_1.scala:7:13. have you forgot to use c.TypeTag annotation for this type parameter? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/macro-reify-tagless-a.flags b/test/files/run/macro-reify-tagless-a.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-tagless-a.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file 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 new file mode 100644 index 0000000000..45e39d7d1c --- /dev/null +++ b/test/files/run/macro-reify-tagless-a/Impls_Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def foo[T](s: T) = macro Impls.foo[T] + + object Impls { + def foo[T](c: Ctx)(s: c.Expr[T]) = c.reify { + List[T](s.eval) + } + } +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-tagless-a/Test_2.scala b/test/files/run/macro-reify-tagless-a/Test_2.scala new file mode 100644 index 0000000000..d996da1570 --- /dev/null +++ b/test/files/run/macro-reify-tagless-a/Test_2.scala @@ -0,0 +1,12 @@ +object Test extends App { + //val list: List[String] = Macros.foo("hello world") + //println(list) + + import scala.reflect.mirror._ + val tpt = AppliedTypeTree(Ident(definitions.ListClass), List(Ident(definitions.StringClass))) + val rhs = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant("hello world")))) + val list = ValDef(NoMods, newTermName("list"), tpt, rhs) + val tree = Block(list, Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Ident(list.name)))) + try tree.eval + catch { case ex: Throwable => println(ex.getMessage) } +} diff --git a/test/files/run/macro-reify-typetag-notypeparams.check b/test/files/run/macro-reify-typetag-notypeparams.check new file mode 100644 index 0000000000..d75b3c72b2 --- /dev/null +++ b/test/files/run/macro-reify-typetag-notypeparams.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-typetag-notypeparams/Test.scala b/test/files/run/macro-reify-typetag-notypeparams/Test.scala new file mode 100644 index 0000000000..041a44273d --- /dev/null +++ b/test/files/run/macro-reify-typetag-notypeparams/Test.scala @@ -0,0 +1,6 @@ +import scala.reflect.mirror._ + +object Test extends App { + println(implicitly[TypeTag[Int]]) + println(implicitly[TypeTag[List[Int]]]) +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-typetag-typeparams-notags.check b/test/files/run/macro-reify-typetag-typeparams-notags.check new file mode 100644 index 0000000000..af4877e205 --- /dev/null +++ b/test/files/run/macro-reify-typetag-typeparams-notags.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[T]
+ConcreteTypeTag[List[T]]
diff --git a/test/files/run/macro-reify-typetag-typeparams-notags/Test.scala b/test/files/run/macro-reify-typetag-typeparams-notags/Test.scala new file mode 100644 index 0000000000..a89499e7fe --- /dev/null +++ b/test/files/run/macro-reify-typetag-typeparams-notags/Test.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test extends App { + def fooNoTypeTag[T] = { + println(implicitly[TypeTag[T]]) + println(implicitly[TypeTag[List[T]]]) + } + fooNoTypeTag[Int] +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-typetag-typeparams-tags.check b/test/files/run/macro-reify-typetag-typeparams-tags.check new file mode 100644 index 0000000000..d75b3c72b2 --- /dev/null +++ b/test/files/run/macro-reify-typetag-typeparams-tags.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-typetag-typeparams-tags/Test.scala b/test/files/run/macro-reify-typetag-typeparams-tags/Test.scala new file mode 100644 index 0000000000..b32680a4b8 --- /dev/null +++ b/test/files/run/macro-reify-typetag-typeparams-tags/Test.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test extends App { + def fooTypeTag[T: TypeTag] = { + println(implicitly[TypeTag[T]]) + println(implicitly[TypeTag[List[T]]]) + } + fooTypeTag[Int] +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-typetag-usegroundtypetag.check b/test/files/run/macro-reify-typetag-usegroundtypetag.check new file mode 100644 index 0000000000..d75b3c72b2 --- /dev/null +++ b/test/files/run/macro-reify-typetag-usegroundtypetag.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[List[Int]]
diff --git a/test/files/run/macro-reify-typetag-usegroundtypetag/Test.scala b/test/files/run/macro-reify-typetag-usegroundtypetag/Test.scala new file mode 100644 index 0000000000..de235f51cc --- /dev/null +++ b/test/files/run/macro-reify-typetag-usegroundtypetag/Test.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test extends App { + def fooTypeTag[T: ConcreteTypeTag] = { + println(implicitly[TypeTag[T]]) + println(implicitly[TypeTag[List[T]]]) + } + fooTypeTag[Int] +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-unreify.check b/test/files/run/macro-reify-unreify.check new file mode 100644 index 0000000000..a5334cc355 --- /dev/null +++ b/test/files/run/macro-reify-unreify.check @@ -0,0 +1 @@ +hello world = Expr[String("hello world")]("hello world")
diff --git a/test/files/run/macro-reify-unreify.flags b/test/files/run/macro-reify-unreify.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-unreify.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-reify-unreify/Macros_1.scala b/test/files/run/macro-reify-unreify/Macros_1.scala new file mode 100644 index 0000000000..1b0b9c6421 --- /dev/null +++ b/test/files/run/macro-reify-unreify/Macros_1.scala @@ -0,0 +1,19 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def foo(s: String) = macro Impls.foo + + object Impls { + def foo(c: Ctx)(s: c.Expr[String]) = { + import c.mirror._ + + val world = c.reifyTree(c.reflectMirrorPrefix, s.tree) + val greeting = c.reifyTree(c.reflectMirrorPrefix, c.typeCheck(Apply(Select(Literal(Constant("hello ")), newTermName("$plus")), List(c.unreifyTree(world))))) + val typedGreeting = Expr[String](greeting) + + c.reify { + println("hello " + s.eval + " = " + typedGreeting.eval) + } + } + } +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-unreify/Test_2.scala b/test/files/run/macro-reify-unreify/Test_2.scala new file mode 100644 index 0000000000..0a762f7ad7 --- /dev/null +++ b/test/files/run/macro-reify-unreify/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo("world") +}
\ No newline at end of file diff --git a/test/files/run/macro-reify-value-outside-reify.check b/test/files/run/macro-reify-value-outside-reify.check new file mode 100644 index 0000000000..2f562a182f --- /dev/null +++ b/test/files/run/macro-reify-value-outside-reify.check @@ -0,0 +1 @@ +42
diff --git a/test/files/run/macro-reify-value-outside-reify.flags b/test/files/run/macro-reify-value-outside-reify.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-reify-value-outside-reify.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala new file mode 100644 index 0000000000..28ec1ace67 --- /dev/null +++ b/test/files/run/macro-reify-value-outside-reify/Impls_Macros_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo(c: Ctx)(x: c.Expr[Int]) = c.literal(x.value) +} + +object Macros { + def foo(x: Int) = macro Impls.foo +} diff --git a/test/files/run/macro-reify-value-outside-reify/Test_2.scala b/test/files/run/macro-reify-value-outside-reify/Test_2.scala new file mode 100644 index 0000000000..8225eb0b39 --- /dev/null +++ b/test/files/run/macro-reify-value-outside-reify/Test_2.scala @@ -0,0 +1,6 @@ +object Test extends App { + import scala.reflect.mirror._ + val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(42)))) + try println(tree.eval) + catch { case ex: Throwable => println(ex.getMessage) } +} diff --git a/test/files/run/macro-repl-basic.check b/test/files/run/macro-repl-basic.check index f8f0d3ad29..3bc899f49b 100644 --- a/test/files/run/macro-repl-basic.check +++ b/test/files/run/macro-repl-basic.check @@ -3,13 +3,39 @@ Type :help for more information. scala>
+scala> import scala.reflect.makro.{Context => Ctx}
+import scala.reflect.makro.{Context=>Ctx}
+
+scala>
+
+scala> object Impls {
+ def foo(c: Ctx)(x: c.Expr[Int]) = {
+ import c.mirror._
+ val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1))))
+ Expr[Int](body)
+ }
+
+ def bar(c: Ctx)(x: c.Expr[Int]) = {
+ import c.mirror._
+ val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2))))
+ Expr[Int](body)
+ }
+
+ def quux(c: Ctx)(x: c.Expr[Int]) = {
+ import c.mirror._
+ val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3))))
+ Expr[Int](body)
+ }
+}
+defined module Impls
+
scala> object Macros {
object Shmacros {
- def macro foo(x: Int): Int = x
+ def foo(x: Int): Int = macro Impls.foo
}
- def macro bar(x: Int): Int = x
+ def bar(x: Int): Int = macro Impls.bar
}; class Macros {
- def macro quux(x: Int): Int = x
+ def quux(x: Int): Int = macro Impls.quux
}
defined module Macros
defined class Macros
@@ -20,6 +46,6 @@ scala> import Macros.Shmacros._ import Macros.Shmacros._
scala> println(foo(2) + Macros.bar(2) * new Macros().quux(4))
-10
+31
scala>
diff --git a/test/files/run/macro-repl-basic.scala b/test/files/run/macro-repl-basic.scala index 9b1a53343b..a21eb7815f 100644 --- a/test/files/run/macro-repl-basic.scala +++ b/test/files/run/macro-repl-basic.scala @@ -3,13 +3,34 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { override def extraSettings = "-Xmacros" def code = """ + |import scala.reflect.makro.{Context => Ctx} + | + |object Impls { + | def foo(c: Ctx)(x: c.Expr[Int]) = { + | import c.mirror._ + | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(1)))) + | Expr[Int](body) + | } + | + | def bar(c: Ctx)(x: c.Expr[Int]) = { + | import c.mirror._ + | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(2)))) + | Expr[Int](body) + | } + | + | def quux(c: Ctx)(x: c.Expr[Int]) = { + | import c.mirror._ + | val body = Apply(Select(x.tree, newTermName("$plus")), List(Literal(Constant(3)))) + | Expr[Int](body) + | } + |} |object Macros { | object Shmacros { - | def macro foo(x: Int): Int = x + | def foo(x: Int): Int = macro Impls.foo | } - | def macro bar(x: Int): Int = x + | def bar(x: Int): Int = macro Impls.bar |}; class Macros { - | def macro quux(x: Int): Int = x + | def quux(x: Int): Int = macro Impls.quux |} | |import Macros.Shmacros._ diff --git a/test/files/run/macro-repl-dontexpand.check b/test/files/run/macro-repl-dontexpand.check index d2bb89b6f7..35845f0cff 100644 --- a/test/files/run/macro-repl-dontexpand.check +++ b/test/files/run/macro-repl-dontexpand.check @@ -3,7 +3,10 @@ Type :help for more information. scala>
-scala> def macro foo = ???
+scala> def bar(c: scala.reflect.makro.Context) = ???
+bar: (c: scala.reflect.makro.Context)Nothing
+
+scala> def foo = macro bar
foo: Any
scala>
diff --git a/test/files/run/macro-repl-dontexpand.scala b/test/files/run/macro-repl-dontexpand.scala index 254bce894c..9889a8ffdf 100644 --- a/test/files/run/macro-repl-dontexpand.scala +++ b/test/files/run/macro-repl-dontexpand.scala @@ -3,6 +3,7 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { override def extraSettings = "-Xmacros" def code = """ - |def macro foo = ??? + |def bar(c: scala.reflect.makro.Context) = ??? + |def foo = macro bar |""".stripMargin }
\ No newline at end of file diff --git a/test/files/run/macro-rettype-mismatch/Macros_1.scala b/test/files/run/macro-rettype-mismatch/Macros_1.scala deleted file mode 100644 index 64e5b93468..0000000000 --- a/test/files/run/macro-rettype-mismatch/Macros_1.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Macros { - def macro foo(x: Int): String = x -}
\ No newline at end of file diff --git a/test/files/run/macro-rettype-mismatch/Test_2.scala b/test/files/run/macro-rettype-mismatch/Test_2.scala deleted file mode 100644 index 39a7c7ad1a..0000000000 --- a/test/files/run/macro-rettype-mismatch/Test_2.scala +++ /dev/null @@ -1,16 +0,0 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - -object Test extends App { - import scala.reflect.mirror._ - val tree = Apply(Select(Ident("Macros"), newTermName("foo")), List(Literal(Constant(2)))) - - val stderr = new java.io.ByteArrayOutputStream() - Console.setErr(new java.io.PrintStream(stderr)) - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - try { toolbox.runExpr(tree) } - catch { case ex: Throwable => println(stderr); println(ex) } -} diff --git a/test/files/run/macro-settings.check b/test/files/run/macro-settings.check new file mode 100644 index 0000000000..33784d1c15 --- /dev/null +++ b/test/files/run/macro-settings.check @@ -0,0 +1 @@ +List(hello=1)
diff --git a/test/files/run/macro-settings.flags b/test/files/run/macro-settings.flags new file mode 100644 index 0000000000..cdc7512197 --- /dev/null +++ b/test/files/run/macro-settings.flags @@ -0,0 +1 @@ +-Xmacros -Xmacro-settings:hello=1
\ No newline at end of file diff --git a/test/files/run/macro-settings/Impls_Macros_1.scala b/test/files/run/macro-settings/Impls_Macros_1.scala new file mode 100644 index 0000000000..8c7254c79a --- /dev/null +++ b/test/files/run/macro-settings/Impls_Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.Context + +object Impls { + def impl(c: Context) = c.reify { + println(c.literal(c.settings.toString).eval) + } +} + +object Macros { + def foo = macro Impls.impl +}
\ No newline at end of file diff --git a/test/files/run/macro-settings/Test_2.scala b/test/files/run/macro-settings/Test_2.scala new file mode 100644 index 0000000000..acfddae942 --- /dev/null +++ b/test/files/run/macro-settings/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo +}
\ No newline at end of file diff --git a/test/files/run/macro-sip19-revised.check b/test/files/run/macro-sip19-revised.check new file mode 100644 index 0000000000..aa2fbd11d3 --- /dev/null +++ b/test/files/run/macro-sip19-revised.check @@ -0,0 +1,5 @@ +hey, i've been called from SourceLocation1(null,Test_2.scala,11,251)
+hey, i've been called from SourceLocation1(SourceLocation1(null,Test_2.scala,11,251),Test_2.scala,8,222)
+hey, i've been called from SourceLocation1(SourceLocation1(SourceLocation1(null,Test_2.scala,11,251),Test_2.scala,8,222),Test_2.scala,8,222)
+hey, i've been called from SourceLocation1(SourceLocation1(SourceLocation1(SourceLocation1(null,Test_2.scala,11,251),Test_2.scala,8,222),Test_2.scala,8,222),Test_2.scala,6,180)
+2
diff --git a/test/files/run/macro-sip19-revised.flags b/test/files/run/macro-sip19-revised.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-sip19-revised.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala new file mode 100644 index 0000000000..e8f6e1df85 --- /dev/null +++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala @@ -0,0 +1,34 @@ +import scala.reflect.makro.Context + +object Macros { + def impl(c: Context) = { + import c.mirror._ + + val inscope = c.inferImplicitValue(staticClass("SourceLocation").asType) + val outer = Expr[SourceLocation](if (!inscope.isEmpty) inscope else Literal(Constant(null))) + + val Apply(fun, args) = c.enclosingImplicits(0)._2 + val fileName = fun.pos.fileInfo.getName + val line = fun.pos.line + val charOffset = fun.pos.point + c.reify { SourceLocation1(outer.eval, c.literal(fileName).eval, c.literal(line).eval, c.literal(charOffset).eval) } + } + + implicit def sourceLocation: SourceLocation1 = macro impl +} + +trait SourceLocation { + /** Source location of the outermost call */ + val outer: SourceLocation + + /** The name of the source file */ + val fileName: String + + /** The line number */ + val line: Int + + /** The character offset */ + val charOffset: Int +} + +case class SourceLocation1(val outer: SourceLocation, val fileName: String, val line: Int, val charOffset: Int) extends SourceLocation diff --git a/test/files/run/macro-sip19-revised/Test_2.scala b/test/files/run/macro-sip19-revised/Test_2.scala new file mode 100644 index 0000000000..d9a4d7d4fc --- /dev/null +++ b/test/files/run/macro-sip19-revised/Test_2.scala @@ -0,0 +1,12 @@ +import Macros._ + +object Test extends App { + def foo(x: Int, y: Int)(implicit loc: SourceLocation): Int = { + println("hey, i've been called from %s".format(loc)) + if (x < y) foo(y, x) + else if (y == 0) x + else foo(x - y, y) + } + + println(foo(4, 2)) +} diff --git a/test/files/run/macro-sip19.check b/test/files/run/macro-sip19.check new file mode 100644 index 0000000000..6b317ccb47 --- /dev/null +++ b/test/files/run/macro-sip19.check @@ -0,0 +1,5 @@ +hey, i've been called from SourceLocation(Test_2.scala,15,366)
+hey, i've been called from SourceLocation(Test_2.scala,11,331)
+hey, i've been called from SourceLocation(Test_2.scala,11,331)
+hey, i've been called from SourceLocation(Test_2.scala,9,285)
+2
diff --git a/test/files/run/macro-sip19.flags b/test/files/run/macro-sip19.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-sip19.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala new file mode 100644 index 0000000000..39b29ad64c --- /dev/null +++ b/test/files/run/macro-sip19/Impls_Macros_1.scala @@ -0,0 +1,25 @@ +import scala.reflect.makro.Context + +object Macros { + def impl(c: Context) = { + import c.mirror._ + val Apply(fun, args) = c.enclosingImplicits(0)._2 + val fileName = fun.pos.fileInfo.getName + val line = fun.pos.line + val charOffset = fun.pos.point + c.reify { SourceLocation(c.literal(fileName).eval, c.literal(line).eval, c.literal(charOffset).eval) } + } + + implicit def sourceLocation: SourceLocation = macro impl +} + +case class SourceLocation( + /** The name of the source file */ + val fileName: String, + + /** The line number */ + val line: Int, + + /** The character offset */ + val charOffset: Int +) diff --git a/test/files/run/macro-sip19/Test_2.scala b/test/files/run/macro-sip19/Test_2.scala new file mode 100644 index 0000000000..32326e6352 --- /dev/null +++ b/test/files/run/macro-sip19/Test_2.scala @@ -0,0 +1,16 @@ +import Macros._ + +object Test extends App { + def foo(x: Int, y: Int)(implicit loc0: SourceLocation): Int = { + var loc = loc0; + { + var loc0 = 0 // shadow loc0 to disambiguate with the implicit macro + println("hey, i've been called from %s".format(loc)) + if (x < y) foo(y, x) + else if (y == 0) x + else foo(x - y, y) + } + } + + println(foo(4, 2)) +} diff --git a/test/files/run/macro-typecheck-implicitsdisabled.check b/test/files/run/macro-typecheck-implicitsdisabled.check new file mode 100644 index 0000000000..aa6c8e1f07 --- /dev/null +++ b/test/files/run/macro-typecheck-implicitsdisabled.check @@ -0,0 +1,2 @@ +scala.this.Predef.any2ArrowAssoc[Int](1).->[Int](2)
+scala.reflect.internal.Types$TypeError: value -> is not a member of Int
diff --git a/test/files/run/macro-typecheck-implicitsdisabled.flags b/test/files/run/macro-typecheck-implicitsdisabled.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-typecheck-implicitsdisabled.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala new file mode 100644 index 0000000000..4f0f76aed6 --- /dev/null +++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala @@ -0,0 +1,28 @@ +import scala.reflect.makro.Context + +object Macros { + def impl_with_implicits_enabled(c: Context) = { + import c.mirror._ + + val tree1 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false) + c.literal(ttree1.toString) + } + + def foo_with_implicits_enabled = macro impl_with_implicits_enabled + + def impl_with_implicits_disabled(c: Context) = { + import c.mirror._ + + try { + val tree2 = Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + val ttree2 = c.typeCheck(tree2, withImplicitViewsDisabled = true) + c.literal(ttree2.toString) + } catch { + case ex: Throwable => + c.literal(ex.toString) + } + } + + def foo_with_implicits_disabled = macro impl_with_implicits_disabled +}
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Test_2.scala b/test/files/run/macro-typecheck-implicitsdisabled/Test_2.scala new file mode 100644 index 0000000000..127e955f0e --- /dev/null +++ b/test/files/run/macro-typecheck-implicitsdisabled/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println(Macros.foo_with_implicits_enabled) + println(Macros.foo_with_implicits_disabled) +}
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled.check b/test/files/run/macro-typecheck-macrosdisabled.check new file mode 100644 index 0000000000..b432a539fc --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled.check @@ -0,0 +1,5 @@ +{
+ val $mr: reflect.mirror.type = scala.reflect.`package`.mirror;
+ $mr.Expr.apply[Int(2)]($mr.Literal.apply($mr.Constant.apply(2)))($mr.ConcreteTypeTag.apply[Int(2)]($mr.ConstantType.apply($mr.Constant.apply(2))))
+}
+mr.reify[Int](2)
diff --git a/test/files/run/macro-typecheck-macrosdisabled.flags b/test/files/run/macro-typecheck-macrosdisabled.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala new file mode 100644 index 0000000000..c253f0b1fb --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -0,0 +1,36 @@ +import scala.reflect.makro.Context + +object Macros { + def impl_with_macros_enabled(c: Context) = { + import c.mirror._ + + // todo. doesn't work. why? + //val mrPkg = staticModule("scala.reflect.package") + //val mrSym = selectTerm(mrPkg, "mirror") + //val NullaryMethodType(mrTpe) = mrSym.typeSignature + //val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror, null) + //val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) + + val mr = Select(Select(Select(Ident(newTermName("scala")), newTermName("reflect")), newTermName("package")), newTermName("mirror")) + val tree1 = Apply(Select(mr, newTermName("reify")), List(Literal(Constant(2)))) + val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) + c.literal(ttree1.toString) + } + + def foo_with_macros_enabled = macro impl_with_macros_enabled + + def impl_with_macros_disabled(c: Context) = { + import c.mirror._ + + val mrPkg = staticModule("scala.reflect.package") + val mrSym = selectTerm(mrPkg, "mirror") + val NullaryMethodType(mrTpe) = mrSym.typeSignature + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror, null) + + val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) + val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) + c.literal(ttree2.toString) + } + + def foo_with_macros_disabled = macro impl_with_macros_disabled +}
\ No newline at end of file diff --git a/test/files/run/macro-typecheck-macrosdisabled/Test_2.scala b/test/files/run/macro-typecheck-macrosdisabled/Test_2.scala new file mode 100644 index 0000000000..bdba39195b --- /dev/null +++ b/test/files/run/macro-typecheck-macrosdisabled/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println(Macros.foo_with_macros_enabled) + println(Macros.foo_with_macros_disabled) +}
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-consfromsls.check b/test/files/run/macro-undetparams-consfromsls.check new file mode 100644 index 0000000000..49e9140d5a --- /dev/null +++ b/test/files/run/macro-undetparams-consfromsls.check @@ -0,0 +1,5 @@ +A = ConcreteTypeTag[Int]
+B = ConcreteTypeTag[Nothing]
+List(1)
+A = ConcreteTypeTag[Any]
+List(abc, 1)
diff --git a/test/files/run/macro-undetparams-consfromsls.flags b/test/files/run/macro-undetparams-consfromsls.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-undetparams-consfromsls.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala new file mode 100644 index 0000000000..c22ff96028 --- /dev/null +++ b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala @@ -0,0 +1,17 @@ +import scala.reflect.makro.Context + +object Macros { + def cons_impl[A: c.TypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.reify { + println("A = " + c.literal(implicitly[c.TypeTag[A]].toString).eval) + x.eval :: xs.eval + } + + def nil_impl[B: c.TypeTag](c: Context): c.Expr[List[B]] = c.reify { + println("B = " + c.literal(implicitly[c.TypeTag[B]].toString).eval) + Nil + } + + def cons[A](x: A, xs: List[A]): List[A] = macro cons_impl[A] + + def nil[B]: List[B] = macro nil_impl[B] +}
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-consfromsls/Test_2.scala b/test/files/run/macro-undetparams-consfromsls/Test_2.scala new file mode 100644 index 0000000000..f2c2ce0051 --- /dev/null +++ b/test/files/run/macro-undetparams-consfromsls/Test_2.scala @@ -0,0 +1,7 @@ +object Test extends App { + import Macros._ + val xs = cons(1, nil) + println(xs) + val ys = cons("abc", xs) + println(ys) +}
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-implicitval.check b/test/files/run/macro-undetparams-implicitval.check new file mode 100644 index 0000000000..6c2b601aa5 --- /dev/null +++ b/test/files/run/macro-undetparams-implicitval.check @@ -0,0 +1 @@ +ConcreteTypeTag[Nothing]
diff --git a/test/files/run/macro-undetparams-implicitval.flags b/test/files/run/macro-undetparams-implicitval.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-undetparams-implicitval.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-implicitval/Test.scala b/test/files/run/macro-undetparams-implicitval/Test.scala new file mode 100644 index 0000000000..5278295451 --- /dev/null +++ b/test/files/run/macro-undetparams-implicitval/Test.scala @@ -0,0 +1,4 @@ +object Test extends App { + def foo[T: TypeTag] = println(implicitly[TypeTag[T]]) + foo +}
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-macroitself.check b/test/files/run/macro-undetparams-macroitself.check new file mode 100644 index 0000000000..e57fc1217b --- /dev/null +++ b/test/files/run/macro-undetparams-macroitself.check @@ -0,0 +1,2 @@ +ConcreteTypeTag[Int]
+ConcreteTypeTag[String]
diff --git a/test/files/run/macro-undetparams-macroitself.flags b/test/files/run/macro-undetparams-macroitself.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/files/run/macro-undetparams-macroitself.flags @@ -0,0 +1 @@ +-Xmacros
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala new file mode 100644 index 0000000000..9d65e8b0da --- /dev/null +++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala @@ -0,0 +1,7 @@ +import scala.reflect.makro.Context + +object Macros { + def impl[T: c.TypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.reify { println(c.literal(implicitly[c.TypeTag[T]].toString).eval) } + + def foo[T](foo: T) = macro impl[T] +}
\ No newline at end of file diff --git a/test/files/run/macro-undetparams-macroitself/Test_2.scala b/test/files/run/macro-undetparams-macroitself/Test_2.scala new file mode 100644 index 0000000000..1a93ff1304 --- /dev/null +++ b/test/files/run/macro-undetparams-macroitself/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + Macros.foo(42) + Macros.foo("42") +}
\ No newline at end of file diff --git a/test/files/run/manifests.scala b/test/files/run/manifests.scala index 6b6ea80b34..2d64bf18a9 100644 --- a/test/files/run/manifests.scala +++ b/test/files/run/manifests.scala @@ -4,29 +4,29 @@ object Test val CO, IN, CONTRA = Value } import Variances.{ CO, IN, CONTRA } - + object SubtypeRelationship extends Enumeration { val NONE, SAME, SUB, SUPER = Value } import SubtypeRelationship.{ NONE, SAME, SUB, SUPER } - + class VarianceTester[T, U, CC[_]](expected: Variances.Value)( implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) { - - def elements = List(ev1 <:< ev2, ev2 <:< ev1) - def containers = List(ev3 <:< ev4, ev4 <:< ev3) + + def elements = List(ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) + def containers = List(ev3.tpe <:< ev4.tpe, ev4.tpe <:< ev3.tpe) def isUnrelated = typeCompare[T, U] == NONE def isSame = typeCompare[T, U] == SAME def isSub = typeCompare[T, U] == SUB def isSuper = typeCompare[T, U] == SUPER - + def showsCovariance = (elements == containers) def showsContravariance = (elements == containers.reverse) def showsInvariance = containers forall (_ == isSame) def allContainerVariances = List(showsCovariance, showsInvariance, showsContravariance) - + def showsExpectedVariance = if (isUnrelated) allContainerVariances forall (_ == false) else if (isSame) allContainerVariances forall (_ == true) @@ -36,64 +36,57 @@ object Test case CONTRA => showsContravariance && !showsCovariance && !showsInvariance } } - + def showsCovariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](CO) showsExpectedVariance def showsInvariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](IN) showsExpectedVariance - + def showsContravariance[T, U, CC[_]](implicit ev1: Manifest[T], ev2: Manifest[U], ev3: Manifest[CC[T]], ev4: Manifest[CC[U]]) = new VarianceTester[T, U, CC](CONTRA) showsExpectedVariance - - def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = { - // checking types as well - if ((ev1 <:< ev2) != (ev1.tpe <:< ev2.tpe)) - println("Failed! " + ((ev1, ev2))) - - if ((ev2 <:< ev1) != (ev2.tpe <:< ev1.tpe)) - println("Failed! " + ((ev2, ev1))) - (ev1 <:< ev2, ev2 <:< ev1) match { + def typeCompare[T, U](implicit ev1: Manifest[T], ev2: Manifest[U]) = { + (ev1.tpe <:< ev2.tpe, ev2.tpe <:< ev1.tpe) match { case (true, true) => SAME case (true, false) => SUB case (false, true) => SUPER case (false, false) => NONE } } - + def assertAnyRef[T: Manifest] = List( - manifest[T] <:< manifest[Any], - manifest[T] <:< manifest[AnyRef], - !(manifest[T] <:< manifest[AnyVal]) + manifest[T].tpe <:< manifest[Any].tpe, + manifest[T].tpe <:< manifest[AnyRef].tpe, + !(manifest[T].tpe <:< manifest[AnyVal].tpe) ) foreach (assert(_, "assertAnyRef")) - + def assertAnyVal[T: Manifest] = List( - manifest[T] <:< manifest[Any], - !(manifest[T] <:< manifest[AnyRef]), - manifest[T] <:< manifest[AnyVal] + manifest[T].tpe <:< manifest[Any].tpe, + !(manifest[T].tpe <:< manifest[AnyRef].tpe), + manifest[T].tpe <:< manifest[AnyVal].tpe ) foreach (assert(_, "assertAnyVal")) - + def assertSameType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SAME, "assertSameType") def assertSuperType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SUPER, "assertSuperType") def assertSubType[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == SUB, "assertSubType") def assertNoRelationship[T: Manifest, U: Manifest] = assert(typeCompare[T, U] == NONE, "assertNoRelationship") - + def testVariancesVia[T: Manifest, U: Manifest] = assert( - typeCompare[T, U] == SUB && + typeCompare[T, U] == SUB && showsCovariance[T, U, List] && showsInvariance[T, U, Set], "testVariancesVia" ) - + def runAllTests = { assertAnyVal[AnyVal] assertAnyVal[Unit] - assertAnyVal[Int] - assertAnyVal[Double] + assertAnyVal[Int] + assertAnyVal[Double] assertAnyVal[Boolean] assertAnyVal[Char] - + assertAnyRef[AnyRef] assertAnyRef[java.lang.Object] assertAnyRef[java.lang.Integer] @@ -103,7 +96,7 @@ object Test assertAnyRef[String] assertAnyRef[scala.List[String]] assertAnyRef[scala.List[_]] - + // variance doesn't work yet // testVariancesVia[String, Any] // testVariancesVia[String, AnyRef] @@ -111,11 +104,11 @@ object Test assertSubType[List[String], List[Any]] assertSubType[List[String], List[AnyRef]] assertNoRelationship[List[String], List[AnyVal]] - + assertSubType[List[Int], List[Any]] assertSubType[List[Int], List[AnyVal]] assertNoRelationship[List[Int], List[AnyRef]] - + // Nothing assertSubType[Nothing, Any] assertSubType[Nothing, AnyVal] @@ -124,7 +117,7 @@ object Test assertSubType[Nothing, List[String]] assertSubType[Nothing, Null] assertSameType[Nothing, Nothing] - + // Null assertSubType[Null, Any] assertNoRelationship[Null, AnyVal] @@ -133,7 +126,7 @@ object Test assertSubType[Null, List[String]] assertSameType[Null, Null] assertSuperType[Null, Nothing] - + // Any assertSameType[Any, Any] assertSuperType[Any, AnyVal] @@ -142,7 +135,7 @@ object Test assertSuperType[Any, List[String]] assertSuperType[Any, Null] assertSuperType[Any, Nothing] - + // Misc unrelated types assertNoRelationship[Unit, AnyRef] assertNoRelationship[Unit, Int] diff --git a/test/files/run/phantomValueClass.check b/test/files/run/phantomValueClass.check new file mode 100644 index 0000000000..323fae03f4 --- /dev/null +++ b/test/files/run/phantomValueClass.check @@ -0,0 +1 @@ +foobar diff --git a/test/files/run/phantomValueClass.scala b/test/files/run/phantomValueClass.scala new file mode 100644 index 0000000000..f6509f2189 --- /dev/null +++ b/test/files/run/phantomValueClass.scala @@ -0,0 +1,10 @@ +final class Phantom[A](val s: String) extends AnyVal { + def compose(p: Phantom[A]): Phantom[A] = new Phantom[A](s+p.s) +} + +object Test extends App { + val x = new Phantom[Int]("foo") + val y = new Phantom[Int]("bar") + val z = x compose y + println(z.s) +} diff --git a/test/files/run/primitive-sigs-2.check b/test/files/run/primitive-sigs-2.check index feb0619525..1b6e24ed20 100644 --- a/test/files/run/primitive-sigs-2.check +++ b/test/files/run/primitive-sigs-2.check @@ -1,7 +1,7 @@ -T<java.lang.Object> -List(A, char, class java.lang.Object) -a -public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.Manifest<T>) -public float[] Arr.arr3(float[][]) -public scala.collection.immutable.List<java.lang.Character> Arr.arr2(java.lang.Character[]) -public scala.collection.immutable.List<java.lang.Object> Arr.arr1(int[]) +T<java.lang.Object>
+List(A, char, class java.lang.Object)
+a
+public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.api.TypeTags.scala.reflect.api.TypeTags$ConcreteTypeTag<T>)
+public float[] Arr.arr3(float[][])
+public scala.collection.immutable.List<java.lang.Character> Arr.arr2(java.lang.Character[])
+public scala.collection.immutable.List<java.lang.Object> Arr.arr1(int[])
diff --git a/test/files/run/reify_ann1a.check b/test/files/run/reify_ann1a.check index 66dce778a8..a3944ae1ee 100644 --- a/test/files/run/reify_ann1a.check +++ b/test/files/run/reify_ann1a.check @@ -1,30 +1,30 @@ -{ - @new ann(immutable.this.List.apply[String]("1a")) @new ann(immutable.this.List.apply[String]("1b")) class C[@new ann(immutable.this.List.apply[String]("2a")) @new ann(immutable.this.List.apply[String]("2b")) T] extends scala.AnyRef { - @new ann(immutable.this.List.apply[String]("3a")) @new ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4a")) @ann(immutable.this.List.apply[String]("4b")) = _; - def <init>(@new ann(immutable.this.List.apply[String]("3a")) @new ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4a")) @ann(immutable.this.List.apply[String]("4b"))) = { - super.<init>(); - () - }; - @new ann(immutable.this.List.apply[String]("5a")) @new ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = { - @new ann(immutable.this.List.apply[String]("7a")) @new ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.$plus(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a"))); - val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a"))); - r.$plus(s) - } - }; - () -} -{ - @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends scala.AnyRef { - @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _; - def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = { - C.super.<init>(); - () - }; - @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = { - @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a"))); - val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a"))); - r.+(s) - } - }; - () -} +{
+ @new ann(immutable.this.List.apply("1a")) @new ann(immutable.this.List.apply("1b")) class C[@new ann(immutable.this.List.apply("2a")) @new ann(immutable.this.List.apply("2b")) T >: Nothing <: Any] extends Object {
+ @new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b")) = _;
+ def <init>(@new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b"))) = {
+ super.<init>();
+ ()
+ };
+ @new ann(immutable.this.List.apply("5a")) @new ann(immutable.this.List.apply("5b")) def f(x: Int @ann(immutable.this.List.apply("6a")) @ann(immutable.this.List.apply("6b"))) = {
+ @new ann(immutable.this.List.apply("7a")) @new ann(immutable.this.List.apply("7b")) val r = x.$plus(3): @ann(immutable.this.List.apply("8a")): @ann(immutable.this.List.apply("8b"));
+ val s = (4: Int @ann(immutable.this.List.apply("9a")) @ann(immutable.this.List.apply("9b")));
+ r.$plus(s)
+ }
+ };
+ ()
+}
+{
+ @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends Object {
+ @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _;
+ def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = {
+ C.super.<init>();
+ ()
+ };
+ @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = {
+ @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")));
+ val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")));
+ r.+(s)
+ }
+ };
+ ()
+}
diff --git a/test/files/run/reify_ann1a.scala b/test/files/run/reify_ann1a.scala index 1ca170904b..1f5d1daccd 100644 --- a/test/files/run/reify_ann1a.scala +++ b/test/files/run/reify_ann1a.scala @@ -1,14 +1,10 @@ -import scala.reflect._ -import scala.reflect.api._ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ class ann(bar: List[String]) extends StaticAnnotation object Test extends App { // test 1: reify - val tree = scala.reflect.Code.lift{ + val tree = reify{ @ann(bar=List("1a")) @ann(bar=List("1b")) class C[@ann(bar=List("2a")) @ann(bar=List("2b")) T](@ann(bar=List("3a")) @ann(bar=List("3b")) x: T @ann(bar=List("4a")) @ann(bar=List("4b"))) { @ann(bar=List("5a")) @ann(bar=List("5b")) def f(x: Int @ann(bar=List("6a")) @ann(bar=List("6b"))) = { @ann(bar=List("7a")) @ann(bar=List("7b")) val r = (x + 3): @ann(bar=List("8a")) @ann(bar=List("8b")) @@ -20,8 +16,7 @@ object Test extends App { println(tree.toString) // test 2: import and typecheck - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val ttree = toolbox.typeCheck(tree) println(ttree.toString) diff --git a/test/files/run/reify_ann1b.check b/test/files/run/reify_ann1b.check index 9bc65a422e..bae838f15f 100644 --- a/test/files/run/reify_ann1b.check +++ b/test/files/run/reify_ann1b.check @@ -1,30 +1,30 @@ -{ - @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T] extends scala.AnyRef { - @new ann(bar = "3a") @new ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4a") @ann(bar = "4b") = _; - def <init>(@new ann(bar = "3a") @new ann(bar = "3b") x: T @ann(bar = "4a") @ann(bar = "4b")) = { - super.<init>(); - () - }; - @new ann(bar = "5a") @new ann(bar = "5b") def f(x: Int @ann(bar = "6b") @ann(bar = "6a")): Int = { - @new ann(bar = "7a") @new ann(bar = "7b") val r: Int @ann(bar = "8b") @ann(bar = "8a") = ((x.$plus(3): Int @ann(bar = "8a")): Int @ann(bar = "8b") @ann(bar = "8a")); - val s: Int @ann(bar = "9b") @ann(bar = "9a") = (4: Int @ann(bar = "9b") @ann(bar = "9a")); - r.$plus(s) - } - }; - () -} -{ - @ann(bar = "1a") @ann(bar = "1b") class C[@ann(bar = "2a") @ann(bar = "2b") T] extends scala.AnyRef { - @ann(bar = "3a") @ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4b") @ann(bar = "4a") = _; - def <init>(@ann(bar = "3a") @ann(bar = "3b") x: T @ann(bar = "4b") @ann(bar = "4a")): C[T] = { - C.super.<init>(); - () - }; - @ann(bar = "5a") @ann(bar = "5b") def f(x: Int @ann(bar = "6b") @ann(bar = "6a")): Int = { - @ann(bar = "7a") @ann(bar = "7b") val r: Int @ann(bar = "8b") @ann(bar = "8a") = ((x.+(3): Int @ann(bar = "8a")): Int @ann(bar = "8b") @ann(bar = "8a")); - val s: Int @ann(bar = "9b") @ann(bar = "9a") = (4: Int @ann(bar = "9b") @ann(bar = "9a")); - r.+(s) - } - }; - () -} +{
+ @new ann(bar = "1a") @new ann(bar = "1b") class C[@new ann(bar = "2a") @new ann(bar = "2b") T >: Nothing <: Any] extends Object {
+ @new ann(bar = "3a") @new ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4a") @ann(bar = "4b") = _;
+ def <init>(@new ann(bar = "3a") @new ann(bar = "3b") x: T @ann(bar = "4a") @ann(bar = "4b")) = {
+ super.<init>();
+ ()
+ };
+ @new ann(bar = "5a") @new ann(bar = "5b") def f(x: Int @ann(bar = "6a") @ann(bar = "6b")) = {
+ @new ann(bar = "7a") @new ann(bar = "7b") val r = x.$plus(3): @ann(bar = "8a"): @ann(bar = "8b");
+ val s = (4: Int @ann(bar = "9a") @ann(bar = "9b"));
+ r.$plus(s)
+ }
+ };
+ ()
+}
+{
+ @ann(bar = "1a") @ann(bar = "1b") class C[@ann(bar = "2a") @ann(bar = "2b") T] extends Object {
+ @ann(bar = "3a") @ann(bar = "3b") <paramaccessor> private[this] val x: T @ann(bar = "4b") @ann(bar = "4a") = _;
+ def <init>(@ann(bar = "3a") @ann(bar = "3b") x: T @ann(bar = "4b") @ann(bar = "4a")): C[T] = {
+ C.super.<init>();
+ ()
+ };
+ @ann(bar = "5a") @ann(bar = "5b") def f(x: Int @ann(bar = "6b") @ann(bar = "6a")): Int = {
+ @ann(bar = "7a") @ann(bar = "7b") val r: Int @ann(bar = "8b") @ann(bar = "8a") = ((x.+(3): Int @ann(bar = "8a")): Int @ann(bar = "8b") @ann(bar = "8a"));
+ val s: Int @ann(bar = "9b") @ann(bar = "9a") = (4: Int @ann(bar = "9b") @ann(bar = "9a"));
+ r.+(s)
+ }
+ };
+ ()
+}
diff --git a/test/files/run/reify_ann1b.scala b/test/files/run/reify_ann1b.scala index 9bdc712227..13d861a15c 100644 --- a/test/files/run/reify_ann1b.scala +++ b/test/files/run/reify_ann1b.scala @@ -1,14 +1,10 @@ -import scala.reflect._ -import scala.reflect.api._ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ class ann(bar: String) extends ClassfileAnnotation object Test extends App { // test 1: reify - val tree = scala.reflect.Code.lift{ + val tree = reify{ @ann(bar="1a") @ann(bar="1b") class C[@ann(bar="2a") @ann(bar="2b") T](@ann(bar="3a") @ann(bar="3b") x: T @ann(bar="4a") @ann(bar="4b")) { @ann(bar="5a") @ann(bar="5b") def f(x: Int @ann(bar="6a") @ann(bar="6b")) = { @ann(bar="7a") @ann(bar="7b") val r = (x + 3): @ann(bar="8a") @ann(bar="8b") @@ -20,8 +16,7 @@ object Test extends App { println(tree.toString) // test 2: import and typecheck - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val ttree = toolbox.typeCheck(tree) println(ttree.toString) diff --git a/test/files/run/reify_ann2a.check b/test/files/run/reify_ann2a.check new file mode 100644 index 0000000000..5022c50ca8 --- /dev/null +++ b/test/files/run/reify_ann2a.check @@ -0,0 +1,44 @@ +{
+ class ann extends StaticAnnotation {
+ <paramaccessor> private[this] val bar: List[String] = _;
+ def <init>(bar: List[String]) = {
+ super.<init>();
+ ()
+ }
+ };
+ @new ann(immutable.this.List.apply("1a")) @new ann(immutable.this.List.apply("1b")) class C[@new ann(immutable.this.List.apply("2a")) @new ann(immutable.this.List.apply("2b")) T >: Nothing <: Any] extends Object {
+ @new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b")) = _;
+ def <init>(@new ann(immutable.this.List.apply("3a")) @new ann(immutable.this.List.apply("3b")) x: T @ann(immutable.this.List.apply("4a")) @ann(immutable.this.List.apply("4b"))) = {
+ super.<init>();
+ ()
+ };
+ @new ann(immutable.this.List.apply("5a")) @new ann(immutable.this.List.apply("5b")) def f(x: Int @ann(immutable.this.List.apply("6a")) @ann(immutable.this.List.apply("6b"))) = {
+ @new ann(immutable.this.List.apply("7a")) @new ann(immutable.this.List.apply("7b")) val r = x.$plus(3): @ann(immutable.this.List.apply("8a")): @ann(immutable.this.List.apply("8b"));
+ val s = (4: Int @ann(immutable.this.List.apply("9a")) @ann(immutable.this.List.apply("9b")));
+ r.$plus(s)
+ }
+ };
+ ()
+}
+{
+ class ann extends scala.annotation.Annotation with scala.annotation.StaticAnnotation {
+ <paramaccessor> private[this] val bar: List[String] = _;
+ def <init>(bar: List[String]): ann = {
+ ann.super.<init>();
+ ()
+ }
+ };
+ @ann(immutable.this.List.apply[String]("1a")) @ann(immutable.this.List.apply[String]("1b")) class C[@ann(immutable.this.List.apply[String]("2a")) @ann(immutable.this.List.apply[String]("2b")) T] extends Object {
+ @ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) <paramaccessor> private[this] val x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a")) = _;
+ def <init>(@ann(immutable.this.List.apply[String]("3a")) @ann(immutable.this.List.apply[String]("3b")) x: T @ann(immutable.this.List.apply[String]("4b")) @ann(immutable.this.List.apply[String]("4a"))): C[T] = {
+ C.super.<init>();
+ ()
+ };
+ @ann(immutable.this.List.apply[String]("5a")) @ann(immutable.this.List.apply[String]("5b")) def f(x: Int @ann(immutable.this.List.apply[String]("6b")) @ann(immutable.this.List.apply[String]("6a"))): Int = {
+ @ann(immutable.this.List.apply[String]("7a")) @ann(immutable.this.List.apply[String]("7b")) val r: Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")) = ((x.+(3): Int @ann(immutable.this.List.apply[String]("8a"))): Int @ann(immutable.this.List.apply[String]("8b")) @ann(immutable.this.List.apply[String]("8a")));
+ val s: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")) = (4: Int @ann(immutable.this.List.apply[String]("9b")) @ann(immutable.this.List.apply[String]("9a")));
+ r.+(s)
+ }
+ };
+ ()
+}
diff --git a/test/files/run/reify_ann2a.scala b/test/files/run/reify_ann2a.scala new file mode 100644 index 0000000000..370abadba0 --- /dev/null +++ b/test/files/run/reify_ann2a.scala @@ -0,0 +1,25 @@ +import scala.reflect.mirror._ + +object Test extends App { + // test 1: reify + val tree = reify{ + class ann(bar: List[String]) extends StaticAnnotation + + @ann(bar=List("1a")) @ann(bar=List("1b")) class C[@ann(bar=List("2a")) @ann(bar=List("2b")) T](@ann(bar=List("3a")) @ann(bar=List("3b")) x: T @ann(bar=List("4a")) @ann(bar=List("4b"))) { + @ann(bar=List("5a")) @ann(bar=List("5b")) def f(x: Int @ann(bar=List("6a")) @ann(bar=List("6b"))) = { + @ann(bar=List("7a")) @ann(bar=List("7b")) val r = (x + 3): @ann(bar=List("8a")) @ann(bar=List("8b")) + val s = 4: Int @ann(bar=List("9a")) @ann(bar=List("9b")) + r + s + } + } + }.tree + println(tree.toString) + + // test 2: import and typecheck + val toolbox = mkToolBox() + val ttree = toolbox.typeCheck(tree) + println(ttree.toString) + + // test 3: import and compile + toolbox.runExpr(tree) +}
\ No newline at end of file diff --git a/test/files/run/reify_ann3.check b/test/files/run/reify_ann3.check new file mode 100644 index 0000000000..9452a9701e --- /dev/null +++ b/test/files/run/reify_ann3.check @@ -0,0 +1,21 @@ +{
+ class Tree[A >: Nothing <: Any, B >: Nothing <: Any] extends Object {
+ @new inline @getter() final <paramaccessor> val key: A = _;
+ def <init>(key: A) = {
+ super.<init>();
+ ()
+ }
+ };
+ ()
+}
+{
+ class Tree[A, B] extends Object {
+ final <paramaccessor> private[this] val key: A = _;
+ @inline @scala.annotation.meta.getter final <stable> <accessor> <paramaccessor> def key: A = Tree.this.key;
+ def <init>(key: A): Tree[A,B] = {
+ Tree.super.<init>();
+ ()
+ }
+ };
+ ()
+}
diff --git a/test/files/run/reify_ann3.scala b/test/files/run/reify_ann3.scala new file mode 100644 index 0000000000..d65e641619 --- /dev/null +++ b/test/files/run/reify_ann3.scala @@ -0,0 +1,19 @@ +import scala.reflect.mirror._ +import scala.annotation._ +import scala.annotation.meta._ + +object Test extends App { + // test 1: reify + val tree = reify{ + class Tree[A, +B](@(inline @getter) final val key: A) + }.tree + println(tree.toString) + + // test 2: import and typecheck + val toolbox = mkToolBox() + val ttree = toolbox.typeCheck(tree) + println(ttree.toString) + + // test 3: import and compile + toolbox.runExpr(tree) +} diff --git a/test/files/run/reify_ann4.check b/test/files/run/reify_ann4.check new file mode 100644 index 0000000000..406ee7bc08 --- /dev/null +++ b/test/files/run/reify_ann4.check @@ -0,0 +1,32 @@ +{
+ class D extends StaticAnnotation {
+ def <init>() = {
+ super.<init>();
+ ()
+ }
+ };
+ class C extends Object {
+ def <init>() = {
+ super.<init>();
+ ()
+ }
+ };
+ val c1 = new C @D();
+ ()
+}
+{
+ class D extends scala.annotation.Annotation with scala.annotation.StaticAnnotation {
+ def <init>(): D = {
+ D.super.<init>();
+ ()
+ }
+ };
+ class C extends Object {
+ def <init>(): C = {
+ C.super.<init>();
+ ()
+ }
+ };
+ val c1: C = new C @D();
+ ()
+}
diff --git a/test/files/run/reify_ann4.scala b/test/files/run/reify_ann4.scala new file mode 100644 index 0000000000..5655812689 --- /dev/null +++ b/test/files/run/reify_ann4.scala @@ -0,0 +1,23 @@ +import scala.reflect.mirror._ +import scala.annotation._ +import scala.annotation.meta._ + +object Test extends App { + // test 1: reify + val tree = reify{ + class D extends StaticAnnotation + class C + val c1 = new C @D + //val c2 = (new C) @D // illegal syntax + //val c3 = c1 @D // illegal syntax + }.tree + println(tree.toString) + + // test 2: import and typecheck + val toolbox = mkToolBox() + val ttree = toolbox.typeCheck(tree) + println(ttree.toString) + + // test 3: import and compile + toolbox.runExpr(tree) +} diff --git a/test/files/run/reify_ann5.check b/test/files/run/reify_ann5.check new file mode 100644 index 0000000000..ecf08eebb2 --- /dev/null +++ b/test/files/run/reify_ann5.check @@ -0,0 +1,22 @@ +{
+ class C extends Object {
+ @new inline @beanGetter() @new BeanProperty() <paramaccessor> val x: Int = _;
+ def <init>(x: Int) = {
+ super.<init>();
+ ()
+ }
+ };
+ ()
+}
+{
+ class C extends Object {
+ @scala.beans.BeanProperty <paramaccessor> private[this] val x: Int = _;
+ <stable> <accessor> <paramaccessor> def x: Int = C.this.x;
+ def <init>(x: Int): C = {
+ C.super.<init>();
+ ()
+ };
+ @inline @scala.annotation.meta.beanGetter def getX(): Int = C.this.x
+ };
+ ()
+}
diff --git a/test/files/run/reify_ann5.scala b/test/files/run/reify_ann5.scala new file mode 100644 index 0000000000..aecc61de46 --- /dev/null +++ b/test/files/run/reify_ann5.scala @@ -0,0 +1,20 @@ +import scala.reflect.mirror._ +import scala.annotation._ +import scala.annotation.meta._ +import scala.beans._ + +object Test extends App { + // test 1: reify + val tree = reify{ + class C(@BeanProperty @(inline @beanGetter) val x: Int) + }.tree + println(tree.toString) + + // test 2: import and typecheck + val toolbox = mkToolBox() + val ttree = toolbox.typeCheck(tree) + println(ttree.toString) + + // test 3: import and compile + toolbox.runExpr(tree) +} diff --git a/test/files/run/reify_anonymous.scala b/test/files/run/reify_anonymous.scala index af16f2f8fd..cd740f0190 100644 --- a/test/files/run/reify_anonymous.scala +++ b/test/files/run/reify_anonymous.scala @@ -1,13 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { println(new {def x = 2; def y = x * x}.y) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_classfileann_a.check b/test/files/run/reify_classfileann_a.check index 419d916907..685ecf5de6 100644 --- a/test/files/run/reify_classfileann_a.check +++ b/test/files/run/reify_classfileann_a.check @@ -1,18 +1,18 @@ -{ - @new ann(bar = "1", quux = Array("2", "3"), baz = new ann(bar = "4")) class C extends scala.AnyRef { - def <init>() = { - super.<init>(); - () - } - }; - () -} -{ - @ann(bar = "1", quux = ["2", "3"], baz = ann(bar = "4")) class C extends scala.AnyRef { - def <init>(): C = { - C.super.<init>(); - () - } - }; - () -} +{
+ @new ann(bar = "1", quux = Array("2", "3"), baz = new ann(bar = "4")) class C extends Object {
+ def <init>() = {
+ super.<init>();
+ ()
+ }
+ };
+ ()
+}
+{
+ @ann(bar = "1", quux = ["2", "3"], baz = ann(bar = "4")) class C extends Object {
+ def <init>(): C = {
+ C.super.<init>();
+ ()
+ }
+ };
+ ()
+}
diff --git a/test/files/run/reify_classfileann_a.scala b/test/files/run/reify_classfileann_a.scala index c77bd3b8a2..c3e7d8d2e9 100644 --- a/test/files/run/reify_classfileann_a.scala +++ b/test/files/run/reify_classfileann_a.scala @@ -1,21 +1,16 @@ -import scala.reflect._ -import scala.reflect.api._ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends ClassfileAnnotation object Test extends App { // test 1: reify - val tree = scala.reflect.Code.lift{ + val tree = reify{ @ann(bar="1", quux=Array("2", "3"), baz = new ann(bar = "4")) class C }.tree println(tree.toString) // test 2: import and typecheck - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val ttree = toolbox.typeCheck(tree) println(ttree.toString) diff --git a/test/files/run/reify_classfileann_b.check b/test/files/run/reify_classfileann_b.check new file mode 100644 index 0000000000..0aac9aeb2a --- /dev/null +++ b/test/files/run/reify_classfileann_b.check @@ -0,0 +1,20 @@ +{
+ class C extends Object {
+ def <init>() = {
+ super.<init>();
+ ()
+ };
+ def x: Int = 2: @ann(bar = "1",quux = Array("2", "3"),baz = new ann(bar = "4"))
+ };
+ ()
+}
+{
+ class C extends Object {
+ def <init>(): C = {
+ C.super.<init>();
+ ()
+ };
+ def x: Int = (2: Int(2) @ann(bar = "1", quux = ["2", "3"], baz = ann(bar = "4")))
+ };
+ ()
+}
diff --git a/test/files/run/reify_classfileann_b.scala b/test/files/run/reify_classfileann_b.scala new file mode 100644 index 0000000000..4e50494af3 --- /dev/null +++ b/test/files/run/reify_classfileann_b.scala @@ -0,0 +1,23 @@ +import scala.reflect.mirror._ + +class ann(bar: String, quux: Array[String] = Array(), baz: ann = null) extends ClassfileAnnotation + +object Test extends App { + // test 1: reify + val tree = reify{ + class C { + def x: Int = { + 2: @ann(bar="1", quux=Array("2", "3"), baz = new ann(bar = "4")) + } + } + }.tree + println(tree.toString) + + // test 2: import and typecheck + val toolbox = mkToolBox() + val ttree = toolbox.typeCheck(tree) + println(ttree.toString) + + // test 3: import and compile + toolbox.runExpr(tree) +}
\ No newline at end of file diff --git a/test/files/run/reify_closure1.scala b/test/files/run/reify_closure1.scala index 7cb3aff17d..3f5c8a8724 100644 --- a/test/files/run/reify_closure1.scala +++ b/test/files/run/reify_closure1.scala @@ -1,15 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { def foo[T](ys: List[T]): Int => Int = { - val fun = reflect.Code.lift{(x: Int) => { + val fun = reify{(x: Int) => { x }} - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure2a.scala b/test/files/run/reify_closure2a.scala index cf367aa63f..f5669a0e2c 100644 --- a/test/files/run/reify_closure2a.scala +++ b/test/files/run/reify_closure2a.scala @@ -1,15 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { def foo(y: Int): Int => Int = { - val fun = reflect.Code.lift{(x: Int) => { + val fun = reify{(x: Int) => { x + y }} - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure3a.scala b/test/files/run/reify_closure3a.scala index d322b970b6..056a705d7d 100644 --- a/test/files/run/reify_closure3a.scala +++ b/test/files/run/reify_closure3a.scala @@ -1,17 +1,14 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { def foo(y: Int): Int => Int = { def y1 = y - val fun = reflect.Code.lift{(x: Int) => { + val fun = reify{(x: Int) => { x + y1 }} - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure4a.scala b/test/files/run/reify_closure4a.scala index bbedd7e092..a63d20e561 100644 --- a/test/files/run/reify_closure4a.scala +++ b/test/files/run/reify_closure4a.scala @@ -1,17 +1,14 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { def foo(y: Int): Int => Int = { val y1 = y - val fun = reflect.Code.lift{(x: Int) => { + val fun = reify{(x: Int) => { x + y1 }} - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/files/run/reify_closure5a.scala b/test/files/run/reify_closure5a.scala index 193e18103a..2e8b413f4c 100644 --- a/test/files/run/reify_closure5a.scala +++ b/test/files/run/reify_closure5a.scala @@ -1,19 +1,18 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - def foo[T](ys: List[T]): Int => Int = { - val fun = reflect.Code.lift{(x: Int) => { + def foo[T: TypeTag](ys: List[T]): Int => Int = { + val fun = reify{(x: Int) => { x + ys.length }} - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(fun.tree) dyn.asInstanceOf[Int => Int] } - println(foo(List(1, 2, 3))(10)) - println(foo(List(1, 2, 3, 4))(10)) + var fun1 = foo(List(1, 2, 3)) + println(fun1(10)) + var fun2 = foo(List(1, 2, 3, 4)) + println(fun2(10)) } diff --git a/test/files/run/reify_closure6.scala b/test/files/run/reify_closure6.scala index 6aff83cb94..2cbd4ce819 100644 --- a/test/files/run/reify_closure6.scala +++ b/test/files/run/reify_closure6.scala @@ -1,13 +1,11 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { var q = 0 - def foo[T](ys: List[T]): Int => Int = { + def foo[T: TypeTag](ys: List[T]): Int => Int = { val z = 1 var y = 0 - val fun = reflect.Code.lift{(x: Int) => { + val fun = reify{(x: Int) => { y += 1 q += 1 println("q = " + q) @@ -15,13 +13,14 @@ object Test extends App { x + ys.length * z + q + y }} - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(fun.tree) dyn.asInstanceOf[Int => Int] } - println("first invocation = " + foo(List(1, 2, 3))(10)) - println("second invocation = " + foo(List(1, 2, 3, 4))(10)) + val fun1 = foo(List(1, 2, 3)) + println("first invocation = " + fun1(10)) + val fun2 = foo(List(1, 2, 3, 4)) + println("second invocation = " + fun2(10)) println("q after second invocation = " + q) }
\ No newline at end of file diff --git a/test/files/run/reify_closure7.scala b/test/files/run/reify_closure7.scala index 46002d8d6c..b9f87dbdeb 100644 --- a/test/files/run/reify_closure7.scala +++ b/test/files/run/reify_closure7.scala @@ -1,14 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { var q = 0 var clo: Int => Int = null - def foo[T](ys: List[T]): Int => Int = { + def foo[T: TypeTag](ys: List[T]): Int => Int = { val z = 1 var y = 0 - val fun = reflect.Code.lift{(x: Int) => { + val fun = reify{(x: Int) => { y += 1 q += 1 println("q = " + q) @@ -17,8 +15,7 @@ object Test extends App { }} if (clo == null) { - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(fun.tree) clo = dyn.asInstanceOf[Int => Int] } @@ -26,6 +23,8 @@ object Test extends App { clo } - println("first invocation = " + foo(List(1, 2, 3))(10)) - println("second invocation = " + foo(List(1, 2, 3, 4))(10)) + val fun1 = foo(List(1, 2, 3)) + println("first invocation = " + fun1(10)) + val fun2 = foo(List(1, 2, 3, 4)) + println("second invocation = " + fun2(10)) } diff --git a/test/files/run/reify_closure8a.scala b/test/files/run/reify_closure8a.scala index 805d8ff855..9de121b42f 100644 --- a/test/files/run/reify_closure8a.scala +++ b/test/files/run/reify_closure8a.scala @@ -1,15 +1,11 @@ -import scala.reflect.Code._ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { class Foo(val y: Int) { - def fun = lift{y} + def fun = reify{y} } - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(new Foo(10).fun.tree) val foo = dyn.asInstanceOf[Int] println(foo) diff --git a/test/files/run/reify_closure8b.check b/test/files/run/reify_closure8b.check new file mode 100644 index 0000000000..e0ec7d2c8f --- /dev/null +++ b/test/files/run/reify_closure8b.check @@ -0,0 +1,3 @@ +scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective compilation has failed:
+
+value y is not a member of Test.Foo
diff --git a/test/files/run/reify_closure8b.scala b/test/files/run/reify_closure8b.scala new file mode 100644 index 0000000000..431da3230e --- /dev/null +++ b/test/files/run/reify_closure8b.scala @@ -0,0 +1,18 @@ +import scala.reflect.mirror._ + +object Test extends App { + // will fail because y is a private field + // reification doesn't magically make unavailable stuff available + class Foo(y: Int) { + def fun = reify{y} + } + + try { + val dyn = mkToolBox().runExpr(new Foo(10).fun.tree) + val foo = dyn.asInstanceOf[Int] + println(foo) + } catch { + case ex: Throwable => + println(ex) + } +} diff --git a/test/files/run/reify_closures10.scala b/test/files/run/reify_closures10.scala index b6ec8e8911..0ccce77a94 100644 --- a/test/files/run/reify_closures10.scala +++ b/test/files/run/reify_closures10.scala @@ -1,14 +1,10 @@ -import scala.reflect.Code._ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { val x = 2 val y = 3 - val code = lift{println(x + y); x + y} + val code = reify{println(x + y); x + y} - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() println(toolbox.runExpr(code.tree)) } diff --git a/test/files/run/reify_complex.scala b/test/files/run/reify_complex.scala index 0d9aeb28c5..ecc25ffca5 100644 --- a/test/files/run/reify_complex.scala +++ b/test/files/run/reify_complex.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class Complex(val re: Double, val im: Double) { def + (that: Complex) = new Complex(re + that.re, im + that.im) @@ -22,9 +20,5 @@ object Test extends App { } val x = new Complex(2, 1); val y = new Complex(1, 3) println(x + y) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_extendbuiltins.scala b/test/files/run/reify_extendbuiltins.scala index 0aaec7cdf2..f95e9ab6ec 100644 --- a/test/files/run/reify_extendbuiltins.scala +++ b/test/files/run/reify_extendbuiltins.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { def fact(n: Int): BigInt = if (n == 0) 1 else fact(n-1) * n class Factorizer(n: Int) { @@ -12,9 +10,5 @@ object Test extends App { implicit def int2fact(n: Int) = new Factorizer(n) println("10! = " + (10!)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_for1.scala b/test/files/run/reify_for1.scala index d1b60d878b..9d1e32f7e5 100644 --- a/test/files/run/reify_for1.scala +++ b/test/files/run/reify_for1.scala @@ -1,15 +1,9 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { val sumOfSquares1 = (for (i <- 1 to 100; if (i % 3 == 0)) yield Math.pow(i, 2)).sum val sumOfSquares2 = (1 to 100).filter(_ % 3 == 0).map(Math.pow(_, 2)).sum assert(sumOfSquares1 == sumOfSquares2) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_fors.scala b/test/files/run/reify_fors.scala index 27ee85d18b..635fce049e 100644 --- a/test/files/run/reify_fors.scala +++ b/test/files/run/reify_fors.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { object Persons { /** A list of persons. To create a list, we use Predef.List * which takes a variable number of arguments and constructs @@ -98,9 +96,5 @@ object Test extends App { val ys = List(2.0, 1.0, 3.0) println("scalProd(" + xs + ", " + ys +") = " + scalProd(xs, ys)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_generic.scala b/test/files/run/reify_generic.scala index 6a4ff148c4..7033c4e237 100644 --- a/test/files/run/reify_generic.scala +++ b/test/files/run/reify_generic.scala @@ -1,14 +1,8 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { val product = List(1, 2, 3).head * List[Any](4, 2, 0).head.asInstanceOf[Int] println(product) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_generic2.scala b/test/files/run/reify_generic2.scala index 9413f41eb5..8f9def318e 100644 --- a/test/files/run/reify_generic2.scala +++ b/test/files/run/reify_generic2.scala @@ -1,15 +1,9 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class C val product = List(new C, new C).length * List[C](new C, new C).length println(product) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_getter.scala b/test/files/run/reify_getter.scala index 33f36888a7..8bae293e72 100644 --- a/test/files/run/reify_getter.scala +++ b/test/files/run/reify_getter.scala @@ -1,18 +1,15 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { class C { val x = 2 } new C().x - }; + } - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val evaluated = toolbox.runExpr(code.tree) println("evaluated = " + evaluated) } diff --git a/test/files/run/reify_implicits.scala b/test/files/run/reify_implicits.scala index 953eabe6c2..60971c3cfb 100644 --- a/test/files/run/reify_implicits.scala +++ b/test/files/run/reify_implicits.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { implicit def arrayWrapper[A : ClassManifest](x: Array[A]) = new { def sort(p: (A, A) => Boolean) = { @@ -12,9 +10,5 @@ object Test extends App { } val x = Array(2, 3, 1, 4) println("x = "+ x.sort((x: Int, y: Int) => x < y).toList) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_inheritance.scala b/test/files/run/reify_inheritance.scala index 78a64c264e..dd86c355a3 100644 --- a/test/files/run/reify_inheritance.scala +++ b/test/files/run/reify_inheritance.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class C { def x = 2 def y = x * x @@ -14,9 +12,5 @@ object Test extends App { } println(new D().y * new C().x) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_inner1.scala b/test/files/run/reify_inner1.scala index 546fe36d16..ea77ece6df 100644 --- a/test/files/run/reify_inner1.scala +++ b/test/files/run/reify_inner1.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class C { class D { val x = 2 @@ -13,9 +11,5 @@ object Test extends App { val outer = new C() val inner = new outer.D() println(inner.x) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_inner2.scala b/test/files/run/reify_inner2.scala index 613614b989..67c403f7e5 100644 --- a/test/files/run/reify_inner2.scala +++ b/test/files/run/reify_inner2.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class C { object D { val x = 2 @@ -13,9 +11,5 @@ object Test extends App { val outer = new C() val inner = outer.D println(inner.x) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_inner3.scala b/test/files/run/reify_inner3.scala index e9fb636dce..ad401d81da 100644 --- a/test/files/run/reify_inner3.scala +++ b/test/files/run/reify_inner3.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { object C { class D { val x = 2 @@ -13,9 +11,5 @@ object Test extends App { val outer = C val inner = new outer.D println(inner.x) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_inner4.scala b/test/files/run/reify_inner4.scala index 33870b0983..140c8e9ed4 100644 --- a/test/files/run/reify_inner4.scala +++ b/test/files/run/reify_inner4.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { object C { object D { val x = 2 @@ -13,9 +11,5 @@ object Test extends App { val outer = C val inner = outer.D println(inner.x) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_maps.scala b/test/files/run/reify_maps.scala index d3d95ffa24..3fcc21892f 100644 --- a/test/files/run/reify_maps.scala +++ b/test/files/run/reify_maps.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { val colors = Map("red" -> 0xFF0000, "turquoise" -> 0x00FFFF, "black" -> 0x000000, @@ -17,9 +15,5 @@ object Test extends App { "Unknown color: " + name } ) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_metalevel_breach_+0_refers_to_1.check b/test/files/run/reify_metalevel_breach_+0_refers_to_1.check new file mode 100644 index 0000000000..5bfed17f8e --- /dev/null +++ b/test/files/run/reify_metalevel_breach_+0_refers_to_1.check @@ -0,0 +1 @@ +evaluated = 2
\ No newline at end of file diff --git a/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala b/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala new file mode 100644 index 0000000000..fe23bc8438 --- /dev/null +++ b/test/files/run/reify_metalevel_breach_+0_refers_to_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + val code = reify{ + val x = 2 + val inner = reify{x} + inner.eval + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.check b/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.check new file mode 100644 index 0000000000..5bfed17f8e --- /dev/null +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.check @@ -0,0 +1 @@ +evaluated = 2
\ No newline at end of file diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala new file mode 100644 index 0000000000..5d98a38592 --- /dev/null +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_0_a.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +object Test extends App { + val x = 2 + val outer = reify{reify{x}} + val code = reify{outer.eval.eval} + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.check b/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.check new file mode 100644 index 0000000000..5bfed17f8e --- /dev/null +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.check @@ -0,0 +1 @@ +evaluated = 2
\ No newline at end of file diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala new file mode 100644 index 0000000000..ca31d83acd --- /dev/null +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_0_b.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + val x = 2 + val code = reify{ + { + val inner = reify{reify{x}} + inner.eval + }.eval + } + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_1.check b/test/files/run/reify_metalevel_breach_-1_refers_to_1.check new file mode 100644 index 0000000000..5bfed17f8e --- /dev/null +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_1.check @@ -0,0 +1 @@ +evaluated = 2
\ No newline at end of file diff --git a/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala b/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala new file mode 100644 index 0000000000..56d85c6ba1 --- /dev/null +++ b/test/files/run/reify_metalevel_breach_-1_refers_to_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + val code = reify{ + val x = 2 + val inner = reify{reify{x}} + inner.eval.eval + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_nested_inner_refers_to_global.check b/test/files/run/reify_nested_inner_refers_to_global.check new file mode 100644 index 0000000000..7ff4c83d37 --- /dev/null +++ b/test/files/run/reify_nested_inner_refers_to_global.check @@ -0,0 +1 @@ +evaluated = 2
diff --git a/test/files/run/reify_nested_inner_refers_to_global.scala b/test/files/run/reify_nested_inner_refers_to_global.scala new file mode 100644 index 0000000000..14899bcf99 --- /dev/null +++ b/test/files/run/reify_nested_inner_refers_to_global.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + val code = { + val x = 2 + reify{ + reify{x}.eval + } + } + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_nested_inner_refers_to_local.check b/test/files/run/reify_nested_inner_refers_to_local.check new file mode 100644 index 0000000000..5bfed17f8e --- /dev/null +++ b/test/files/run/reify_nested_inner_refers_to_local.check @@ -0,0 +1 @@ +evaluated = 2
\ No newline at end of file diff --git a/test/files/run/reify_nested_inner_refers_to_local.scala b/test/files/run/reify_nested_inner_refers_to_local.scala new file mode 100644 index 0000000000..fd56585f72 --- /dev/null +++ b/test/files/run/reify_nested_inner_refers_to_local.scala @@ -0,0 +1,12 @@ +import scala.reflect.mirror._ + +object Test extends App { + val code = reify{ + val x = 2 + reify{x}.eval + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_nested_outer_refers_to_global.check b/test/files/run/reify_nested_outer_refers_to_global.check new file mode 100644 index 0000000000..7ff4c83d37 --- /dev/null +++ b/test/files/run/reify_nested_outer_refers_to_global.check @@ -0,0 +1 @@ +evaluated = 2
diff --git a/test/files/run/reify_nested_outer_refers_to_global.scala b/test/files/run/reify_nested_outer_refers_to_global.scala new file mode 100644 index 0000000000..f34e4fe04b --- /dev/null +++ b/test/files/run/reify_nested_outer_refers_to_global.scala @@ -0,0 +1,16 @@ +import scala.reflect.mirror._ + +object Test extends App { + val code = { + val x = 2 + val outer = reify{x} + reify{ + val x = 42 + outer.eval + }; + } + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_nested_outer_refers_to_local.check b/test/files/run/reify_nested_outer_refers_to_local.check new file mode 100644 index 0000000000..7ff4c83d37 --- /dev/null +++ b/test/files/run/reify_nested_outer_refers_to_local.check @@ -0,0 +1 @@ +evaluated = 2
diff --git a/test/files/run/reify_nested_outer_refers_to_local.scala b/test/files/run/reify_nested_outer_refers_to_local.scala new file mode 100644 index 0000000000..e16c851d8d --- /dev/null +++ b/test/files/run/reify_nested_outer_refers_to_local.scala @@ -0,0 +1,16 @@ +import scala.reflect.mirror._ + +object Test extends App { + val outer = { + val x = 2 + reify{x} + } + val code = reify{ + val x = 42 + outer.eval + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_newimpl_01.check b/test/files/run/reify_newimpl_01.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/reify_newimpl_01.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_01.scala b/test/files/run/reify_newimpl_01.scala new file mode 100644 index 0000000000..f7539a15b0 --- /dev/null +++ b/test/files/run/reify_newimpl_01.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val x = 2 + val code = reify { + x + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_02.check b/test/files/run/reify_newimpl_02.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/reify_newimpl_02.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_02.scala b/test/files/run/reify_newimpl_02.scala new file mode 100644 index 0000000000..2c085efa04 --- /dev/null +++ b/test/files/run/reify_newimpl_02.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var x = 2 + val code = reify { + x + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_03.check b/test/files/run/reify_newimpl_03.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/reify_newimpl_03.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_03.scala b/test/files/run/reify_newimpl_03.scala new file mode 100644 index 0000000000..361cfc50bb --- /dev/null +++ b/test/files/run/reify_newimpl_03.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val code = reify { + val x = 2 + reify{x}.eval + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_04.check b/test/files/run/reify_newimpl_04.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/reify_newimpl_04.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_04.scala b/test/files/run/reify_newimpl_04.scala new file mode 100644 index 0000000000..d80a7c9ffd --- /dev/null +++ b/test/files/run/reify_newimpl_04.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val code = reify { + var x = 2 + reify{x}.eval + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_05.check b/test/files/run/reify_newimpl_05.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/reify_newimpl_05.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_05.scala b/test/files/run/reify_newimpl_05.scala new file mode 100644 index 0000000000..85c1711bdb --- /dev/null +++ b/test/files/run/reify_newimpl_05.scala @@ -0,0 +1,12 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val code = reify { + var x = 2 + def y = x // forcibly captures x + reify{x}.eval + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_06.check b/test/files/run/reify_newimpl_06.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/reify_newimpl_06.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_06.scala b/test/files/run/reify_newimpl_06.scala new file mode 100644 index 0000000000..257b54167a --- /dev/null +++ b/test/files/run/reify_newimpl_06.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C(val y: Int) { + val code = reify { + reify{y}.eval + } + } + + println(new C(2).code.eval) +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_09.check b/test/files/run/reify_newimpl_09.check new file mode 100644 index 0000000000..220bd6875a --- /dev/null +++ b/test/files/run/reify_newimpl_09.check @@ -0,0 +1 @@ +List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_09.scala b/test/files/run/reify_newimpl_09.scala new file mode 100644 index 0000000000..2c81945a2a --- /dev/null +++ b/test/files/run/reify_newimpl_09.scala @@ -0,0 +1,11 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + type T = Int + val code = reify { + List[T](2) + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_10.check b/test/files/run/reify_newimpl_10.check new file mode 100644 index 0000000000..220bd6875a --- /dev/null +++ b/test/files/run/reify_newimpl_10.check @@ -0,0 +1 @@ +List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_10.scala b/test/files/run/reify_newimpl_10.scala new file mode 100644 index 0000000000..6e70b4d216 --- /dev/null +++ b/test/files/run/reify_newimpl_10.scala @@ -0,0 +1,12 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + type T = Int + implicit val tt = implicitly[TypeTag[String]].asInstanceOf[TypeTag[T]] // this "mistake" is made for a reason! + val code = reify { + List[T](2) + } + println(code.eval) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_11.check b/test/files/run/reify_newimpl_11.check new file mode 100644 index 0000000000..e2a8206132 --- /dev/null +++ b/test/files/run/reify_newimpl_11.check @@ -0,0 +1,2 @@ +scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective toolbox has failed:
+unresolved free type variables (namely: T defined by C in reify_newimpl_11.scala:4:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_11.scala b/test/files/run/reify_newimpl_11.scala new file mode 100644 index 0000000000..4e91c7a457 --- /dev/null +++ b/test/files/run/reify_newimpl_11.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C[T] { + val code = reify { + List[T](2.asInstanceOf[T]) + } + println(code.eval) + } + + try { + new C[Int] + } catch { + case ex: Throwable => + println(ex) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_12.check b/test/files/run/reify_newimpl_12.check new file mode 100644 index 0000000000..220bd6875a --- /dev/null +++ b/test/files/run/reify_newimpl_12.check @@ -0,0 +1 @@ +List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_12.scala b/test/files/run/reify_newimpl_12.scala new file mode 100644 index 0000000000..433168ce28 --- /dev/null +++ b/test/files/run/reify_newimpl_12.scala @@ -0,0 +1,12 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C[T: TypeTag] { + val code = reify { + List[T](2.asInstanceOf[T]) + } + println(code.eval) + } + + new C[Int] +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_13.check b/test/files/run/reify_newimpl_13.check new file mode 100644 index 0000000000..7c47310cf2 --- /dev/null +++ b/test/files/run/reify_newimpl_13.check @@ -0,0 +1,2 @@ +scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective toolbox has failed:
+unresolved free type variables (namely: T defined by C in reify_newimpl_13.scala:5:13). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_13.scala b/test/files/run/reify_newimpl_13.scala new file mode 100644 index 0000000000..dd1980b74f --- /dev/null +++ b/test/files/run/reify_newimpl_13.scala @@ -0,0 +1,19 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + class C[T] { + val code = reify { + List[T](2.asInstanceOf[T]) + } + println(code.eval) + } + + try { + new C[Int] + } catch { + case ex: Throwable => + println(ex) + } + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_14.check b/test/files/run/reify_newimpl_14.check new file mode 100644 index 0000000000..220bd6875a --- /dev/null +++ b/test/files/run/reify_newimpl_14.check @@ -0,0 +1 @@ +List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_14.scala b/test/files/run/reify_newimpl_14.scala new file mode 100644 index 0000000000..3f52f19cfb --- /dev/null +++ b/test/files/run/reify_newimpl_14.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + class C[T: TypeTag] { + val code = reify { + List[T](2.asInstanceOf[T]) + } + println(code.eval) + } + + new C[Int] + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_15.check b/test/files/run/reify_newimpl_15.check new file mode 100644 index 0000000000..220bd6875a --- /dev/null +++ b/test/files/run/reify_newimpl_15.check @@ -0,0 +1 @@ +List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_15.scala b/test/files/run/reify_newimpl_15.scala new file mode 100644 index 0000000000..b707b2583d --- /dev/null +++ b/test/files/run/reify_newimpl_15.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C { + type T = Int + val code = reify { + List[T](2) + } + println(code.eval) + } + + new C +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_16.check b/test/files/run/reify_newimpl_16.check new file mode 100644 index 0000000000..220bd6875a --- /dev/null +++ b/test/files/run/reify_newimpl_16.check @@ -0,0 +1 @@ +List(2)
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_16.scala b/test/files/run/reify_newimpl_16.scala new file mode 100644 index 0000000000..98fc15878c --- /dev/null +++ b/test/files/run/reify_newimpl_16.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + class C { + type T = Int + val code = reify { + List[T](2) + } + println(code.eval) + } + + new C + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_17.check b/test/files/run/reify_newimpl_17.check new file mode 100644 index 0000000000..0fb9ddfc2d --- /dev/null +++ b/test/files/run/reify_newimpl_17.check @@ -0,0 +1,2 @@ +scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective toolbox has failed:
+unresolved free type variables (namely: U defined by C in reify_newimpl_17.scala:4:11). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_17.scala b/test/files/run/reify_newimpl_17.scala new file mode 100644 index 0000000000..331777fcfb --- /dev/null +++ b/test/files/run/reify_newimpl_17.scala @@ -0,0 +1,18 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C[U] { + type T = U + val code = reify { + List[T](2.asInstanceOf[T]) + } + println(code.eval) + } + + try { + new C[Int] + } catch { + case ex: Throwable => + println(ex) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_18.check b/test/files/run/reify_newimpl_18.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_18.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_18.scala b/test/files/run/reify_newimpl_18.scala new file mode 100644 index 0000000000..704e54928a --- /dev/null +++ b/test/files/run/reify_newimpl_18.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C[U: TypeTag] { + type T = U + val code = reify { + List[T](2.asInstanceOf[T]) + } + println(code.eval) + } + + new C[Int] +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_19.check b/test/files/run/reify_newimpl_19.check new file mode 100644 index 0000000000..32f9300f53 --- /dev/null +++ b/test/files/run/reify_newimpl_19.check @@ -0,0 +1,2 @@ +scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective toolbox has failed:
+unresolved free type variables (namely: T defined by C in reify_newimpl_19.scala:5:10). have you forgot to use TypeTag annotations for type parameters external to a reifee? if you have troubles tracking free type variables, consider using -Xlog-free-types
diff --git a/test/files/run/reify_newimpl_19.scala b/test/files/run/reify_newimpl_19.scala new file mode 100644 index 0000000000..0ea8ae6992 --- /dev/null +++ b/test/files/run/reify_newimpl_19.scala @@ -0,0 +1,18 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C { + type T + val code = reify { + List[T](2.asInstanceOf[T]) + } + println(code.eval) + } + + try { + new C { val T = Int } + } catch { + case ex: Throwable => + println(ex) + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_20.check b/test/files/run/reify_newimpl_20.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_20.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_20.scala b/test/files/run/reify_newimpl_20.scala new file mode 100644 index 0000000000..16895a449e --- /dev/null +++ b/test/files/run/reify_newimpl_20.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C { + type T + implicit val tt: TypeTag[T] = implicitly[TypeTag[Int]].asInstanceOf[TypeTag[T]] + val code = reify { + List[T](2.asInstanceOf[T]) + } + println(code.eval) + } + + new C { type T = String } // this "mistake" is made for a reason! +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_21.check b/test/files/run/reify_newimpl_21.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_21.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_21.scala b/test/files/run/reify_newimpl_21.scala new file mode 100644 index 0000000000..99f9ac9089 --- /dev/null +++ b/test/files/run/reify_newimpl_21.scala @@ -0,0 +1,18 @@ +import scala.reflect.mirror._ + +object Test extends App { + trait C { + type T + implicit val tt: TypeTag[T] + lazy val code = reify { + List[T](2.asInstanceOf[T]) + } + } + + class D extends C { + type T = String // this "mistake" is made for a reason! + override val tt: TypeTag[T] = implicitly[TypeTag[Int]].asInstanceOf[TypeTag[T]] + } + + println((new D).code.eval) +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_22.check b/test/files/run/reify_newimpl_22.check new file mode 100644 index 0000000000..51699cbc29 --- /dev/null +++ b/test/files/run/reify_newimpl_22.check @@ -0,0 +1,23 @@ +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.mirror._
+import scala.reflect.mirror._
+
+scala> {
+ val x = 2
+ val code = reify {
+ x
+ }
+ println(code.eval)
+}
+<console>:13: free term: Ident(newTermName("x")) defined by res0 in <console>:12:21
+ val code = reify {
+ ^
+2
+
+scala>
+
+scala>
diff --git a/test/files/run/reify_newimpl_22.scala b/test/files/run/reify_newimpl_22.scala new file mode 100644 index 0000000000..a211ad360c --- /dev/null +++ b/test/files/run/reify_newimpl_22.scala @@ -0,0 +1,15 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def extraSettings = "-Xlog-free-terms" + def code = """ +import scala.reflect.mirror._ +{ + val x = 2 + val code = reify { + x + } + println(code.eval) +} + """ +} diff --git a/test/files/run/reify_newimpl_23.check b/test/files/run/reify_newimpl_23.check new file mode 100644 index 0000000000..33d15190fb --- /dev/null +++ b/test/files/run/reify_newimpl_23.check @@ -0,0 +1,22 @@ +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.mirror._
+import scala.reflect.mirror._
+
+scala> def foo[T]{
+ val code = reify {
+ List[T]()
+ }
+ println(code.eval)
+}
+<console>:11: free type: Ident(newTypeName("T")) defined by foo in <console>:10:16
+ val code = reify {
+ ^
+foo: [T]=> Unit
+
+scala>
+
+scala>
diff --git a/test/files/run/reify_newimpl_23.scala b/test/files/run/reify_newimpl_23.scala new file mode 100644 index 0000000000..15da4e497e --- /dev/null +++ b/test/files/run/reify_newimpl_23.scala @@ -0,0 +1,14 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def extraSettings = "-Xlog-free-types" + def code = """ +import scala.reflect.mirror._ +def foo[T]{ + val code = reify { + List[T]() + } + println(code.eval) +} + """ +} diff --git a/test/files/run/reify_newimpl_24.check b/test/files/run/reify_newimpl_24.check new file mode 100644 index 0000000000..66b18c790e --- /dev/null +++ b/test/files/run/reify_newimpl_24.check @@ -0,0 +1,24 @@ +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.mirror._
+import scala.reflect.mirror._
+
+scala> {
+ val x = 2
+ val code = reify {
+ val y = reify { x }
+ y.eval
+ }
+ println(code.eval)
+}
+<console>:15: this splice cannot be resolved statically
+ y.eval
+ ^
+2
+
+scala>
+
+scala>
diff --git a/test/files/run/reify_newimpl_24.scala b/test/files/run/reify_newimpl_24.scala new file mode 100644 index 0000000000..7b21eeeb10 --- /dev/null +++ b/test/files/run/reify_newimpl_24.scala @@ -0,0 +1,16 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def extraSettings = "-Xlog-runtime-splices" + def code = """ +import scala.reflect.mirror._ +{ + val x = 2 + val code = reify { + val y = reify { x } + y.eval + } + println(code.eval) +} + """ +} diff --git a/test/files/run/reify_newimpl_25.check b/test/files/run/reify_newimpl_25.check new file mode 100644 index 0000000000..37ff83c9ee --- /dev/null +++ b/test/files/run/reify_newimpl_25.check @@ -0,0 +1,21 @@ +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.mirror._
+import scala.reflect.mirror._
+
+scala> {
+ val x = "2"
+ val tt = implicitly[TypeTag[x.type]]
+ println(tt)
+}
+<console>:13: free term: Ident(newTermName("x")) defined by res0 in <console>:12:21
+ val tt = implicitly[TypeTag[x.type]]
+ ^
+ConcreteTypeTag[x.type]
+
+scala>
+
+scala>
diff --git a/test/files/run/reify_newimpl_25.scala b/test/files/run/reify_newimpl_25.scala new file mode 100644 index 0000000000..1f66f5e681 --- /dev/null +++ b/test/files/run/reify_newimpl_25.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def extraSettings = "-Xlog-free-terms" + def code = """ +import scala.reflect.mirror._ +{ + val x = "2" + val tt = implicitly[TypeTag[x.type]] + println(tt) +} + """ +} diff --git a/test/files/run/reify_newimpl_26.check b/test/files/run/reify_newimpl_26.check new file mode 100644 index 0000000000..bfbf1d653d --- /dev/null +++ b/test/files/run/reify_newimpl_26.check @@ -0,0 +1,23 @@ +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.mirror._
+import scala.reflect.mirror._
+
+scala> def foo[T]{
+ val tt = implicitly[TypeTag[List[T]]]
+ println(tt)
+}
+<console>:11: free type: Ident(newTypeName("T")) defined by foo in <console>:10:16
+ val tt = implicitly[TypeTag[List[T]]]
+ ^
+foo: [T]=> Unit
+
+scala> foo[Int]
+ConcreteTypeTag[List[T]]
+
+scala>
+
+scala>
diff --git a/test/files/run/reify_newimpl_26.scala b/test/files/run/reify_newimpl_26.scala new file mode 100644 index 0000000000..f2dd1bfc4e --- /dev/null +++ b/test/files/run/reify_newimpl_26.scala @@ -0,0 +1,13 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def extraSettings = "-Xlog-free-types" + def code = """ +import scala.reflect.mirror._ +def foo[T]{ + val tt = implicitly[TypeTag[List[T]]] + println(tt) +} +foo[Int] + """ +} diff --git a/test/files/run/reify_newimpl_27.check b/test/files/run/reify_newimpl_27.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_27.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_27.scala b/test/files/run/reify_newimpl_27.scala new file mode 100644 index 0000000000..b3d6d5c865 --- /dev/null +++ b/test/files/run/reify_newimpl_27.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + object C { + type T = Int + val code = reify { + List[T](2) + } + println(code.eval) + } + + C +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_28.check b/test/files/run/reify_newimpl_28.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_28.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_28.scala b/test/files/run/reify_newimpl_28.scala new file mode 100644 index 0000000000..f7874b8548 --- /dev/null +++ b/test/files/run/reify_newimpl_28.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + object C { + type T = Int + val code = reify { + List[T](2) + } + println(code.eval) + } + + C + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_29.check b/test/files/run/reify_newimpl_29.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_29.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_29.scala b/test/files/run/reify_newimpl_29.scala new file mode 100644 index 0000000000..e32762f335 --- /dev/null +++ b/test/files/run/reify_newimpl_29.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C { + type T = Int + val code = reify { + List[C#T](2) + } + println(code.eval) + } + + new C +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_30.check b/test/files/run/reify_newimpl_30.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_30.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_30.scala b/test/files/run/reify_newimpl_30.scala new file mode 100644 index 0000000000..e4ba3221e1 --- /dev/null +++ b/test/files/run/reify_newimpl_30.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + class C { + type T = Int + val code = reify { + List[C#T](2) + } + println(code.eval) + } + + new C + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_31.check b/test/files/run/reify_newimpl_31.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_31.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_31.scala b/test/files/run/reify_newimpl_31.scala new file mode 100644 index 0000000000..20a851e32e --- /dev/null +++ b/test/files/run/reify_newimpl_31.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + object C { + type T = Int + val code = reify { + List[C.T](2) + } + println(code.eval) + } + + C +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_32.check b/test/files/run/reify_newimpl_32.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_32.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_32.scala b/test/files/run/reify_newimpl_32.scala new file mode 100644 index 0000000000..788486ec00 --- /dev/null +++ b/test/files/run/reify_newimpl_32.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + object C { + type T = Int + val code = reify { + List[C.T](2) + } + println(code.eval) + } + + C + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_33.check b/test/files/run/reify_newimpl_33.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_33.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_33.scala b/test/files/run/reify_newimpl_33.scala new file mode 100644 index 0000000000..84a8258256 --- /dev/null +++ b/test/files/run/reify_newimpl_33.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + object C { + type T = Int + val c = C + val code = reify { + List[c.T](2) + } + println(code.eval) + } + + C +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_34.check b/test/files/run/reify_newimpl_34.check new file mode 100644 index 0000000000..a7029974a4 --- /dev/null +++ b/test/files/run/reify_newimpl_34.check @@ -0,0 +1 @@ +List(2)
diff --git a/test/files/run/reify_newimpl_34.scala b/test/files/run/reify_newimpl_34.scala new file mode 100644 index 0000000000..5935ab385c --- /dev/null +++ b/test/files/run/reify_newimpl_34.scala @@ -0,0 +1,16 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + object C { + type T = Int + lazy val c = C + val code = reify { + List[c.T](2) + } + println(code.eval) + } + + C + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_36.check b/test/files/run/reify_newimpl_36.check new file mode 100644 index 0000000000..2f562a182f --- /dev/null +++ b/test/files/run/reify_newimpl_36.check @@ -0,0 +1 @@ +42
diff --git a/test/files/run/reify_newimpl_36.scala b/test/files/run/reify_newimpl_36.scala new file mode 100644 index 0000000000..c76efce27a --- /dev/null +++ b/test/files/run/reify_newimpl_36.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val x = 42 + def foo() = reify(reify(x)); + { + val x = 2 + val code1 = foo() + val code2 = code1.eval + println(code2.eval) + } + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_37.check b/test/files/run/reify_newimpl_37.check new file mode 100644 index 0000000000..2f562a182f --- /dev/null +++ b/test/files/run/reify_newimpl_37.check @@ -0,0 +1 @@ +42
diff --git a/test/files/run/reify_newimpl_37.scala b/test/files/run/reify_newimpl_37.scala new file mode 100644 index 0000000000..e83d35dbe1 --- /dev/null +++ b/test/files/run/reify_newimpl_37.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val x = 42 + def foo() = reify(reify(reify(x))); + { + val x = 2 + val code1 = foo() + val code2 = code1.eval + val code3 = code2.eval + println(code3.eval) + } + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_38.check b/test/files/run/reify_newimpl_38.check new file mode 100644 index 0000000000..2f562a182f --- /dev/null +++ b/test/files/run/reify_newimpl_38.check @@ -0,0 +1 @@ +42
diff --git a/test/files/run/reify_newimpl_38.scala b/test/files/run/reify_newimpl_38.scala new file mode 100644 index 0000000000..70ef49ecf7 --- /dev/null +++ b/test/files/run/reify_newimpl_38.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val x = 42 + def foo() = reify{ val y = x; reify(y) }; + { + val x = 2 + val code1 = foo() + val code2 = code1.eval + println(code2.eval) + } + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_39.check b/test/files/run/reify_newimpl_39.check new file mode 100644 index 0000000000..2f562a182f --- /dev/null +++ b/test/files/run/reify_newimpl_39.check @@ -0,0 +1 @@ +42
diff --git a/test/files/run/reify_newimpl_39.scala b/test/files/run/reify_newimpl_39.scala new file mode 100644 index 0000000000..faa45d917d --- /dev/null +++ b/test/files/run/reify_newimpl_39.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val x = 42 + def foo() = reify{ val y = x; reify{ val z = y; reify(z) } }; + { + val x = 2 + val code1 = foo() + val code2 = code1.eval + val code3 = code2.eval + println(code3.eval) + } + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_40.check b/test/files/run/reify_newimpl_40.check new file mode 100644 index 0000000000..94c5a65fe0 --- /dev/null +++ b/test/files/run/reify_newimpl_40.check @@ -0,0 +1 @@ +74088
diff --git a/test/files/run/reify_newimpl_40.scala b/test/files/run/reify_newimpl_40.scala new file mode 100644 index 0000000000..a983a92324 --- /dev/null +++ b/test/files/run/reify_newimpl_40.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + val x = 42 + def foo() = reify{ val y = x; reify{ val z = y * x; reify(z * x) } }; + { + val x = 2 + val code1 = foo() + val code2 = code1.eval + val code3 = code2.eval + println(code3.eval) + } + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_41.check b/test/files/run/reify_newimpl_41.check new file mode 100644 index 0000000000..0b427f2ee6 --- /dev/null +++ b/test/files/run/reify_newimpl_41.check @@ -0,0 +1,3 @@ +42 +44 +43
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_41.scala b/test/files/run/reify_newimpl_41.scala new file mode 100644 index 0000000000..9aedccc98a --- /dev/null +++ b/test/files/run/reify_newimpl_41.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var _x = 42 + def x = { val x0 = _x; _x += 1; x0 } + var _y = 1 + def y = { val y0 = _y + _x; _y += y0; y0 } + val code = reify { + def foo = y // ensures that y is the first freevar we find + println(x) + println(y) + println(x) + } + code.eval + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_42.check b/test/files/run/reify_newimpl_42.check new file mode 100644 index 0000000000..0b427f2ee6 --- /dev/null +++ b/test/files/run/reify_newimpl_42.check @@ -0,0 +1,3 @@ +42 +44 +43
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_42.scala b/test/files/run/reify_newimpl_42.scala new file mode 100644 index 0000000000..1e21bd59bc --- /dev/null +++ b/test/files/run/reify_newimpl_42.scala @@ -0,0 +1,16 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var _x = 42 + def x = { val x0 = _x; _x += 1; x0 } + var _y = 1 + def y = { val y0 = _y + _x; _y += y0; y0 } + val code = reify { + println(x) + println(y) + println(x) + } + code.eval + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_43.check b/test/files/run/reify_newimpl_43.check new file mode 100644 index 0000000000..7a754f414c --- /dev/null +++ b/test/files/run/reify_newimpl_43.check @@ -0,0 +1,2 @@ +1 +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_43.scala b/test/files/run/reify_newimpl_43.scala new file mode 100644 index 0000000000..962461db8b --- /dev/null +++ b/test/files/run/reify_newimpl_43.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var counter = 0 + lazy val x = { counter += 1; counter } + lazy val y = { counter += 1; counter } + val code = reify { + def foo = y // ensures that y is the first freevar we find + println(x) + println(y) + } + code.eval + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_44.check b/test/files/run/reify_newimpl_44.check new file mode 100644 index 0000000000..7a754f414c --- /dev/null +++ b/test/files/run/reify_newimpl_44.check @@ -0,0 +1,2 @@ +1 +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_44.scala b/test/files/run/reify_newimpl_44.scala new file mode 100644 index 0000000000..962461db8b --- /dev/null +++ b/test/files/run/reify_newimpl_44.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var counter = 0 + lazy val x = { counter += 1; counter } + lazy val y = { counter += 1; counter } + val code = reify { + def foo = y // ensures that y is the first freevar we find + println(x) + println(y) + } + code.eval + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_45.check b/test/files/run/reify_newimpl_45.check new file mode 100644 index 0000000000..6e14f71e26 --- /dev/null +++ b/test/files/run/reify_newimpl_45.check @@ -0,0 +1,2 @@ +List(free type T) +ima worx: 2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_45.scala b/test/files/run/reify_newimpl_45.scala new file mode 100644 index 0000000000..241b7d4bc3 --- /dev/null +++ b/test/files/run/reify_newimpl_45.scala @@ -0,0 +1,12 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C[T >: Null] { + val code = reify{val x: T = "2".asInstanceOf[T]; println("ima worx: %s".format(x)); x} + println(freeTypes(code)) + val T = freeTypes(code)(0) + mkToolBox().runExpr(code, Map(T -> definitions.StringClass.asType)) + } + + new C[String] +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_47.check b/test/files/run/reify_newimpl_47.check new file mode 100644 index 0000000000..d8263ee986 --- /dev/null +++ b/test/files/run/reify_newimpl_47.check @@ -0,0 +1 @@ +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_47.scala b/test/files/run/reify_newimpl_47.scala new file mode 100644 index 0000000000..bd1bd1fe65 --- /dev/null +++ b/test/files/run/reify_newimpl_47.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + val outer = { + val x = 2 + reify{x} + } + + val code = reify{ + val x = 42 + outer.eval + } + + println(code.eval) +} diff --git a/test/files/run/reify_newimpl_48.check b/test/files/run/reify_newimpl_48.check new file mode 100644 index 0000000000..f11c82a4cb --- /dev/null +++ b/test/files/run/reify_newimpl_48.check @@ -0,0 +1 @@ +9
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_48.scala b/test/files/run/reify_newimpl_48.scala new file mode 100644 index 0000000000..1522509907 --- /dev/null +++ b/test/files/run/reify_newimpl_48.scala @@ -0,0 +1,20 @@ +import scala.reflect.mirror._ + +object Test extends App { + val outer1 = { + val x = 2 + reify{x} + } + + val outer2 = { + val x = 3 + reify{x} + } + + val code = reify{ + val x = 4 + x + outer1.eval + outer2.eval + } + + println(code.eval) +} diff --git a/test/files/run/reify_newimpl_49.check b/test/files/run/reify_newimpl_49.check new file mode 100644 index 0000000000..d8a621df00 --- /dev/null +++ b/test/files/run/reify_newimpl_49.check @@ -0,0 +1,3 @@ +3 +3 +5
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_49.scala b/test/files/run/reify_newimpl_49.scala new file mode 100644 index 0000000000..68d968e28b --- /dev/null +++ b/test/files/run/reify_newimpl_49.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var y = 1 + def x = { y += 2; y } + val code = reify { + def foo = y // ensures that y is the first freevar we find + println(x) + println(y) + println(x) + } + code.eval + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_50.check b/test/files/run/reify_newimpl_50.check new file mode 100644 index 0000000000..d8a621df00 --- /dev/null +++ b/test/files/run/reify_newimpl_50.check @@ -0,0 +1,3 @@ +3 +3 +5
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_50.scala b/test/files/run/reify_newimpl_50.scala new file mode 100644 index 0000000000..b81d72a4eb --- /dev/null +++ b/test/files/run/reify_newimpl_50.scala @@ -0,0 +1,14 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var y = 1 + def x = { y += 2; y } + val code = reify { + println(x) + println(y) + println(x) + } + code.eval + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_51.check b/test/files/run/reify_newimpl_51.check new file mode 100644 index 0000000000..9a4ddeacd3 --- /dev/null +++ b/test/files/run/reify_newimpl_51.check @@ -0,0 +1,3 @@ +2 +1 +2
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_51.scala b/test/files/run/reify_newimpl_51.scala new file mode 100644 index 0000000000..ccbae2e160 --- /dev/null +++ b/test/files/run/reify_newimpl_51.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var counter = 0 + lazy val x = { counter += 1; counter } + lazy val y = { counter += 1; counter } + val code = reify { + def foo = y // ensures that y is the first freevar we find + val bar = reify { println(x * y) } + bar.eval + println(x) + println(y) + } + code.eval + } +}
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_52.check b/test/files/run/reify_newimpl_52.check new file mode 100644 index 0000000000..9359a2b211 --- /dev/null +++ b/test/files/run/reify_newimpl_52.check @@ -0,0 +1,3 @@ +2 +2 +1
\ No newline at end of file diff --git a/test/files/run/reify_newimpl_52.scala b/test/files/run/reify_newimpl_52.scala new file mode 100644 index 0000000000..60b16d3618 --- /dev/null +++ b/test/files/run/reify_newimpl_52.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object Test extends App { + { + var counter = 0 + lazy val x = { counter += 1; counter } + lazy val y = { counter += 1; counter } + val code = reify { + def foo = y // ensures that y is the first freevar we find + val bar = reify { println(y * x) } + bar.eval + println(x) + println(y) + } + code.eval + } +}
\ No newline at end of file diff --git a/test/files/run/reify_printf.scala b/test/files/run/reify_printf.scala index cd6052bc5e..dc092c1a85 100644 --- a/test/files/run/reify_printf.scala +++ b/test/files/run/reify_printf.scala @@ -1,19 +1,15 @@ import java.io.{ ByteArrayOutputStream, PrintStream } -import scala.reflect.Code import scala.reflect.mirror._ import scala.reflect.api._ import scala.reflect.api.Trees import scala.reflect.internal.Types -import reflect.runtime.Mirror.ToolBox -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings import scala.util.matching.Regex object Test extends App { - val tree = tree_printf(Code.lift("hello %s").tree, Code.lift("world").tree) + val tree = tree_printf(reify("hello %s").tree, reify("world").tree) - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter, args mkString " ") + import scala.reflect.mirror._ + val toolbox = mkToolBox() val output = new ByteArrayOutputStream() Console.setOut(new PrintStream(output)) @@ -22,6 +18,7 @@ object Test extends App { assert(output.toString() == "hello world", output.toString() +" == hello world") /* + // upd. Oh, good old times, our very-very first experiments with macros :) macro def printf(format: String, params: Any*) : String = tree_printf(format: Tree, (params: Seq[Tree]): _*) */ diff --git a/test/files/run/reify_sort.scala b/test/files/run/reify_sort.scala index 5984a64967..0b373b358f 100644 --- a/test/files/run/reify_sort.scala +++ b/test/files/run/reify_sort.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { /** Nested methods can use and even update everything * visible in their scope (including local variables or * arguments of enclosing methods). @@ -48,9 +46,5 @@ object Test extends App { println(ar) sort(ar) println(ar) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_sort1.scala b/test/files/run/reify_sort1.scala index 6f365dea26..56125619e9 100644 --- a/test/files/run/reify_sort1.scala +++ b/test/files/run/reify_sort1.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { def sort(a: List[Int]): List[Int] = { if (a.length < 2) a @@ -18,9 +16,5 @@ object Test extends App { val xs = List(6, 2, 8, 5, 1) println(xs) println(sort(xs)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_this.scala b/test/files/run/reify_this.scala index ee1f116013..280d735ab6 100644 --- a/test/files/run/reify_this.scala +++ b/test/files/run/reify_this.scala @@ -1,30 +1,19 @@ -import scala.reflect._ -import scala.reflect.Code._ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ trait Eval { - def eval(code: Code): Any = eval(code.tree) - - def eval(tree: Tree): Any = { - val settings = new Settings - val reporter = new ConsoleReporter(settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(tree) - } + def eval(tree: Expr[_]) = tree.eval } object Test extends App with Eval { // select a value from package - eval(lift{println("foo")}) - eval(lift{println((new Object).toString == (new Object).toString)}) + eval(reify{println("foo")}) + eval(reify{println((new Object).toString == (new Object).toString)}) // select a type from package - eval(lift{val x: Any = 2; println(x)}) - eval(lift{val x: Object = "bar"; println(x)}) + eval(reify{val x: Any = 2; println(x)}) + eval(reify{val x: Object = "bar"; println(x)}) // select a value from module val x = 2 - eval(lift{println(x)}) + eval(reify{println(x)}) } diff --git a/test/files/run/reify_timeofday.scala b/test/files/run/reify_timeofday.scala index 122d7a6d52..481ab04df5 100644 --- a/test/files/run/reify_timeofday.scala +++ b/test/files/run/reify_timeofday.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class DateError extends Exception /** Simulating properties in Scala @@ -39,9 +37,5 @@ object Test extends App { case de: DateError => println("DateError") case e: Exception => println("Exception") } - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/reify_typerefs_1a.check b/test/files/run/reify_typerefs_1a.check new file mode 100644 index 0000000000..919c298ba3 --- /dev/null +++ b/test/files/run/reify_typerefs_1a.check @@ -0,0 +1 @@ +evaluated = List(Expression, Expression)
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_1a.scala b/test/files/run/reify_typerefs_1a.scala new file mode 100644 index 0000000000..15d8d17835 --- /dev/null +++ b/test/files/run/reify_typerefs_1a.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +class Expression { + override def toString = "Expression" +} + +object Test extends App { + val code = reify { + List(new Expression, new Expression) + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_typerefs_1b.check b/test/files/run/reify_typerefs_1b.check new file mode 100644 index 0000000000..919c298ba3 --- /dev/null +++ b/test/files/run/reify_typerefs_1b.check @@ -0,0 +1 @@ +evaluated = List(Expression, Expression)
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_1b.scala b/test/files/run/reify_typerefs_1b.scala new file mode 100644 index 0000000000..06ce1e35ac --- /dev/null +++ b/test/files/run/reify_typerefs_1b.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Expression { + override def toString = "Expression" +} + +object Test extends App { + val code = reify { + List(Expression, Expression) + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_typerefs_2a.check b/test/files/run/reify_typerefs_2a.check new file mode 100644 index 0000000000..919c298ba3 --- /dev/null +++ b/test/files/run/reify_typerefs_2a.check @@ -0,0 +1 @@ +evaluated = List(Expression, Expression)
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_2a.scala b/test/files/run/reify_typerefs_2a.scala new file mode 100644 index 0000000000..d03efea222 --- /dev/null +++ b/test/files/run/reify_typerefs_2a.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +package foo { + class Expression { + override def toString = "Expression" + } +} + +object Test extends App { + val code = reify { + List(new foo.Expression, new foo.Expression) + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_typerefs_2b.check b/test/files/run/reify_typerefs_2b.check new file mode 100644 index 0000000000..919c298ba3 --- /dev/null +++ b/test/files/run/reify_typerefs_2b.check @@ -0,0 +1 @@ +evaluated = List(Expression, Expression)
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_2b.scala b/test/files/run/reify_typerefs_2b.scala new file mode 100644 index 0000000000..3d9f7d61b8 --- /dev/null +++ b/test/files/run/reify_typerefs_2b.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +package foo { + object Expression { + override def toString = "Expression" + } +} + +object Test extends App { + val code = reify { + List(foo.Expression, foo.Expression) + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_typerefs_3a.check b/test/files/run/reify_typerefs_3a.check new file mode 100644 index 0000000000..919c298ba3 --- /dev/null +++ b/test/files/run/reify_typerefs_3a.check @@ -0,0 +1 @@ +evaluated = List(Expression, Expression)
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_3a.scala b/test/files/run/reify_typerefs_3a.scala new file mode 100644 index 0000000000..4128073f60 --- /dev/null +++ b/test/files/run/reify_typerefs_3a.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object foo { + class Expression { + override def toString = "Expression" + } +} + +object Test extends App { + val code = reify { + List(new foo.Expression, new foo.Expression) + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_typerefs_3b.check b/test/files/run/reify_typerefs_3b.check new file mode 100644 index 0000000000..919c298ba3 --- /dev/null +++ b/test/files/run/reify_typerefs_3b.check @@ -0,0 +1 @@ +evaluated = List(Expression, Expression)
\ No newline at end of file diff --git a/test/files/run/reify_typerefs_3b.scala b/test/files/run/reify_typerefs_3b.scala new file mode 100644 index 0000000000..a7ede00c9c --- /dev/null +++ b/test/files/run/reify_typerefs_3b.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object foo { + object Expression { + override def toString = "Expression" + } +} + +object Test extends App { + val code = reify { + List(foo.Expression, foo.Expression) + }; + + val toolbox = mkToolBox() + val evaluated = toolbox.runExpr(code.tree) + println("evaluated = " + evaluated) +} diff --git a/test/files/run/reify_varargs.scala b/test/files/run/reify_varargs.scala index 175cfb5db0..fe8f03b702 100644 --- a/test/files/run/reify_varargs.scala +++ b/test/files/run/reify_varargs.scala @@ -1,16 +1,10 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { val msg = java.text.MessageFormat.format( "On {1} there was {2} on planet {0}.", "Hoth", "the fifth of August", "a disturbance in the Force") println("Message="+msg) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/repl-power.check b/test/files/run/repl-power.check index 1e7b6f0cd8..b811a4a8c5 100644 --- a/test/files/run/repl-power.check +++ b/test/files/run/repl-power.check @@ -1,32 +1,32 @@ -Type in expressions to have them evaluated. -Type :help for more information. - -scala> :power -** Power User mode enabled - BEEP WHIR GYVE ** -** :phase has been set to 'typer'. ** -** scala.tools.nsc._ has been imported ** -** global._, definitions._ also imported ** -** Try :help, :vals, power.<tab> ** - -scala> // guarding against "error: reference to global is ambiguous" - -scala> global.emptyValDef // "it is imported twice in the same scope by ..." -res0: $r.global.emptyValDef.type = private val _ = _ - -scala> val tp = ArrayClass[scala.util.Random] // magic with manifests -tp: $r.global.Type = Array[scala.util.Random] - -scala> tp.memberType(Array_apply) // evidence -res1: $r.global.Type = (i: Int)scala.util.Random - -scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl -m: $r.treedsl.global.Match = -10 match { - case 5 => false - case _ => true -} - -scala> typed(m).tpe // typed is in scope -res2: $r.treedsl.global.Type = Boolean - -scala> +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala> :power
+** Power User mode enabled - BEEP WHIR GYVE **
+** :phase has been set to 'typer'. **
+** scala.tools.nsc._ has been imported **
+** global._, definitions._ also imported **
+** Try :help, :vals, power.<tab> **
+
+scala> // guarding against "error: reference to global is ambiguous"
+
+scala> global.emptyValDef // "it is imported twice in the same scope by ..."
+res0: $r.global.emptyValDef.type = private val _ = _
+
+scala> val tp = ArrayClass[scala.util.Random] // magic with manifests
+tp: $r.global.Type = Array[scala.util.Random]
+
+scala> tp.memberType(Array_apply) // evidence
+res1: $r.global.Type = (i: Int)scala.util.Random
+
+scala> val m = LIT(10) MATCH (CASE(LIT(5)) ==> FALSE, DEFAULT ==> TRUE) // treedsl
+m: $r.treedsl.global.Match =
+10 match {
+ case 5 => false
+ case _ => true
+}
+
+scala> typed(m).tpe // typed is in scope
+res2: $r.treedsl.global.Type = Boolean
+
+scala>
diff --git a/test/files/run/repl-reset.check b/test/files/run/repl-reset.check index 8c21ab067a..7256b851bb 100644 --- a/test/files/run/repl-reset.check +++ b/test/files/run/repl-reset.check @@ -28,7 +28,7 @@ val x3 = 3 case class BippyBungus() x1 + x2 + x3 -Forgetting all expression results and named terms: BippyBungus, x1, x2, x3 +Forgetting all expression results and named terms: $intp, BippyBungus, x1, x2, x3 Forgetting defined types: BippyBungus scala> x1 + x2 + x3 diff --git a/test/files/run/t1195.check b/test/files/run/t1195.check.temporarily.disabled index d023bc91f7..d023bc91f7 100644 --- a/test/files/run/t1195.check +++ b/test/files/run/t1195.check.temporarily.disabled diff --git a/test/files/run/t1195.scala b/test/files/run/t1195.scala.temporarily.disabled index 81ef5bdb0e..81ef5bdb0e 100644 --- a/test/files/run/t1195.scala +++ b/test/files/run/t1195.scala.temporarily.disabled diff --git a/test/files/run/t3758.check b/test/files/run/t3758.check new file mode 100644 index 0000000000..9c6ab655a3 --- /dev/null +++ b/test/files/run/t3758.check @@ -0,0 +1,6 @@ +List(String)
+List(Int)
+List(Float)
+List(String)
+List(Int)
+List(Float)
diff --git a/test/files/run/t3758.scala b/test/files/run/t3758.scala index 18750b0a9c..10bfb5724b 100644 --- a/test/files/run/t3758.scala +++ b/test/files/run/t3758.scala @@ -1,10 +1,10 @@ object Test { def main(args: Array[String]): Unit = { - assert(classManifest[Array[String]].typeArguments contains classManifest[String]) - assert(classManifest[Array[Int]].typeArguments contains classManifest[Int]) - assert(classManifest[Array[Float]].typeArguments contains classManifest[Float]) - assert(manifest[Array[String]].typeArguments contains manifest[String]) - assert(manifest[Array[Int]].typeArguments contains manifest[Int]) - assert(manifest[Array[Float]].typeArguments contains manifest[Float]) + println(classManifest[Array[String]].tpe.typeArguments) + println(classManifest[Array[Int]].tpe.typeArguments) + println(classManifest[Array[Float]].tpe.typeArguments) + println(manifest[Array[String]].tpe.typeArguments) + println(manifest[Array[Int]].tpe.typeArguments) + println(manifest[Array[Float]].tpe.typeArguments) } } diff --git a/test/files/run/t4110.check b/test/files/run/t4110.check.temporarily.disabled index 8b005989de..8b005989de 100644 --- a/test/files/run/t4110.check +++ b/test/files/run/t4110.check.temporarily.disabled diff --git a/test/files/run/t4110.scala b/test/files/run/t4110.scala.temporarily.disabled index 4bd377b73e..4bd377b73e 100644 --- a/test/files/run/t4110.scala +++ b/test/files/run/t4110.scala.temporarily.disabled diff --git a/test/files/run/t4658.check b/test/files/run/t4658.check index 743b0faee3..bb6405175e 100644 --- a/test/files/run/t4658.check +++ b/test/files/run/t4658.check @@ -19,8 +19,8 @@ Ranges: -30 -10 IntRanges: -Disabled #1 -Disabled #2 +-1073741824 +-1073741824 0 0 55 @@ -39,8 +39,8 @@ Disabled #2 -30 -10 LongRanges: -Disabled #1 -Disabled #2 +2305843008139952128 +-2305843008139952128 0 0 55 @@ -59,8 +59,8 @@ Disabled #2 -30 -10 BigIntRanges: -Disabled #1 -Disabled #2 +2305843008139952128 +-2305843008139952128 0 0 55 diff --git a/test/files/run/t4658.scala b/test/files/run/t4658.scala index e1799fae9b..8c07c50694 100644 --- a/test/files/run/t4658.scala +++ b/test/files/run/t4658.scala @@ -20,22 +20,14 @@ object Test { def numericBigIntRanges = rangeData.map(r => if (r.inclusive) NumericRange.inclusive(BigInt(r.start), BigInt(r.end), BigInt(r.step)) else NumericRange(BigInt(r.start), BigInt(r.end), BigInt(r.step))) def main(args: Array[String]) { - // We drop the first two tests for all ranges which don't have a decent sum implementation, - // because it is just too slow. println("Ranges:") ranges.foreach{range => println(range.sum)} println("IntRanges:") - println("Disabled #1") - println("Disabled #2") - numericIntRanges.drop(2).foreach{range => println(range.sum)} + numericIntRanges.foreach{range => println(range.sum)} println("LongRanges:") - println("Disabled #1") - println("Disabled #2") - numericLongRanges.drop(2).foreach{range => println(range.sum)} + numericLongRanges.foreach{range => println(range.sum)} println("BigIntRanges:") - println("Disabled #1") - println("Disabled #2") - numericBigIntRanges.drop(2).foreach{range => println(range.sum)} + numericBigIntRanges.foreach{range => println(range.sum)} } }
\ No newline at end of file diff --git a/test/files/run/t5224.check b/test/files/run/t5224.check index 28bc75d4fd..c754f23551 100644 --- a/test/files/run/t5224.check +++ b/test/files/run/t5224.check @@ -1,9 +1,9 @@ -{ - @new Foo(bar = "qwe") class C extends scala.AnyRef { - def <init>() = { - super.<init>(); - () - } - }; - () -} +{
+ @new Foo(bar = "qwe") class C extends Object {
+ def <init>() = {
+ super.<init>();
+ ()
+ }
+ };
+ ()
+}
diff --git a/test/files/run/t5224.scala b/test/files/run/t5224.scala index 2226a69a05..93b244e03e 100644 --- a/test/files/run/t5224.scala +++ b/test/files/run/t5224.scala @@ -1,9 +1,8 @@ -import scala.reflect._ -import scala.reflect.api._ +import scala.reflect.mirror._ class Foo(bar: String) extends ClassfileAnnotation object Test extends App { - val tree = scala.reflect.Code.lift{@Foo(bar = "qwe") class C}.tree + val tree = reify{@Foo(bar = "qwe") class C}.tree println(tree.toString) }
\ No newline at end of file diff --git a/test/files/run/t5225_1.check b/test/files/run/t5225_1.check index 719da572c7..40db2468b1 100644 --- a/test/files/run/t5225_1.check +++ b/test/files/run/t5225_1.check @@ -1,4 +1,4 @@ -{ - @new transient() @new volatile() var x: Int = 2; - () -} +{
+ @new transient() @new volatile() var x = 2;
+ ()
+}
diff --git a/test/files/run/t5225_1.scala b/test/files/run/t5225_1.scala index a655b7dd71..5e1d3b1f17 100644 --- a/test/files/run/t5225_1.scala +++ b/test/files/run/t5225_1.scala @@ -1,7 +1,6 @@ -import scala.reflect._ -import scala.reflect.api._ +import scala.reflect.mirror._ object Test extends App { - val tree = scala.reflect.Code.lift{@transient @volatile var x = 2}.tree + val tree = reify{@transient @volatile var x = 2}.tree println(tree.toString) }
\ No newline at end of file diff --git a/test/files/run/t5225_2.check b/test/files/run/t5225_2.check index c4f6b4761e..8cd2ddc1a4 100644 --- a/test/files/run/t5225_2.check +++ b/test/files/run/t5225_2.check @@ -1,4 +1,4 @@ -{ - def foo(@new cloneable() x: Int): String = ""; - () -} +{
+ def foo(@new cloneable() x: Int) = "";
+ ()
+}
diff --git a/test/files/run/t5225_2.scala b/test/files/run/t5225_2.scala index 65ea9b2f73..4cab640fe8 100644 --- a/test/files/run/t5225_2.scala +++ b/test/files/run/t5225_2.scala @@ -1,7 +1,6 @@ -import scala.reflect._ -import scala.reflect.api._ +import scala.reflect.mirror._ object Test extends App { - val tree = scala.reflect.Code.lift{def foo(@cloneable x: Int) = ""}.tree + val tree = reify{def foo(@cloneable x: Int) = ""}.tree println(tree.toString) }
\ No newline at end of file diff --git a/test/files/run/t5229_1.scala b/test/files/run/t5229_1.scala index d5af569656..273079a89d 100644 --- a/test/files/run/t5229_1.scala +++ b/test/files/run/t5229_1.scala @@ -1,13 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { object C - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5229_2.scala b/test/files/run/t5229_2.scala index 07f9ac6b84..85bf78ba31 100644 --- a/test/files/run/t5229_2.scala +++ b/test/files/run/t5229_2.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { object C { val x = 2 } @@ -11,8 +9,7 @@ object Test extends App { println(C.x) }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val evaluated = toolbox.runExpr(code.tree) println("evaluated = " + evaluated) } diff --git a/test/files/run/t5230.scala b/test/files/run/t5230.scala index d3106ca05c..e0632f591c 100644 --- a/test/files/run/t5230.scala +++ b/test/files/run/t5230.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { class C { val x = 2 } @@ -11,8 +9,7 @@ object Test extends App { println(new C().x) }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val evaluated = toolbox.runExpr(code.tree) println("evaluated = " + evaluated) } diff --git a/test/files/run/t5258a.check b/test/files/run/t5258a.check deleted file mode 100644 index 4e0b2da04c..0000000000 --- a/test/files/run/t5258a.check +++ /dev/null @@ -1 +0,0 @@ -int
\ No newline at end of file diff --git a/test/files/run/t5258a.scala b/test/files/run/t5258a.scala deleted file mode 100644 index 8cc4249e06..0000000000 --- a/test/files/run/t5258a.scala +++ /dev/null @@ -1,13 +0,0 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - -object Test extends App { - val code = scala.reflect.Code.lift{ - println(classOf[Int]) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) -}
\ No newline at end of file diff --git a/test/files/run/t5266_1.scala b/test/files/run/t5266_1.scala index 4262bc7a7b..ebb432be71 100644 --- a/test/files/run/t5266_1.scala +++ b/test/files/run/t5266_1.scala @@ -1,15 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { def x = 2 println(x) }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val evaluated = toolbox.runExpr(code.tree) println("evaluated = " + evaluated) }
\ No newline at end of file diff --git a/test/files/run/t5266_2.scala b/test/files/run/t5266_2.scala index d0f718dbd7..27c91c35a8 100644 --- a/test/files/run/t5266_2.scala +++ b/test/files/run/t5266_2.scala @@ -1,16 +1,13 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { def x = 2 def y = x println(y) }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val evaluated = toolbox.runExpr(code.tree) println("evaluated = " + evaluated) } diff --git a/test/files/run/t5269.scala b/test/files/run/t5269.scala index cab99f17e6..9026090b29 100644 --- a/test/files/run/t5269.scala +++ b/test/files/run/t5269.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { trait Z { val z = 2 } @@ -13,9 +11,5 @@ object Test extends App { } new X().println() - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5270.scala b/test/files/run/t5270.scala index 934cc13dea..476b610148 100644 --- a/test/files/run/t5270.scala +++ b/test/files/run/t5270.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class Y { def y = 100 } @@ -17,9 +15,5 @@ object Test extends App { } new X().println() - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5271_1.check b/test/files/run/t5271_1.check index 9b956da17a..7a728e5164 100644 --- a/test/files/run/t5271_1.check +++ b/test/files/run/t5271_1.check @@ -1,11 +1,11 @@ -{ - case class C extends Object with Product with Serializable { - <caseaccessor> <paramaccessor> val foo : Int = _; - <caseaccessor> <paramaccessor> val bar : Int = _; - def <init>(foo: Int, bar: Int) = { - super.<init>(); - () - } - }; - () -} +{
+ case class C extends Product with Serializable {
+ <caseaccessor> <paramaccessor> val foo: Int = _;
+ <caseaccessor> <paramaccessor> val bar: Int = _;
+ def <init>(foo: Int, bar: Int) = {
+ super.<init>();
+ ()
+ }
+ };
+ ()
+}
diff --git a/test/files/run/t5271_1.scala b/test/files/run/t5271_1.scala index fbc57aead7..5baa57c290 100644 --- a/test/files/run/t5271_1.scala +++ b/test/files/run/t5271_1.scala @@ -1,13 +1,10 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { case class C(foo: Int, bar: Int) }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() println(code.tree) } diff --git a/test/files/run/t5271_2.check b/test/files/run/t5271_2.check index 27297febb6..d8d6edeffc 100644 --- a/test/files/run/t5271_2.check +++ b/test/files/run/t5271_2.check @@ -1,12 +1,12 @@ -{ - case class C extends Object with Product with Serializable { - <caseaccessor> <paramaccessor> val foo : Int = _; - <caseaccessor> <paramaccessor> val bar : Int = _; - def <init>(foo: Int, bar: Int) = { - super.<init>(); - () - } - }; - val c = C.apply(2, 2); - scala.this.Predef.println(c.foo.$times(c.bar)) -} +{
+ case class C extends Product with Serializable {
+ <caseaccessor> <paramaccessor> val foo: Int = _;
+ <caseaccessor> <paramaccessor> val bar: Int = _;
+ def <init>(foo: Int, bar: Int) = {
+ super.<init>();
+ ()
+ }
+ };
+ val c = C.apply(2, 2);
+ scala.this.Predef.println(c.foo.$times(c.bar))
+}
diff --git a/test/files/run/t5271_2.scala b/test/files/run/t5271_2.scala index 4bfc574e00..9820ebe692 100644 --- a/test/files/run/t5271_2.scala +++ b/test/files/run/t5271_2.scala @@ -1,15 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { case class C(foo: Int, bar: Int) val c = C(2, 2) println(c.foo * c.bar) }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() println(code.tree) } diff --git a/test/files/run/t5271_3.check b/test/files/run/t5271_3.check index 9331c78959..1d4f47c5df 100644 --- a/test/files/run/t5271_3.check +++ b/test/files/run/t5271_3.check @@ -1,19 +1,19 @@ -{ - object C extends scala.AnyRef with Serializable { - def <init>() = { - super.<init>(); - () - }; - def qwe: Int = 4 - }; - case class C extends Object with Product with Serializable { - <caseaccessor> <paramaccessor> val foo : Int = _; - <caseaccessor> <paramaccessor> val bar : Int = _; - def <init>(foo: Int, bar: Int) = { - super.<init>(); - () - } - }; - val c = C.apply(2, 2); - scala.this.Predef.println(c.foo.$times(c.bar).$eq$eq(C.qwe)) -} +{
+ object C extends Object {
+ def <init>() = {
+ super.<init>();
+ ()
+ };
+ def qwe = 4
+ };
+ case class C extends Product with Serializable {
+ <caseaccessor> <paramaccessor> val foo: Int = _;
+ <caseaccessor> <paramaccessor> val bar: Int = _;
+ def <init>(foo: Int, bar: Int) = {
+ super.<init>();
+ ()
+ }
+ };
+ val c = C.apply(2, 2);
+ scala.this.Predef.println(c.foo.$times(c.bar).$eq$eq(C.qwe))
+}
diff --git a/test/files/run/t5271_3.scala b/test/files/run/t5271_3.scala index a085bdca4c..5fd94f4a2b 100644 --- a/test/files/run/t5271_3.scala +++ b/test/files/run/t5271_3.scala @@ -1,16 +1,13 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { object C { def qwe = 4 } case class C(foo: Int, bar: Int) val c = C(2, 2) println(c.foo * c.bar == C.qwe) }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() println(code.tree) } diff --git a/test/files/run/t5271_4.scala b/test/files/run/t5271_4.scala index c253b1adca..e13a331d9c 100644 --- a/test/files/run/t5271_4.scala +++ b/test/files/run/t5271_4.scala @@ -1,13 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { case object C - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5272_1.scala b/test/files/run/t5272_1.scala index 882287f033..46472babf3 100644 --- a/test/files/run/t5272_1.scala +++ b/test/files/run/t5272_1.scala @@ -1,16 +1,10 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { 2 match { case 2 => println("okay") case _ => println("not okay") } - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5272_2.scala b/test/files/run/t5272_2.scala index 48b6a670bb..f5bab44205 100644 --- a/test/files/run/t5272_2.scala +++ b/test/files/run/t5272_2.scala @@ -1,15 +1,9 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { 2 match { case x => println("okay" + x) } - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5273_1.scala b/test/files/run/t5273_1.scala index 80460a4ae6..1b491923b2 100644 --- a/test/files/run/t5273_1.scala +++ b/test/files/run/t5273_1.scala @@ -1,16 +1,10 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { List(1, 2, 3) match { case foo :: bar :: _ => println(foo * bar) case _ => println("this is getting out of hand!") } - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5273_2a.scala b/test/files/run/t5273_2a.scala index a7a336d8a7..062ff79d11 100644 --- a/test/files/run/t5273_2a.scala +++ b/test/files/run/t5273_2a.scala @@ -1,14 +1,8 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { val foo :: bar :: _ = List(1, 2, 3) println(foo * bar) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5273_2b.scala b/test/files/run/t5273_2b.scala index 85c40f0607..82f1de89f7 100644 --- a/test/files/run/t5273_2b.scala +++ b/test/files/run/t5273_2b.scala @@ -1,15 +1,9 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { val RegexParser = """(.*) \d+([A-Z]+) \| (.*) \|.*""".r val RegexParser(name, shortname, value) = "American Dollar 1USD | 2,8567 | sometext" println("name = %s, shortname = %s, value = %s".format(name, shortname, value)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5274_1.scala b/test/files/run/t5274_1.scala index 74a5b81bcb..7ef332aa05 100644 --- a/test/files/run/t5274_1.scala +++ b/test/files/run/t5274_1.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { def factorial(n: BigInt): BigInt = if (n == 0) 1 else n * factorial(n-1) @@ -11,9 +9,5 @@ object Test extends App { println("50! = " + f50) println("49! = " + f49) println("50!/49! = " + (f50 / f49)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5274_2.scala b/test/files/run/t5274_2.scala index 5984a64967..0b373b358f 100644 --- a/test/files/run/t5274_2.scala +++ b/test/files/run/t5274_2.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { /** Nested methods can use and even update everything * visible in their scope (including local variables or * arguments of enclosing methods). @@ -48,9 +46,5 @@ object Test extends App { println(ar) sort(ar) println(ar) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5275.scala b/test/files/run/t5275.scala index 285d8a18a4..534672be3c 100644 --- a/test/files/run/t5275.scala +++ b/test/files/run/t5275.scala @@ -1,14 +1,8 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class C(val foo: Int) println(new C(2).foo) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5276_1a.scala b/test/files/run/t5276_1a.scala index b717675824..a6e327c0e7 100644 --- a/test/files/run/t5276_1a.scala +++ b/test/files/run/t5276_1a.scala @@ -1,14 +1,8 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { lazy val x = 2 println(x) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5276_1b.scala b/test/files/run/t5276_1b.scala index 1ff25504ca..1bc3e246c9 100644 --- a/test/files/run/t5276_1b.scala +++ b/test/files/run/t5276_1b.scala @@ -1,14 +1,8 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { implicit lazy val x = 2 println(implicitly[Int]) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5276_2a.scala b/test/files/run/t5276_2a.scala index af5ff2a565..cdd87ddc9e 100644 --- a/test/files/run/t5276_2a.scala +++ b/test/files/run/t5276_2a.scala @@ -1,17 +1,11 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class C { lazy val x = 2 } println(new C().x) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5276_2b.scala b/test/files/run/t5276_2b.scala index 63904b2898..2fac951731 100644 --- a/test/files/run/t5276_2b.scala +++ b/test/files/run/t5276_2b.scala @@ -1,18 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { class C { implicit lazy val x = 2 def y = implicitly[Int] } println(new C().y) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5277_1.scala b/test/files/run/t5277_1.scala index 0aaec7cdf2..f95e9ab6ec 100644 --- a/test/files/run/t5277_1.scala +++ b/test/files/run/t5277_1.scala @@ -1,9 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { def fact(n: Int): BigInt = if (n == 0) 1 else fact(n-1) * n class Factorizer(n: Int) { @@ -12,9 +10,5 @@ object Test extends App { implicit def int2fact(n: Int) = new Factorizer(n) println("10! = " + (10!)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5277_2.scala b/test/files/run/t5277_2.scala index 91ed55122a..5f1737f503 100644 --- a/test/files/run/t5277_2.scala +++ b/test/files/run/t5277_2.scala @@ -1,17 +1,11 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { def p(implicit i: Int) = print(i) implicit val v = 2 println(p) println(p(1)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5279.scala b/test/files/run/t5279.scala index cef58535d5..aab5588877 100644 --- a/test/files/run/t5279.scala +++ b/test/files/run/t5279.scala @@ -1,13 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { println(new Integer(10)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5334_1.scala b/test/files/run/t5334_1.scala index 9887bebf78..49dbea6b68 100644 --- a/test/files/run/t5334_1.scala +++ b/test/files/run/t5334_1.scala @@ -1,14 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { class C { override def toString = "C" } - new C + val ret = new C + ret.asInstanceOf[Object] }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() println(toolbox.runExpr(code.tree)) } diff --git a/test/files/run/t5334_2.scala b/test/files/run/t5334_2.scala index 775a05aaf7..c6a77158dd 100644 --- a/test/files/run/t5334_2.scala +++ b/test/files/run/t5334_2.scala @@ -1,14 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + val code = reify { class C { override def toString() = "C" } - List((new C, new C)) + val ret = List((new C, new C)) + ret.asInstanceOf[List[Any]] }; - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() println(toolbox.runExpr(code.tree)) } diff --git a/test/files/run/t5335.scala b/test/files/run/t5335.scala index 8e2ed59db6..a0fe6c5822 100644 --- a/test/files/run/t5335.scala +++ b/test/files/run/t5335.scala @@ -1,13 +1,7 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { - val code = scala.reflect.Code.lift{ + reify { println(new {def x = 2}.x) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/files/run/t5415.scala b/test/files/run/t5415.scala index 3db356da86..c6552f69b3 100644 --- a/test/files/run/t5415.scala +++ b/test/files/run/t5415.scala @@ -1,14 +1,10 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import scala.reflect.runtime.Mirror.ToolBox - object Test extends App{ case class Queryable2[T]() { def filter(predicate: T => Boolean) = ??? } trait CoffeesTable{ def sales : Int } val q = Queryable2[CoffeesTable]() - val code = scala.reflect.Code.lift{q.filter(_.sales > 5)} + import scala.reflect.mirror._ + val code = reify{q.filter(_.sales > 5)} - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val ttree = toolbox.typeCheck(code.tree) } diff --git a/test/files/run/t5419.check b/test/files/run/t5419.check index 7e6d739354..50751b168e 100644 --- a/test/files/run/t5419.check +++ b/test/files/run/t5419.check @@ -1 +1 @@ -(5: Int(5) @Foo) +5: @Foo.asInstanceOf[Int]
diff --git a/test/files/run/t5419.scala b/test/files/run/t5419.scala index 695786e5c4..d65d8f38c8 100644 --- a/test/files/run/t5419.scala +++ b/test/files/run/t5419.scala @@ -1,9 +1,8 @@ -import scala.reflect._ -import scala.reflect.api._ +import scala.reflect.mirror._ class Foo extends StaticAnnotation object Test extends App { - val tree = scala.reflect.Code.lift{5: @Foo}.tree + val tree = reify{(5: @Foo).asInstanceOf[Int]}.tree println(tree.toString) }
\ No newline at end of file diff --git a/test/files/run/t5423.scala b/test/files/run/t5423.scala index fc507c417b..645c8c7c1d 100644 --- a/test/files/run/t5423.scala +++ b/test/files/run/t5423.scala @@ -1,7 +1,4 @@ -import java.lang.Class import scala.reflect.mirror._ -import scala.reflect.runtime.Mirror.ToolBox -import scala.reflect.Code final class table extends StaticAnnotation @table class A diff --git a/test/files/run/t5614.check b/test/files/run/t5614.check new file mode 100644 index 0000000000..f659f2da3b --- /dev/null +++ b/test/files/run/t5614.check @@ -0,0 +1,3 @@ +3 +a +b diff --git a/test/files/run/t5614.flags b/test/files/run/t5614.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/run/t5614.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/run/t5614.scala b/test/files/run/t5614.scala new file mode 100644 index 0000000000..7c85c33f12 --- /dev/null +++ b/test/files/run/t5614.scala @@ -0,0 +1,5 @@ +object Test extends App { + val str = s"a\nb" + println(str.length) + println(str) +} diff --git a/test/files/run/t5648.check b/test/files/run/t5648.check new file mode 100644 index 0000000000..1140ff52e2 --- /dev/null +++ b/test/files/run/t5648.check @@ -0,0 +1,4 @@ +true +true +true +true diff --git a/test/files/run/t5648.flags b/test/files/run/t5648.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/run/t5648.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/run/t5648.scala b/test/files/run/t5648.scala new file mode 100644 index 0000000000..c5cea9e1cb --- /dev/null +++ b/test/files/run/t5648.scala @@ -0,0 +1,10 @@ +case class C(val s: Int*) + +object Test { + def main(args: Array[String]): Unit = { + println(new C(1, 3, 7) == new C(1, 3, 7)) + println(new C(1, 3, 7) == C(1, 3, 7)) + println(C(1, 3, 7) == new C(1, 3, 7)) + println(C(1, 3, 7) == C(1, 3, 7)) + } +} diff --git a/test/files/run/toolbox_console_reporter.check b/test/files/run/toolbox_console_reporter.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/toolbox_console_reporter.check diff --git a/test/files/run/toolbox_console_reporter.scala b/test/files/run/toolbox_console_reporter.scala new file mode 100644 index 0000000000..fd244b40ec --- /dev/null +++ b/test/files/run/toolbox_console_reporter.scala @@ -0,0 +1,16 @@ +import scala.reflect.mirror._ + +object Test extends App { + // todo. cannot test this unfortunately, because ConsoleReporter grabs Console.out too early + // todo. and isn't affected by Console.setOut employed by partest to intercept output + + //val toolbox = mkToolBox(reporter = mkConsoleReporter(), options = "-deprecation") + //toolbox.runExpr(reify{ + // object Utils { + // @deprecated("test", "2.10.0") + // def foo { println("hello") } + // } + // + // Utils.foo + //}) +} diff --git a/test/files/run/toolbox_default_reporter_is_silent.check b/test/files/run/toolbox_default_reporter_is_silent.check new file mode 100644 index 0000000000..ef0493b275 --- /dev/null +++ b/test/files/run/toolbox_default_reporter_is_silent.check @@ -0,0 +1 @@ +hello
diff --git a/test/files/run/toolbox_default_reporter_is_silent.scala b/test/files/run/toolbox_default_reporter_is_silent.scala new file mode 100644 index 0000000000..78606e2abc --- /dev/null +++ b/test/files/run/toolbox_default_reporter_is_silent.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + val toolbox = mkToolBox() + toolbox.runExpr(reify{ + object Utils { + @deprecated("test", "2.10.0") + def foo { println("hello") } + } + + Utils.foo + }) +} diff --git a/test/files/run/toolbox_silent_reporter.check b/test/files/run/toolbox_silent_reporter.check new file mode 100644 index 0000000000..2d05b1e3f8 --- /dev/null +++ b/test/files/run/toolbox_silent_reporter.check @@ -0,0 +1,4 @@ +hello +============compiler messages============ +Info(NoPosition,method foo in object Utils is deprecated: test,WARNING) +========================================= diff --git a/test/files/run/toolbox_silent_reporter.scala b/test/files/run/toolbox_silent_reporter.scala new file mode 100644 index 0000000000..7e9259946b --- /dev/null +++ b/test/files/run/toolbox_silent_reporter.scala @@ -0,0 +1,16 @@ +import scala.reflect.mirror._ + +object Test extends App { + val toolbox = mkToolBox(options = "-deprecation") + toolbox.runExpr(reify{ + object Utils { + @deprecated("test", "2.10.0") + def foo { println("hello") } + } + + Utils.foo + }) + println("============compiler messages============") + toolbox.reporter.infos.foreach(println(_)) + println("=========================================") +}
\ No newline at end of file diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.check b/test/files/run/toolbox_typecheck_implicitsdisabled.check new file mode 100644 index 0000000000..4bc64530ab --- /dev/null +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.check @@ -0,0 +1,5 @@ +{
+ import scala.Predef._;
+ scala.Predef.any2ArrowAssoc[Int](1).->[Int](2)
+}
+scala.reflect.runtime.ToolBoxes$ToolBox$ToolBoxError: reflective typecheck has failed: value -> is not a member of Int
diff --git a/test/files/run/toolbox_typecheck_implicitsdisabled.scala b/test/files/run/toolbox_typecheck_implicitsdisabled.scala new file mode 100644 index 0000000000..9d52e91f73 --- /dev/null +++ b/test/files/run/toolbox_typecheck_implicitsdisabled.scala @@ -0,0 +1,24 @@ +import scala.reflect.mirror._ + +object Test extends App { + val toolbox = mkToolBox() + + val tree1 = Block( + Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1))), + Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + ) + val ttree1 = toolbox.typeCheck(tree1, withImplicitViewsDisabled = false) + println(ttree1) + + try { + val tree2 = Block( + Import(Select(Ident(newTermName("scala")), newTermName("Predef")), List(ImportSelector(nme.WILDCARD, -1, null, -1))), + Apply(Select(Literal(Constant(1)), newTermName("$minus$greater")), List(Literal(Constant(2)))) + ) + val ttree2 = toolbox.typeCheck(tree2, withImplicitViewsDisabled = true) + println(ttree2) + } catch { + case ex: Throwable => + println(ex) + } +}
\ No newline at end of file diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.check b/test/files/run/toolbox_typecheck_macrosdisabled.check new file mode 100644 index 0000000000..cf2420bc17 --- /dev/null +++ b/test/files/run/toolbox_typecheck_macrosdisabled.check @@ -0,0 +1,5 @@ +{
+ val $mr: mr.type = mr;
+ $mr.Expr.apply[Int(2)]($mr.Literal.apply($mr.Constant.apply(2)))($mr.ConcreteTypeTag.apply[Int(2)]($mr.ConstantType.apply($mr.Constant.apply(2))))
+}
+mr.reify[Int](2)
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled.scala b/test/files/run/toolbox_typecheck_macrosdisabled.scala new file mode 100644 index 0000000000..7d2707d5e1 --- /dev/null +++ b/test/files/run/toolbox_typecheck_macrosdisabled.scala @@ -0,0 +1,17 @@ +import scala.reflect.mirror._ + +object Test extends App { + val toolbox = mkToolBox() + val mrPkg = staticModule("scala.reflect.package") + val mrSym = selectTerm(mrPkg, "mirror") + val NullaryMethodType(mrTpe) = mrSym.typeSignature + val mr = newFreeTerm("mr", mrTpe, scala.reflect.mirror, null) + + val tree1 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) + val ttree1 = toolbox.typeCheck(tree1, withMacrosDisabled = false) + println(ttree1) + + val tree2 = Apply(Select(Ident(mr), newTermName("reify")), List(Literal(Constant(2)))) + val ttree2 = toolbox.typeCheck(tree2, withMacrosDisabled = true) + println(ttree2) +} diff --git a/test/files/run/treePrint.check b/test/files/run/treePrint.check.temporarily.disabled index 3360815ac1..3360815ac1 100644 --- a/test/files/run/treePrint.check +++ b/test/files/run/treePrint.check.temporarily.disabled diff --git a/test/files/run/treePrint.scala b/test/files/run/treePrint.scala.temporarily.disabled index e0332a705f..e0332a705f 100644 --- a/test/files/run/treePrint.scala +++ b/test/files/run/treePrint.scala.temporarily.disabled diff --git a/test/files/run/typetags_core.check b/test/files/run/typetags_core.check new file mode 100644 index 0000000000..62fcb481ae --- /dev/null +++ b/test/files/run/typetags_core.check @@ -0,0 +1,30 @@ +true
+ConcreteTypeTag[Byte]
+true
+ConcreteTypeTag[Short]
+true
+ConcreteTypeTag[Char]
+true
+ConcreteTypeTag[Int]
+true
+ConcreteTypeTag[Long]
+true
+ConcreteTypeTag[Float]
+true
+ConcreteTypeTag[Double]
+true
+ConcreteTypeTag[Boolean]
+true
+ConcreteTypeTag[Unit]
+true
+ConcreteTypeTag[Any]
+true
+ConcreteTypeTag[Object]
+true
+ConcreteTypeTag[AnyVal]
+true
+ConcreteTypeTag[AnyRef]
+true
+ConcreteTypeTag[Null]
+true
+ConcreteTypeTag[Nothing]
diff --git a/test/files/run/typetags_core.scala b/test/files/run/typetags_core.scala new file mode 100644 index 0000000000..883c54b9a8 --- /dev/null +++ b/test/files/run/typetags_core.scala @@ -0,0 +1,32 @@ +object Test extends App { + println(implicitly[TypeTag[Byte]] eq TypeTag.Byte) + println(implicitly[TypeTag[Byte]]) + println(implicitly[TypeTag[Short]] eq TypeTag.Short) + println(implicitly[TypeTag[Short]]) + println(implicitly[TypeTag[Char]] eq TypeTag.Char) + println(implicitly[TypeTag[Char]]) + println(implicitly[TypeTag[Int]] eq TypeTag.Int) + println(implicitly[TypeTag[Int]]) + println(implicitly[TypeTag[Long]] eq TypeTag.Long) + println(implicitly[TypeTag[Long]]) + println(implicitly[TypeTag[Float]] eq TypeTag.Float) + println(implicitly[TypeTag[Float]]) + println(implicitly[TypeTag[Double]] eq TypeTag.Double) + println(implicitly[TypeTag[Double]]) + println(implicitly[TypeTag[Boolean]] eq TypeTag.Boolean) + println(implicitly[TypeTag[Boolean]]) + println(implicitly[TypeTag[Unit]] eq TypeTag.Unit) + println(implicitly[TypeTag[Unit]]) + println(implicitly[TypeTag[Any]] eq TypeTag.Any) + println(implicitly[TypeTag[Any]]) + println(implicitly[TypeTag[Object]] eq TypeTag.Object) + println(implicitly[TypeTag[Object]]) + println(implicitly[TypeTag[AnyVal]] eq TypeTag.AnyVal) + println(implicitly[TypeTag[AnyVal]]) + println(implicitly[TypeTag[AnyRef]] eq TypeTag.AnyRef) + println(implicitly[TypeTag[AnyRef]]) + println(implicitly[TypeTag[Null]] eq TypeTag.Null) + println(implicitly[TypeTag[Null]]) + println(implicitly[TypeTag[Nothing]] eq TypeTag.Nothing) + println(implicitly[TypeTag[Nothing]]) +}
\ No newline at end of file |