diff options
Diffstat (limited to 'test/files/run')
130 files changed, 941 insertions, 96 deletions
diff --git a/test/files/run/dead-code-elimination.check b/test/files/run/dead-code-elimination.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/dead-code-elimination.check +++ /dev/null diff --git a/test/files/run/delambdafy-nested-by-name.check b/test/files/run/delambdafy-nested-by-name.check new file mode 100644 index 0000000000..94954abda4 --- /dev/null +++ b/test/files/run/delambdafy-nested-by-name.check @@ -0,0 +1,2 @@ +hello +world diff --git a/test/files/run/delambdafy-nested-by-name.scala b/test/files/run/delambdafy-nested-by-name.scala new file mode 100644 index 0000000000..4498b3308d --- /dev/null +++ b/test/files/run/delambdafy-nested-by-name.scala @@ -0,0 +1,11 @@ +// during development of delayed delambdafication I created a bug where calling a by-name method with a by-name argument that +// itself contained a by-name argument would cause a class cast exception. That bug wasn't found in the existing test suite +// so this test covers that case +object Test { + def meth1(arg1: => String) = arg1 + def meth2(arg2: => String) = meth1({println("hello"); arg2}) + + def main(args: Array[String]) { + println(meth2("world")) + } +}
\ No newline at end of file diff --git a/test/files/run/delambdafy-two-lambdas.check b/test/files/run/delambdafy-two-lambdas.check new file mode 100644 index 0000000000..ed9ea404dd --- /dev/null +++ b/test/files/run/delambdafy-two-lambdas.check @@ -0,0 +1,2 @@ +13 +24 diff --git a/test/files/run/delambdafy-two-lambdas.scala b/test/files/run/delambdafy-two-lambdas.scala new file mode 100644 index 0000000000..decede74a4 --- /dev/null +++ b/test/files/run/delambdafy-two-lambdas.scala @@ -0,0 +1,12 @@ +/* + * Tests if two lambdas defined in the same class do not lead to + * name clashes. + */ +object Test { + def takeLambda(f: Int => Int ): Int = f(12) + + def main(args: Array[String]): Unit = { + println(takeLambda(x => x+1)) + println(takeLambda(x => x*2)) + } +} diff --git a/test/files/run/delambdafy_t6028.check b/test/files/run/delambdafy_t6028.check new file mode 100644 index 0000000000..92cfbaefb6 --- /dev/null +++ b/test/files/run/delambdafy_t6028.check @@ -0,0 +1,57 @@ +[[syntax trees at end of lambdalift]] // newSource1.scala +package <empty> { + class T extends Object { + <paramaccessor> private[this] val classParam: Int = _; + def <init>(classParam: Int): T = { + T.super.<init>(); + () + }; + private[this] val field: Int = 0; + <stable> <accessor> def field(): Int = T.this.field; + def foo(methodParam: Int): Function0 = { + val methodLocal: Int = 0; + { + (() => T.this.$anonfun$1(methodParam, methodLocal)).$asInstanceOf[Function0]() + } + }; + def bar(barParam: Int): Object = { + @volatile var MethodLocalObject$module: runtime.VolatileObjectRef = scala.runtime.VolatileObjectRef.zero(); + T.this.MethodLocalObject$1(barParam, MethodLocalObject$module) + }; + def tryy(tryyParam: Int): Function0 = { + var tryyLocal: runtime.IntRef = scala.runtime.IntRef.create(0); + { + (() => T.this.$anonfun$2(tryyParam, tryyLocal)).$asInstanceOf[Function0]() + } + }; + final <artifact> private[this] def $anonfun$1(methodParam$1: Int, methodLocal$1: Int): Int = T.this.classParam.+(T.this.field()).+(methodParam$1).+(methodLocal$1); + abstract trait MethodLocalTrait$1 extends Object { + <synthetic> <stable> <artifact> def $outer(): T + }; + object MethodLocalObject$2 extends Object with T#MethodLocalTrait$1 { + def <init>($outer: T, barParam$1: Int): T#MethodLocalObject$2.type = { + MethodLocalObject$2.super.<init>(); + MethodLocalObject$2.this.$asInstanceOf[T#MethodLocalTrait$1$class]()./*MethodLocalTrait$1$class*/$init$(barParam$1); + () + }; + <synthetic> <paramaccessor> <artifact> private[this] val $outer: T = _; + <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer; + <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer + }; + final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { + MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); + MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() + }; + abstract trait MethodLocalTrait$1$class extends Object with T#MethodLocalTrait$1 { + def /*MethodLocalTrait$1$class*/$init$(barParam$1: Int): Unit = { + () + }; + scala.this.Predef.print(scala.Int.box(barParam$1)) + }; + final <artifact> private[this] def $anonfun$2(tryyParam$1: Int, tryyLocal$1: runtime.IntRef): Unit = try { + tryyLocal$1.elem = tryyParam$1 + } finally () + } +} + +warning: there were 1 feature warning(s); re-run with -feature for details diff --git a/test/files/run/delambdafy_t6028.scala b/test/files/run/delambdafy_t6028.scala new file mode 100644 index 0000000000..0b7ef48c3d --- /dev/null +++ b/test/files/run/delambdafy_t6028.scala @@ -0,0 +1,21 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Ydelambdafy:method -Xprint:lambdalift -d " + testOutput.path + + override def code = """class T(classParam: Int) { + | val field: Int = 0 + | def foo(methodParam: Int) = {val methodLocal = 0 ; () => classParam + field + methodParam + methodLocal } + | def bar(barParam: Int) = { trait MethodLocalTrait { print(barParam) }; object MethodLocalObject extends MethodLocalTrait; MethodLocalObject } + | def tryy(tryyParam: Int) = { var tryyLocal = 0; () => try { tryyLocal = tryyParam } finally () } + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_t6555.check b/test/files/run/delambdafy_t6555.check new file mode 100644 index 0000000000..6b174c0d2a --- /dev/null +++ b/test/files/run/delambdafy_t6555.check @@ -0,0 +1,15 @@ +[[syntax trees at end of specialize]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + private[this] val f: Int => Int = { + final <artifact> def $anonfun(param: Int): Int = param; + ((param: Int) => $anonfun(param)) + }; + <stable> <accessor> def f(): Int => Int = Foo.this.f + } +} + diff --git a/test/files/run/delambdafy_t6555.scala b/test/files/run/delambdafy_t6555.scala new file mode 100644 index 0000000000..a1dcfe790c --- /dev/null +++ b/test/files/run/delambdafy_t6555.scala @@ -0,0 +1,15 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:specialize -Ydelambdafy:method -d " + testOutput.path + + override def code = "class Foo { val f = (param: Int) => param } " + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_uncurry_byname_inline.check b/test/files/run/delambdafy_uncurry_byname_inline.check new file mode 100644 index 0000000000..0dc69b379a --- /dev/null +++ b/test/files/run/delambdafy_uncurry_byname_inline.check @@ -0,0 +1,21 @@ +[[syntax trees at end of uncurry]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + def bar(x: () => Int): Int = x.apply(); + def foo(): Int = Foo.this.bar({ + @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction0[Int] with Serializable { + def <init>(): <$anon: () => Int> = { + $anonfun.super.<init>(); + () + }; + final def apply(): Int = 1 + }; + (new <$anon: () => Int>(): () => Int) + }) + } +} + diff --git a/test/files/run/delambdafy_uncurry_byname_inline.scala b/test/files/run/delambdafy_uncurry_byname_inline.scala new file mode 100644 index 0000000000..8f480fa804 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_byname_inline.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:uncurry -Ydelambdafy:inline -d " + testOutput.path + + override def code = """class Foo { + | def bar(x: => Int) = x + | + | def foo = bar(1) + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_uncurry_byname_method.check b/test/files/run/delambdafy_uncurry_byname_method.check new file mode 100644 index 0000000000..cd3edc7d6f --- /dev/null +++ b/test/files/run/delambdafy_uncurry_byname_method.check @@ -0,0 +1,15 @@ +[[syntax trees at end of uncurry]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + def bar(x: () => Int): Int = x.apply(); + def foo(): Int = Foo.this.bar({ + final <artifact> def $anonfun(): Int = 1; + (() => $anonfun()) + }) + } +} + diff --git a/test/files/run/delambdafy_uncurry_byname_method.scala b/test/files/run/delambdafy_uncurry_byname_method.scala new file mode 100644 index 0000000000..1adeec8433 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_byname_method.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:uncurry -Ydelambdafy:method -Ystop-after:uncurry -d " + testOutput.path + + override def code = """class Foo { + | def bar(x: => Int) = x + | + | def foo = bar(1) + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_uncurry_inline.check b/test/files/run/delambdafy_uncurry_inline.check new file mode 100644 index 0000000000..e2b024b462 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_inline.check @@ -0,0 +1,23 @@ +[[syntax trees at end of uncurry]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + def bar(): Unit = { + val f: Int => Int = { + @SerialVersionUID(0) final <synthetic> class $anonfun extends scala.runtime.AbstractFunction1[Int,Int] with Serializable { + def <init>(): <$anon: Int => Int> = { + $anonfun.super.<init>(); + () + }; + final def apply(x: Int): Int = x.+(1) + }; + (new <$anon: Int => Int>(): Int => Int) + }; + () + } + } +} + diff --git a/test/files/run/delambdafy_uncurry_inline.scala b/test/files/run/delambdafy_uncurry_inline.scala new file mode 100644 index 0000000000..b42b65f5bb --- /dev/null +++ b/test/files/run/delambdafy_uncurry_inline.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:uncurry -Ydelambdafy:inline -d " + testOutput.path + + override def code = """class Foo { + | def bar = { + | val f = {x: Int => x + 1} + | } + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/delambdafy_uncurry_method.check b/test/files/run/delambdafy_uncurry_method.check new file mode 100644 index 0000000000..5ee3d174b3 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_method.check @@ -0,0 +1,17 @@ +[[syntax trees at end of uncurry]] // newSource1.scala +package <empty> { + class Foo extends Object { + def <init>(): Foo = { + Foo.super.<init>(); + () + }; + def bar(): Unit = { + val f: Int => Int = { + final <artifact> def $anonfun(x: Int): Int = x.+(1); + ((x: Int) => $anonfun(x)) + }; + () + } + } +} + diff --git a/test/files/run/delambdafy_uncurry_method.scala b/test/files/run/delambdafy_uncurry_method.scala new file mode 100644 index 0000000000..a988fb2ee7 --- /dev/null +++ b/test/files/run/delambdafy_uncurry_method.scala @@ -0,0 +1,20 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:uncurry -Ydelambdafy:method -Ystop-after:uncurry -d " + testOutput.path + + override def code = """class Foo { + | def bar = { + | val f = {x: Int => x + 1} + | } + |} + |""".stripMargin.trim + + override def show(): Unit = { + Console.withErr(System.out) { + compile() + } + } +} diff --git a/test/files/run/exoticnames.check b/test/files/run/exoticnames.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/exoticnames.check +++ /dev/null diff --git a/test/files/run/intmap.check b/test/files/run/intmap.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/intmap.check +++ /dev/null diff --git a/test/files/run/longmap.check b/test/files/run/longmap.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/longmap.check +++ /dev/null diff --git a/test/files/run/macro-abort-fresh.check b/test/files/run/macro-abort-fresh.check index 87491f6e48..9fddee57d4 100644 --- a/test/files/run/macro-abort-fresh.check +++ b/test/files/run/macro-abort-fresh.check @@ -1,4 +1,4 @@ -$1$ +fresh$1 qwe1 qwe2 reflective compilation has failed: diff --git a/test/files/run/macro-bundle-repl.check b/test/files/run/macro-bundle-repl.check index b9c809f037..c11c48dc55 100644 --- a/test/files/run/macro-bundle-repl.check +++ b/test/files/run/macro-bundle-repl.check @@ -7,13 +7,13 @@ import scala.language.experimental.macros scala> import scala.reflect.macros.Macro import scala.reflect.macros.Macro -scala> trait Bar extends Macro { def impl = c.literalUnit };def bar = macro Bar.impl +scala> trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl defined trait Bar defined term macro bar: Unit scala> bar -scala> trait Foo extends Macro { def impl = c.literalUnit } +scala> trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } } defined trait Foo scala> def foo = macro Foo.impl diff --git a/test/files/run/macro-bundle-repl.scala b/test/files/run/macro-bundle-repl.scala index 50783c8cba..3171aaacc2 100644 --- a/test/files/run/macro-bundle-repl.scala +++ b/test/files/run/macro-bundle-repl.scala @@ -4,9 +4,9 @@ object Test extends ReplTest { def code = """ import scala.language.experimental.macros import scala.reflect.macros.Macro -trait Bar extends Macro { def impl = c.literalUnit };def bar = macro Bar.impl +trait Bar extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } };def bar = macro Bar.impl bar -trait Foo extends Macro { def impl = c.literalUnit } +trait Foo extends Macro { def impl = { import c.universe._; c.Expr[Unit](q"()") } } def foo = macro Foo.impl foo """ diff --git a/test/files/run/macro-bundle-static/Impls_Macros_1.scala b/test/files/run/macro-bundle-static/Impls_Macros_1.scala index 831dac6df5..e81fd0dbd6 100644 --- a/test/files/run/macro-bundle-static/Impls_Macros_1.scala +++ b/test/files/run/macro-bundle-static/Impls_Macros_1.scala @@ -4,8 +4,8 @@ import scala.language.experimental.macros object Enclosing { trait Impl extends Macro { - def mono = c.literalUnit - def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString) + def mono = { import c.universe._; c.Expr[Unit](q"()") } + def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") } def weird = macro mono } } @@ -18,8 +18,8 @@ object Macros { package pkg { object Enclosing { trait Impl extends Macro { - def mono = c.literalTrue - def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString + c.weakTypeOf[T].toString) + def mono = { import c.universe._; c.Expr[Boolean](q"true") } + def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") } def weird = macro mono } } diff --git a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala index 676935682e..8c7df2cdc5 100644 --- a/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala +++ b/test/files/run/macro-bundle-toplevel/Impls_Macros_1.scala @@ -2,8 +2,8 @@ import scala.reflect.macros.Context import scala.reflect.macros.Macro trait Impl extends Macro { - def mono = c.literalUnit - def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString) + def mono = { import c.universe._; c.Expr[Unit](q"()") } + def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString}") } def weird = macro mono } @@ -14,8 +14,8 @@ object Macros { package pkg { trait Impl extends Macro { - def mono = c.literalTrue - def poly[T: c.WeakTypeTag] = c.literal(c.weakTypeOf[T].toString + c.weakTypeOf[T].toString) + def mono = { import c.universe._; c.Expr[Boolean](q"true") } + def poly[T: c.WeakTypeTag] = { import c.universe._; c.Expr[String](q"${c.weakTypeOf[T].toString + c.weakTypeOf[T].toString}") } def weird = macro mono } diff --git a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala index bc4a9fded7..53511ebc72 100644 --- a/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala +++ b/test/files/run/macro-divergence-spurious/Impls_Macros_1.scala @@ -15,7 +15,7 @@ object Complex { val recur = c.inferImplicitValue(trecur, silent = true) if (recur == EmptyTree) c.abort(c.enclosingPosition, s"couldn't synthesize $trecur") } - c.literalNull + c.Expr[Null](Literal(Constant(null))) } implicit object ComplexString extends Complex[String] diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala index cd54028676..68f1920cdd 100644 --- a/test/files/run/macro-enclosures/Impls_Macros_1.scala +++ b/test/files/run/macro-enclosures/Impls_Macros_1.scala @@ -1,13 +1,16 @@ import scala.reflect.macros.Context object Macros { - def impl(c: Context) = c.universe.reify { - println("enclosingPackage = " + c.literal(c.enclosingPackage.toString).splice) - println("enclosingClass = " + c.literal(c.enclosingClass.toString).splice) - println("enclosingImpl = " + c.literal(c.enclosingImpl.toString).splice) - println("enclosingTemplate = " + c.literal(c.enclosingTemplate.toString).splice) - println("enclosingMethod = " + c.literal(c.enclosingMethod.toString).splice) - println("enclosingDef = " + c.literal(c.enclosingDef.toString).splice) + def impl(c: Context) = { + import c.universe._ + reify { + println("enclosingPackage = " + c.Expr[String](Literal(Constant(c.enclosingPackage.toString))).splice) + println("enclosingClass = " + c.Expr[String](Literal(Constant(c.enclosingClass.toString))).splice) + println("enclosingImpl = " + c.Expr[String](Literal(Constant(c.enclosingImpl.toString))).splice) + println("enclosingTemplate = " + c.Expr[String](Literal(Constant(c.enclosingTemplate.toString))).splice) + println("enclosingMethod = " + c.Expr[String](Literal(Constant(c.enclosingMethod.toString))).splice) + println("enclosingDef = " + c.Expr[String](Literal(Constant(c.enclosingDef.toString))).splice) + } } def foo = macro impl diff --git a/test/files/run/macro-expand-tparams-bounds.check b/test/files/run/macro-expand-tparams-bounds.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/macro-expand-tparams-bounds.check +++ /dev/null diff --git a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala index f9103aaf8f..d63f034e9b 100644 --- a/test/files/run/macro-expand-tparams-bounds/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-bounds/Impls_1.scala @@ -1,12 +1,12 @@ import scala.reflect.macros.Context object Impls1 { - def foo[U <: String](c: Context): c.Expr[Unit] = c.literalUnit + def foo[U <: String](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") } } class C class D extends C object Impls2 { - def foo[U <: C](c: Context): c.Expr[Unit] = c.literalUnit + def foo[U <: C](c: Context): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") } } diff --git a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala index e92396d1b4..a98c4abe78 100644 --- a/test/files/run/macro-expand-tparams-prefix/Impls_1.scala +++ b/test/files/run/macro-expand-tparams-prefix/Impls_1.scala @@ -5,8 +5,7 @@ object Impls1 { def foo[U: c.WeakTypeTag](c: Context)(x: c.Expr[U]) = { import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(U.toString)))) - c.Expr[Unit](body) + c.Expr[Unit](q"println(${U.toString})") } } @@ -16,18 +15,18 @@ object Impls2 { val T = implicitly[c.WeakTypeTag[T]] val U = implicitly[c.WeakTypeTag[U]] val body = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString + " " + U.toString)))) - c.Expr[Unit](body) + c.Expr[Unit](q"""println(${T.toString} + " " + ${U.toString})""") } } object Impls345 { def foo[T, U: c.WeakTypeTag, V](c: Context)(implicit T: c.WeakTypeTag[T], V: c.WeakTypeTag[V]): c.Expr[Unit] = { import c.universe._ - c.Expr(Block(List( - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(T.toString)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(implicitly[c.WeakTypeTag[U]].toString)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant(V.toString))))), - Literal(Constant(())))) + c.Expr(q""" + println(${T.toString}) + println(${implicitly[c.WeakTypeTag[U]].toString}) + println(${V.toString}) + """) } } diff --git a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala index 95d746980e..043675ec00 100644 --- a/test/files/run/macro-impl-default-params/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-default-params/Impls_Macros_1.scala @@ -6,13 +6,12 @@ object Impls { import c.{prefix => prefix} import c.universe._ val U = implicitly[c.WeakTypeTag[U]] - val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo_targs...")))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix is: " + prefix.staticType)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("type of prefix tree is: " + prefix.tree.tpe)))), - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("U is: " + U.tpe))))), - Literal(Constant(()))) - c.Expr[Unit](body) + c.Expr[Unit](q""" + println("invoking foo_targs...") + println("type of prefix is: " + ${prefix.staticType.toString}) + println("type of prefix tree is: " + ${prefix.tree.tpe.toString}) + println("U is: " + ${U.tpe.toString}) + """) } } diff --git a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala index 738c88bbc8..5f3bbac719 100644 --- a/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala +++ b/test/files/run/macro-impl-rename-context/Impls_Macros_1.scala @@ -3,10 +3,7 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(unconventionalName: Ctx)(x: unconventionalName.Expr[Int]) = { import unconventionalName.universe._ - val body = Block(List( - Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("invoking foo..."))))), - Literal(Constant(()))) - unconventionalName.Expr[Unit](body) + unconventionalName.Expr[Unit](q"""println("invoking foo...")""") } } diff --git a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala index 9b8dafaa97..24eacb36de 100644 --- a/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala +++ b/test/files/run/macro-impl-tparam-only-in-impl/Impls_1.scala @@ -1,5 +1,5 @@ import scala.reflect.macros.{Context => Ctx} object Impls { - def foo[U <: String](c: Ctx): c.Expr[Unit] = c.literalUnit + def foo[U <: String](c: Ctx): c.Expr[Unit] = { import c.universe._; c.Expr[Unit](q"()") } } diff --git a/test/files/run/macro-openmacros/Impls_Macros_1.scala b/test/files/run/macro-openmacros/Impls_Macros_1.scala index 50a1782431..884d7f8825 100644 --- a/test/files/run/macro-openmacros/Impls_Macros_1.scala +++ b/test/files/run/macro-openmacros/Impls_Macros_1.scala @@ -14,9 +14,9 @@ object Macros { } import c.universe._ - val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), TermName("foo"))) else c.literalUnit + val next = if (c.enclosingMacros.length < 3) c.Expr[Unit](Select(Ident(c.mirror.staticModule("Macros")), TermName("foo"))) else c.Expr[Unit](Literal(Constant(()))) c.universe.reify { - println(c.literal(normalizePaths(c.enclosingMacros.toString)).splice) + println(c.Expr[String](Literal(Constant(normalizePaths(c.enclosingMacros.toString)))).splice) next.splice } } diff --git a/test/files/run/macro-reify-nested-a.check b/test/files/run/macro-reify-nested-a.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/macro-reify-nested-a.check +++ /dev/null diff --git a/test/files/run/macro-reify-nested-b.check b/test/files/run/macro-reify-nested-b.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/macro-reify-nested-b.check +++ /dev/null diff --git a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala index 5330d0e32b..f454fc430a 100644 --- a/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala +++ b/test/files/run/macro-reify-splice-outside-reify/Impls_Macros_1.scala @@ -2,9 +2,9 @@ import scala.reflect.macros.{Context => Ctx} object Impls { def foo(c: Ctx)(x: c.Expr[Int]) = { + import c.universe._ val x1 = c.Expr[Int](c.resetAllAttrs(x.tree)) -// was: c.literal(x1.splice) - c.literal(c.eval(x1)) + c.Expr[Int](Literal(Constant(c.eval(x1)))) } } diff --git a/test/files/run/macro-settings/Impls_Macros_1.scala b/test/files/run/macro-settings/Impls_Macros_1.scala index 83d80a5bff..9257784cf2 100644 --- a/test/files/run/macro-settings/Impls_Macros_1.scala +++ b/test/files/run/macro-settings/Impls_Macros_1.scala @@ -1,8 +1,11 @@ import scala.reflect.macros.Context object Impls { - def impl(c: Context) = c.universe.reify { - println(c.literal(c.settings.toString).splice) + def impl(c: Context) = { + import c.universe._ + reify { + println(c.Expr[String](Literal(Constant(c.settings.toString))).splice) + } } } diff --git a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala index 8d7d3b5d3d..1b914ac797 100644 --- a/test/files/run/macro-sip19-revised/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19-revised/Impls_Macros_1.scala @@ -11,7 +11,8 @@ object Macros { val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point - c.universe.reify { SourceLocation1(outer.splice, c.literal(fileName).splice, c.literal(line).splice, c.literal(charOffset).splice) } + def literal[T](x: T) = c.Expr[T](Literal(Constant(x))) + c.universe.reify { SourceLocation1(outer.splice, literal(fileName).splice, literal(line).splice, literal(charOffset).splice) } } implicit def sourceLocation: SourceLocation1 = macro impl diff --git a/test/files/run/macro-sip19/Impls_Macros_1.scala b/test/files/run/macro-sip19/Impls_Macros_1.scala index 4c165ed1b8..95e19c4fd1 100644 --- a/test/files/run/macro-sip19/Impls_Macros_1.scala +++ b/test/files/run/macro-sip19/Impls_Macros_1.scala @@ -7,7 +7,8 @@ object Macros { val fileName = fun.pos.source.file.file.getName val line = fun.pos.line val charOffset = fun.pos.point - c.universe.reify { SourceLocation(c.literal(fileName).splice, c.literal(line).splice, c.literal(charOffset).splice) } + def literal[T](x: T) = c.Expr[T](Literal(Constant(x))) + c.universe.reify { SourceLocation(literal(fileName).splice, literal(line).splice, literal(charOffset).splice) } } implicit def sourceLocation: SourceLocation = macro impl diff --git a/test/files/run/macro-system-properties.check b/test/files/run/macro-system-properties.check index ff96a34426..c61fe7f2cf 100644 --- a/test/files/run/macro-system-properties.check +++ b/test/files/run/macro-system-properties.check @@ -8,7 +8,7 @@ import reflect.macros.Context scala> object GrabContext { def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) // System.properties lets you stash true globals (unlike statics which are classloader scoped) - def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } + def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } def grab() = macro impl } defined object GrabContext diff --git a/test/files/run/macro-system-properties.scala b/test/files/run/macro-system-properties.scala index e182defc81..9dcd044dbd 100644 --- a/test/files/run/macro-system-properties.scala +++ b/test/files/run/macro-system-properties.scala @@ -7,7 +7,7 @@ object Test extends ReplTest { object GrabContext { def lastContext = Option(System.getProperties.get("lastContext").asInstanceOf[reflect.macros.runtime.Context]) // System.properties lets you stash true globals (unlike statics which are classloader scoped) - def impl(c: Context)() = { System.getProperties.put("lastContext", c); c.literalUnit } + def impl(c: Context)() = { import c.universe._; System.getProperties.put("lastContext", c); c.Expr[Unit](q"()") } def grab() = macro impl } object Test { class C(implicit a: Any) { GrabContext.grab } } diff --git a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala index dbeb7efbc0..cd37c269b5 100644 --- a/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-implicitsdisabled/Impls_Macros_1.scala @@ -6,7 +6,7 @@ object Macros { val tree1 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withImplicitViewsDisabled = false) - c.literal(ttree1.toString) + c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_implicits_enabled = macro impl_with_implicits_enabled @@ -17,10 +17,10 @@ object Macros { try { val tree2 = Apply(Select(Literal(Constant(1)), TermName("$minus$greater")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withImplicitViewsDisabled = true) - c.literal(ttree2.toString) + c.Expr[String](Literal(Constant(ttree2.toString))) } catch { case ex: Throwable => - c.literal(ex.toString) + c.Expr[String](Literal(Constant(ex.toString))) } } diff --git a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala index ff535fea8d..2532cfd2b9 100644 --- a/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled/Impls_Macros_1.scala @@ -7,7 +7,7 @@ object Macros { val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) val tree1 = Apply(Select(ru, TermName("reify")), List(Literal(Constant(2)))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) - c.literal(ttree1.toString) + c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_macros_enabled = macro impl_with_macros_enabled @@ -23,7 +23,7 @@ object Macros { val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Literal(Constant(2)))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) - c.literal(ttree2.toString) + c.Expr[String](Literal(Constant(ttree2.toString))) } def foo_with_macros_disabled = macro impl_with_macros_disabled diff --git a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala index a96e0c53b6..7b22793df9 100644 --- a/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala +++ b/test/files/run/macro-typecheck-macrosdisabled2/Impls_Macros_1.scala @@ -7,7 +7,7 @@ object Macros { val ru = Select(Select(Select(Select(Ident(TermName("scala")), TermName("reflect")), TermName("runtime")), TermName("package")), TermName("universe")) val tree1 = Apply(Select(ru, TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree1 = c.typeCheck(tree1, withMacrosDisabled = false) - c.literal(ttree1.toString) + c.Expr[String](Literal(Constant(ttree1.toString))) } def foo_with_macros_enabled = macro impl_with_macros_enabled @@ -23,7 +23,7 @@ object Macros { val tree2 = Apply(Select(Ident(ru), TermName("reify")), List(Apply(Select(Ident(TermName("scala")), TermName("Array")), List(Literal(Constant(2)))))) val ttree2 = c.typeCheck(tree2, withMacrosDisabled = true) - c.literal(ttree2.toString) + c.Expr[String](Literal(Constant(ttree2.toString))) } def foo_with_macros_disabled = macro impl_with_macros_disabled diff --git a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala index bcbd12817b..6695a297ea 100644 --- a/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-consfromsls/Impls_Macros_1.scala @@ -2,14 +2,20 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = c.universe.reify { - println("A = " + c.literal(implicitly[c.WeakTypeTag[A]].toString).splice) - x.splice :: xs.splice + def cons_impl[A: c.WeakTypeTag](c: Context)(x: c.Expr[A], xs: c.Expr[List[A]]): c.Expr[List[A]] = { + import c.universe._ + reify { + println("A = " + c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[A]].toString))).splice) + x.splice :: xs.splice + } } - def nil_impl[B: c.WeakTypeTag](c: Context): c.Expr[List[B]] = c.universe.reify { - println("B = " + c.literal(implicitly[c.WeakTypeTag[B]].toString).splice) - Nil + def nil_impl[B: c.WeakTypeTag](c: Context): c.Expr[List[B]] = { + import c.universe._ + reify { + println("B = " + c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[B]].toString))).splice) + Nil + } } def cons[A](x: A, xs: List[A]): List[A] = macro cons_impl[A] diff --git a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala index 0244273b6f..85877b3f13 100644 --- a/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala +++ b/test/files/run/macro-undetparams-macroitself/Impls_Macros_1.scala @@ -2,7 +2,10 @@ import scala.reflect.runtime.universe._ import scala.reflect.macros.Context object Macros { - def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = c.universe.reify { println(c.literal(implicitly[c.WeakTypeTag[T]].toString).splice) } + def impl[T: c.WeakTypeTag](c: Context)(foo: c.Expr[T]): c.Expr[Unit] = { + import c.universe._ + reify { println(c.Expr[String](Literal(Constant(implicitly[c.WeakTypeTag[T]].toString))).splice) } + } def foo[T](foo: T) = macro impl[T] }
\ No newline at end of file diff --git a/test/files/run/origins.flags b/test/files/run/origins.flags index a7e64e4f0c..690753d807 100644 --- a/test/files/run/origins.flags +++ b/test/files/run/origins.flags @@ -1 +1 @@ --no-specialization
\ No newline at end of file +-no-specialization -Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/primitive-sigs-2-new.flags b/test/files/run/primitive-sigs-2-new.flags new file mode 100644 index 0000000000..2349d8294d --- /dev/null +++ b/test/files/run/primitive-sigs-2-new.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline diff --git a/test/files/run/primitive-sigs-2-old.flags b/test/files/run/primitive-sigs-2-old.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/run/primitive-sigs-2-old.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index 10d2ed5af7..1cd94ccb45 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -12,7 +12,7 @@ superaccessors 6 add super accessors in traits and nested classes uncurry 10 uncurry, translate function values to anonymous classes tailcalls 11 replace tail calls by jumps specialize 12 @specialized-driven class and method specialization - explicitouter 13 this refs to outer pointers, translate patterns + explicitouter 13 this refs to outer pointers erasure 14 erase types, add interfaces for traits posterasure 15 clean up erased inline classes lazyvals 16 allocate bitmaps, translate lazy vals into lazified defs @@ -21,6 +21,7 @@ superaccessors 6 add super accessors in traits and nested classes flatten 19 eliminate inner classes mixin 20 mixin composition cleanup 21 platform-specific cleanups, generate reflective calls - icode 22 generate portable intermediate code - jvm 23 generate JVM bytecode - terminal 24 the last phase during a compilation run + delambdafy 22 remove lambdas + icode 23 generate portable intermediate code + jvm 24 generate JVM bytecode + terminal 25 the last phase during a compilation run diff --git a/test/files/run/range.check b/test/files/run/range.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/range.check +++ /dev/null diff --git a/test/files/run/reflection-fancy-java-classes.check b/test/files/run/reflection-fancy-java-classes.check new file mode 100644 index 0000000000..258208dd99 --- /dev/null +++ b/test/files/run/reflection-fancy-java-classes.check @@ -0,0 +1,12 @@ +===== JAVA POV ===== +class Foo_1$1 +getEnclosingClass = class Foo_1 +getEnclosingMethod = null +getEnclosingConstructor = null +isMemberClass = false +isLocalClass = false +isAnonymousClass = true + +===== SCALA POV ===== +class 1 +object Foo_1 diff --git a/test/files/run/reflection-fancy-java-classes/Foo_1.java b/test/files/run/reflection-fancy-java-classes/Foo_1.java new file mode 100644 index 0000000000..f6fd76124b --- /dev/null +++ b/test/files/run/reflection-fancy-java-classes/Foo_1.java @@ -0,0 +1,5 @@ +public class Foo_1 { + public static Bar bar = new Bar(); + private static class Bar { + } +}
\ No newline at end of file diff --git a/test/files/run/reflection-fancy-java-classes/Test_2.scala b/test/files/run/reflection-fancy-java-classes/Test_2.scala new file mode 100644 index 0000000000..271960ee79 --- /dev/null +++ b/test/files/run/reflection-fancy-java-classes/Test_2.scala @@ -0,0 +1,20 @@ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} + +object Test extends App { + println("===== JAVA POV =====") + val jfancy = Class.forName("Foo_1$1") + println(jfancy) + println("getEnclosingClass = " + jfancy.getEnclosingClass) + println("getEnclosingMethod = " + jfancy.getEnclosingMethod) + println("getEnclosingConstructor = " + jfancy.getEnclosingConstructor) + println("isMemberClass = " + jfancy.isMemberClass) + println("isLocalClass = " + jfancy.isLocalClass) + println("isAnonymousClass = " + jfancy.isAnonymousClass) + + println("") + println("===== SCALA POV =====") + val sfancy = cm.classSymbol(jfancy) + println(sfancy) + println(sfancy.owner) +}
\ No newline at end of file diff --git a/test/files/run/reflection-sync-potpourri.scala b/test/files/run/reflection-sync-potpourri.scala new file mode 100644 index 0000000000..0ad5f2ab66 --- /dev/null +++ b/test/files/run/reflection-sync-potpourri.scala @@ -0,0 +1,32 @@ +import scala.reflect.runtime.universe._ + +// this test checks that under heavily multithreaded conditions: +// 1) scala.reflect.runtime.universe, its rootMirror and definitions are initialized correctly +// 2) symbols are correctly materialized into PackageScopes (no dupes) +// 3) unpickling works okay even we unpickle the same symbol a lot of times + +object Test extends App { + def foo[T: TypeTag](x: T) = typeOf[T].toString + val n = 1000 + val rng = new scala.util.Random() + val types = List( + () => typeOf[java.lang.reflect.Method], + () => typeOf[java.lang.annotation.Annotation], + () => typeOf[scala.io.BufferedSource], + () => typeOf[scala.io.Codec]) + val perms = types.permutations.toList + def force(lazytpe: () => Type): String = { + lazytpe().typeSymbol.typeSignature + lazytpe().toString + } + val diceRolls = List.fill(n)(rng.nextInt(perms.length)) + val threads = (1 to n) map (i => new Thread(s"Reflector-$i") { + override def run(): Unit = { + val s1 = foo("42") + val s2 = perms(diceRolls(i - 1)).map(x => force(x)).sorted.mkString(", ") + assert(s1 == "java.lang.String") + assert(s2 == "java.lang.annotation.Annotation, java.lang.reflect.Method, scala.io.BufferedSource, scala.io.Codec") + } + }) + threads foreach (_.start) +}
\ No newline at end of file diff --git a/test/files/run/reify_for1.check b/test/files/run/reify_for1.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/reify_for1.check +++ /dev/null diff --git a/test/files/run/reify_fors_oldpatmat.flags b/test/files/run/reify_fors_oldpatmat.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/reify_fors_oldpatmat.flags +++ /dev/null diff --git a/test/files/run/reify_maps_oldpatmat.flags b/test/files/run/reify_maps_oldpatmat.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/reify_maps_oldpatmat.flags +++ /dev/null diff --git a/test/files/run/repl-term-macros.check b/test/files/run/repl-term-macros.check index 2a143a1777..63bafe401b 100644 --- a/test/files/run/repl-term-macros.check +++ b/test/files/run/repl-term-macros.check @@ -9,7 +9,7 @@ import language.experimental.macros scala> -scala> def impl1(c: Context) = c.literalUnit +scala> def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } impl1: (c: scala.reflect.macros.Context)c.Expr[Unit] scala> def foo1 = macro impl1 @@ -19,7 +19,7 @@ scala> foo1 scala> -scala> def impl2(c: Context)() = c.literalUnit +scala> def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") } impl2: (c: scala.reflect.macros.Context)()c.Expr[Unit] scala> def foo2() = macro impl2 @@ -29,7 +29,7 @@ scala> foo2() scala> -scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = c.literalUnit +scala> def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } impl3: (c: scala.reflect.macros.Context)(x: c.Expr[Int])(y: c.Expr[Int])c.Expr[Unit] scala> def foo3(x: Int)(y: Int) = macro impl3 diff --git a/test/files/run/repl-term-macros.scala b/test/files/run/repl-term-macros.scala index f826259be9..125e397b22 100644 --- a/test/files/run/repl-term-macros.scala +++ b/test/files/run/repl-term-macros.scala @@ -5,15 +5,15 @@ object Test extends ReplTest { import scala.reflect.macros.Context import language.experimental.macros -def impl1(c: Context) = c.literalUnit +def impl1(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo1 = macro impl1 foo1 -def impl2(c: Context)() = c.literalUnit +def impl2(c: Context)() = { import c.universe._; c.Expr[Unit](q"()") } def foo2() = macro impl2 foo2() -def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = c.literalUnit +def impl3(c: Context)(x: c.Expr[Int])(y: c.Expr[Int]) = { import c.universe._; c.Expr[Unit](q"()") } def foo3(x: Int)(y: Int) = macro impl3 foo3(2)(3) """ diff --git a/test/files/run/static-module-method.check b/test/files/run/static-module-method.check new file mode 100644 index 0000000000..ce01362503 --- /dev/null +++ b/test/files/run/static-module-method.check @@ -0,0 +1 @@ +hello diff --git a/test/files/run/static-module-method.scala b/test/files/run/static-module-method.scala new file mode 100644 index 0000000000..a8691300de --- /dev/null +++ b/test/files/run/static-module-method.scala @@ -0,0 +1,14 @@ +// During development of delayed delambdafy there was a problem where +// GenASM would eliminate a loadmodule for all methods defined within that module +// even if those methods were static. This test would thus fail +// with a verify error under -Ydelambdafy:method + +object Test { + def moduleMethod(x: String) = x + + def map(x: String, f: String => String) = f(x) + + def main(args: Array[String]) { + println(map("hello", Test.moduleMethod)) + } +}
\ No newline at end of file diff --git a/test/files/run/t0668.check b/test/files/run/t0668.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t0668.check +++ /dev/null diff --git a/test/files/run/t1167.flags b/test/files/run/t1167.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/run/t1167.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/t1829.check b/test/files/run/t1829.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t1829.check +++ /dev/null diff --git a/test/files/run/t2594_tcpoly.check b/test/files/run/t2594_tcpoly.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t2594_tcpoly.check +++ /dev/null diff --git a/test/files/run/t3346a.check b/test/files/run/t3346a.check new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/test/files/run/t3346a.check @@ -0,0 +1 @@ +1 diff --git a/test/files/run/t3346a.scala b/test/files/run/t3346a.scala new file mode 100644 index 0000000000..c0a90b011b --- /dev/null +++ b/test/files/run/t3346a.scala @@ -0,0 +1,11 @@ +import scala.language.implicitConversions + +object Test extends App { + class Rep[T](x : T) + + class SomeOps[T](x : Rep[T]) { def foo = 1 } + implicit def mkOps[X, T](x : X)(implicit conv: X => Rep[T]) : SomeOps[T] = new SomeOps(conv(x)) + + val a: Rep[Int] = new Rep(42) + println(a.foo) +}
\ No newline at end of file diff --git a/test/files/run/t3346d.scala b/test/files/run/t3346d.scala new file mode 100644 index 0000000000..3f79896210 --- /dev/null +++ b/test/files/run/t3346d.scala @@ -0,0 +1,21 @@ +import scala.language.implicitConversions + +object Test extends App { + trait TARInt + + trait Basket[A,B] { + def iAmABasket = {} + } + + trait BasketFactory[A,B] { + def create(v: A): Basket[A,B] + } + + implicit val bf = new BasketFactory[Int,TARInt] { + def create(v: Int): Basket[Int,TARInt] = new Basket[Int, TARInt]{} + } + + implicit def i2[A,B](a: A)(implicit bf: BasketFactory[A,B]): Basket[A,B] = bf.create(a) + + 1.iAmABasket // <-- i2 conversion not applicable +}
\ No newline at end of file diff --git a/test/files/run/t3346e.check b/test/files/run/t3346e.check new file mode 100644 index 0000000000..71a57ffa70 --- /dev/null +++ b/test/files/run/t3346e.check @@ -0,0 +1,12 @@ +eqw +List(0, 2) +List(0, 2) +BitSet(0, 2) +Vector(113, 119, 101) +qwe +List(2, 0) +List(0!) +BitSet(0, 2) +qwe +List(2, 0) +qwe diff --git a/test/files/run/t3346e.scala b/test/files/run/t3346e.scala new file mode 100644 index 0000000000..ac0de564d4 --- /dev/null +++ b/test/files/run/t3346e.scala @@ -0,0 +1,81 @@ +import scala.language.implicitConversions +import scala.collection.generic.CanBuildFrom +import scala.math.Ordering +import collection.{TraversableLike, SeqLike} +import collection.immutable.BitSet + +class QuickSort[Coll](a: Coll) { + //should be able to sort only something with defined order (someting like a Seq) + def quickSort[T](implicit ev0: Coll => SeqLike[T, Coll], + cbf: CanBuildFrom[Coll, T, Coll], + n: Ordering[T]): Coll = { + quickSortAnything(ev0, cbf, n) + } + + //we can even sort a Set, if we really want to + def quickSortAnything[T](implicit ev0: Coll => TraversableLike[T, Coll], + cbf: CanBuildFrom[Coll, T, Coll], + n: Ordering[T]): Coll = { + import n._ + if (a.size < 2) { + a + } else { + // We pick the first value for the pivot. + val pivot = a.head + val (lower, tmp) = a.partition(_ < pivot) + val (upper, same) = tmp.partition(_ > pivot) + val b = cbf() + b.sizeHint(a.size) + b ++= new QuickSort(lower).quickSortAnything + b ++= same + b ++= new QuickSort(upper).quickSortAnything + b.result + } + } +} + +class FilterMap[Repr](a: Repr) { + def filterMap[A, B, That](f: A => Option[B])(implicit ev0: Repr => TraversableLike[A, Repr], + cbf: CanBuildFrom[Repr, B, That]): That = { + a.flatMap(e => f(e).toSeq) + } +} + +class FilterMapFixed[A, Repr <% TraversableLike[A, Repr]](a: Repr) { + def filterMap2[B, That](f: A => Option[B])(implicit cbf: CanBuildFrom[Repr, B, That]): That = { + a.flatMap(e => f(e).toSeq) + } +} + +object MyEnhancements { + implicit def toQS[Coll](a: Coll) = new QuickSort(a) + implicit def toFM[Coll](a: Coll) = new FilterMap(a) + implicit def toFM2[A, Repr <% TraversableLike[A, Repr]](a: Repr) = new FilterMapFixed(a) +} + +object Test extends App { + + import MyEnhancements._ + + println("qwe".quickSort) + println(Array(2, 0).quickSort.toList) + println(Seq(2, 0).quickSort) + //not very useful to sort a set, but just as a demonstration + println(BitSet(2, 0).quickSortAnything) + + //need to hint type inferencer, + //probably will be able to overcome after https://issues.scala-lang.org/browse/SI-4699 and + // related issues are fixed (by moving ev0 parameter from filterMap to toFM), see toFM2 + println("qwe".filterMap((c: Char) => Some(c.toInt))) + println("qwe".filterMap((c: Char) => Some(c))) + println(Array(2, 0).filterMap((c: Int) => Some(c.toInt)).toList) + println(Seq(2, 0).filterMap((c: Int) => if (c < 2) Some(c + "!") else None)) + def test(i:Int) = Option(i) + println(BitSet(2,0).filterMap(test)) + + println(toFM2("qwe").filterMap2(c => Some(c))) + println(toFM2(Array(2, 0)).filterMap2(c => Some(c.toInt)).toList) + //No implicit view available from java.lang.String => scala.collection.TraversableLike[A,java.lang.String]. :( + //Not anymore :) + println("qwe".filterMap2(c => Some(c))) +} diff --git a/test/files/run/t3346f.check b/test/files/run/t3346f.check new file mode 100644 index 0000000000..fd3c81a4d7 --- /dev/null +++ b/test/files/run/t3346f.check @@ -0,0 +1,2 @@ +5 +5 diff --git a/test/files/run/t3346f.scala b/test/files/run/t3346f.scala new file mode 100644 index 0000000000..4799ca2ca9 --- /dev/null +++ b/test/files/run/t3346f.scala @@ -0,0 +1,15 @@ +import scala.language.implicitConversions +import scala.language.reflectiveCalls + +object Test extends App { + trait Foo[A] + implicit def fooString: Foo[String] = null + implicit def value[A](implicit foo: Foo[A]) = 5 + + println(implicitly[Int]) + + implicit def conversion[A](x: Int)(implicit foo: Foo[A]) = new { + def aMethod = 5 + } + println(1.aMethod) +} diff --git a/test/files/run/t3346g.check b/test/files/run/t3346g.check new file mode 100644 index 0000000000..ce894825e0 --- /dev/null +++ b/test/files/run/t3346g.check @@ -0,0 +1 @@ +A(3,asdf) diff --git a/test/files/run/t3346g.scala b/test/files/run/t3346g.scala new file mode 100644 index 0000000000..d7c9d79c7f --- /dev/null +++ b/test/files/run/t3346g.scala @@ -0,0 +1,9 @@ +import scala.language.implicitConversions + +case class A(b: Int, c: String) + +object Test extends App { + implicit def s2i(s: String): Int = s.length + implicit def toA[T](t: T)(implicit f: T => Int): A = A(f(t), t.toString) + println("asdf".copy(b = 3)) +}
\ No newline at end of file diff --git a/test/files/run/t3346h.check b/test/files/run/t3346h.check new file mode 100644 index 0000000000..587be6b4c3 --- /dev/null +++ b/test/files/run/t3346h.check @@ -0,0 +1 @@ +x diff --git a/test/files/run/t3346h.scala b/test/files/run/t3346h.scala new file mode 100644 index 0000000000..97ebc9380c --- /dev/null +++ b/test/files/run/t3346h.scala @@ -0,0 +1,9 @@ +import scala.language.implicitConversions + +object Test extends App { + trait Fundep[T, U] { def u(t: T): U } + class C { def y = "x" } + implicit val FundepStringC = new Fundep[String, C]{ def u(t: String) = new C } + implicit def foo[T, U](x: T)(implicit y: Fundep[T, U]): U = y.u(x) + println("x".y) +}
\ No newline at end of file diff --git a/test/files/run/t3346j.check b/test/files/run/t3346j.check new file mode 100644 index 0000000000..59e8626fc5 --- /dev/null +++ b/test/files/run/t3346j.check @@ -0,0 +1 @@ +Int diff --git a/test/files/run/t3346j.scala b/test/files/run/t3346j.scala new file mode 100644 index 0000000000..98b5a870a7 --- /dev/null +++ b/test/files/run/t3346j.scala @@ -0,0 +1,11 @@ +import scala.language.implicitConversions +import scala.language.reflectiveCalls +import scala.reflect.runtime.universe._ + +object Test extends App { + class A[T] + class B[T] + implicit def foo[T: TypeTag](a: A[T])(implicit b: B[T]) = new { def baz = typeOf[T] } + implicit def bar[T <: Int]: B[T] = new B[T]() + println(new A[Int]().baz) +}
\ No newline at end of file diff --git a/test/files/run/t3897.flags b/test/files/run/t3897.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/run/t3897.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline
\ No newline at end of file diff --git a/test/files/run/t4542.check b/test/files/run/t4542.check index 5a8108dcbc..a53f31a3c7 100644 --- a/test/files/run/t4542.check +++ b/test/files/run/t4542.check @@ -9,9 +9,6 @@ defined class Foo scala> val f = new Foo <console>:8: warning: class Foo is deprecated: foooo val f = new Foo - ^ -<console>:8: warning: class Foo is deprecated: foooo - val f = new Foo ^ f: Foo = Bippy diff --git a/test/files/run/t5229_1.check b/test/files/run/t5229_1.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5229_1.check +++ /dev/null diff --git a/test/files/run/t5271_4.check b/test/files/run/t5271_4.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5271_4.check +++ /dev/null diff --git a/test/files/run/t5272_1_oldpatmat.flags b/test/files/run/t5272_1_oldpatmat.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5272_1_oldpatmat.flags +++ /dev/null diff --git a/test/files/run/t5272_2_oldpatmat.flags b/test/files/run/t5272_2_oldpatmat.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5272_2_oldpatmat.flags +++ /dev/null diff --git a/test/files/run/t5273_1_oldpatmat.flags b/test/files/run/t5273_1_oldpatmat.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5273_1_oldpatmat.flags +++ /dev/null diff --git a/test/files/run/t5273_2a_oldpatmat.flags b/test/files/run/t5273_2a_oldpatmat.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5273_2a_oldpatmat.flags +++ /dev/null diff --git a/test/files/run/t5273_2b_oldpatmat.flags b/test/files/run/t5273_2b_oldpatmat.flags deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5273_2b_oldpatmat.flags +++ /dev/null diff --git a/test/files/run/t5415.check b/test/files/run/t5415.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5415.check +++ /dev/null diff --git a/test/files/run/t5418.check b/test/files/run/t5418.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5418.check +++ /dev/null diff --git a/test/files/run/t5545.check b/test/files/run/t5545.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5545.check +++ /dev/null diff --git a/test/files/run/t5894.scala b/test/files/run/t5894.scala index abeec32365..5deda34489 100644 --- a/test/files/run/t5894.scala +++ b/test/files/run/t5894.scala @@ -4,7 +4,7 @@ class Test object Test { def foo = macro fooImpl - def fooImpl(c: reflect.macros.Context) = c.literalUnit + def fooImpl(c: reflect.macros.Context) = { import c.universe._; c.Expr[Unit](q"()") } def main(args: Array[String]) { try { diff --git a/test/files/run/t5923a/Macros_1.scala b/test/files/run/t5923a/Macros_1.scala index 97076eb102..741379cf34 100644 --- a/test/files/run/t5923a/Macros_1.scala +++ b/test/files/run/t5923a/Macros_1.scala @@ -46,7 +46,7 @@ object Macros { if (sym.isParameter && !sym.isSkolem) TypeTag.Nothing.asInstanceOf[TypeTag[T]] else ttag0 } - reify(C[T](c.literal(weakTypeOf[T].toString).splice)) + reify(C[T](c.Expr[String](Literal(Constant(weakTypeOf[T].toString))).splice)) } } }
\ No newline at end of file diff --git a/test/files/run/t5923d.check b/test/files/run/t5923d.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5923d.check +++ /dev/null diff --git a/test/files/run/t5940.scala b/test/files/run/t5940.scala index 147ff38256..9c8f702c68 100644 --- a/test/files/run/t5940.scala +++ b/test/files/run/t5940.scala @@ -7,12 +7,12 @@ object Test extends DirectTest { import scala.reflect.macros.Context object Impls { - def impl(c: Context) = c.literalUnit + def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } } object Macros { //import Impls._ - def impl(c: Context) = c.literalUnit + def impl(c: Context) = { import c.universe._; c.Expr[Unit](q"()") } def foo = macro impl } """ diff --git a/test/files/run/t5942.check b/test/files/run/t5942.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t5942.check +++ /dev/null diff --git a/test/files/run/t6028.scala b/test/files/run/t6028.scala index cab17535fc..a6f920c5bb 100644 --- a/test/files/run/t6028.scala +++ b/test/files/run/t6028.scala @@ -3,7 +3,7 @@ import java.io.{Console => _, _} object Test extends DirectTest { - override def extraSettings: String = "-usejavacp -Xprint:lambdalift -d " + testOutput.path + override def extraSettings: String = "-usejavacp -Ydelambdafy:inline -Xprint:lambdalift -d " + testOutput.path override def code = """class T(classParam: Int) { | val field: Int = 0 diff --git a/test/files/run/t6102.check b/test/files/run/t6102.check index 4e8efa7b6d..aa3e6cc9e2 100644 --- a/test/files/run/t6102.check +++ b/test/files/run/t6102.check @@ -19,6 +19,7 @@ [running phase flatten on t6102.scala] [running phase mixin on t6102.scala] [running phase cleanup on t6102.scala] +[running phase delambdafy on t6102.scala] [running phase icode on t6102.scala] #partest -optimise [running phase inliner on t6102.scala] diff --git a/test/files/run/t6197.check b/test/files/run/t6197.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t6197.check +++ /dev/null diff --git a/test/files/run/t6198.check b/test/files/run/t6198.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t6198.check +++ /dev/null diff --git a/test/files/run/t6199-toolbox.scala b/test/files/run/t6199-toolbox.scala index 89015f5878..6ba5e50f66 100644 --- a/test/files/run/t6199-toolbox.scala +++ b/test/files/run/t6199-toolbox.scala @@ -4,5 +4,5 @@ import scala.tools.reflect.ToolBox object Test extends App { val tb = cm.mkToolBox() - println(tb.eval(Literal(Constant(())))) + println(tb.eval(q"()")) }
\ No newline at end of file diff --git a/test/files/run/t6240-universe-code-gen.scala b/test/files/run/t6240-universe-code-gen.scala new file mode 100644 index 0000000000..84691639bd --- /dev/null +++ b/test/files/run/t6240-universe-code-gen.scala @@ -0,0 +1,82 @@ +import scala.tools.partest.nest.FileManager._ + +object Test extends App { + val cm = reflect.runtime.currentMirror + val u = cm.universe + import u._ + + val JavaUniverseTpe = typeOf[reflect.runtime.JavaUniverse] + val DefinitionsModule = JavaUniverseTpe.member(TermName("definitions")) + + def forceCode(prefix: String, tp: Type): String = { + def isLazyAccessorOrObject(sym: Symbol) = ( + (sym.isMethod && sym.asMethod.isLazy) + || sym.isModule + ) + val forcables = tp.members.sorted.filter(isLazyAccessorOrObject) + forcables.map { + sym => + val path = s"$prefix.${sym.name}" + " " + ( + if (sym.isPrivate || sym.isProtected) s"// inaccessible: $path" + else path + ) + }.mkString("\n") + } + + val code = + s"""|// Generated Code, validated by run/t6240-universe-code-gen.scala + |package scala.reflect + |package runtime + | + |trait JavaUniverseForce { self: runtime.JavaUniverse => + | def force() { + | Literal(Constant(42)).duplicate + | nme.flattenedName() + | nme.raw + | WeakTypeTag + | TypeTag + | TypeTag.Byte.tpe + | TypeTag.Short.tpe + | TypeTag.Char.tpe + | TypeTag.Int.tpe + | TypeTag.Long.tpe + | TypeTag.Float.tpe + | TypeTag.Double.tpe + | TypeTag.Boolean.tpe + | TypeTag.Unit.tpe + | TypeTag.Any.tpe + | TypeTag.AnyVal.tpe + | TypeTag.AnyRef.tpe + | TypeTag.Object.tpe + | TypeTag.Nothing.tpe + | TypeTag.Null.tpe + | + |${forceCode("this", JavaUniverseTpe)} + |${forceCode("definitions", DefinitionsModule.typeSignature)} + |${forceCode("refChecks", typeOf[scala.reflect.internal.transform.RefChecks])} + |${forceCode("uncurry", typeOf[scala.reflect.internal.transform.UnCurry])} + |${forceCode("erasure", typeOf[scala.reflect.internal.transform.Erasure])} + | } + |}""".stripMargin + + import java.io.File + val testFile = new File(sys.props("partest.test-path")) + val actualFile = new java.io.File(testFile.getParent + "/../../../src/reflect/scala/reflect/runtime/JavaUniverseForce.scala").getCanonicalFile + val actual = scala.io.Source.fromFile(actualFile) + val actualLines = actual.getLines.toList + val generatedLines = code.lines.toList + if (actualLines != generatedLines) { + val msg = s"""|${actualFile} must be updated. + |=========================================================== + | DIFF: + |=========================================================== + |${compareContents(actualLines, generatedLines)} + |=========================================================== + | NEW CONTENTS: + |=========================================================== + |${code}""".stripMargin + + assert(false, msg) + } +} diff --git a/test/files/run/t6240a.check b/test/files/run/t6240a.check new file mode 100644 index 0000000000..29f695b6f4 --- /dev/null +++ b/test/files/run/t6240a.check @@ -0,0 +1 @@ +StepTwo.type diff --git a/test/files/run/t6240a/StepOne.java b/test/files/run/t6240a/StepOne.java new file mode 100644 index 0000000000..342d617c79 --- /dev/null +++ b/test/files/run/t6240a/StepOne.java @@ -0,0 +1,41 @@ +import java.io.File; +import java.io.IOException; +import java.lang.ClassNotFoundException; +import java.lang.NoSuchMethodException; +import java.lang.IllegalAccessException; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.MalformedURLException; + +public class StepOne { + public static void main(String[] args) + throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, IOException { + String[] launchPaths = System.getProperty("launch.classpath").split(File.pathSeparator); + + // move away StepThree + File tempDir = File.createTempFile("temp", Long.toString(System.nanoTime())); + System.setProperty("launch.step.three", tempDir.getAbsolutePath()); + tempDir.delete(); + tempDir.mkdir(); + File[] testClasses = new File(launchPaths[0]).listFiles(); + for (int i = 0; i < testClasses.length; i++) { + File testClass = testClasses[i]; + if (testClass.getPath().contains("StepThree")) { + File testClassMoved = new File(tempDir.getAbsolutePath() + "/" + testClass.getName()); + testClass.renameTo(testClassMoved); + } + } + + // launch StepTwo + URL[] launchURLs = new URL[launchPaths.length]; + for (int i = 0; i < launchPaths.length; i++) { + launchURLs[i] = new File(launchPaths[i]).toURL(); + } + URLClassLoader classLoader = new URLClassLoader(launchURLs, Object.class.getClassLoader()); + Class<?> stepTwo = classLoader.loadClass("StepTwo"); + Method main = stepTwo.getDeclaredMethod("main", String[].class); + main.invoke(null, (Object)(new String[]{})); + } +} diff --git a/test/files/run/t6240a/StepTwo.scala b/test/files/run/t6240a/StepTwo.scala new file mode 100644 index 0000000000..fc3221921d --- /dev/null +++ b/test/files/run/t6240a/StepTwo.scala @@ -0,0 +1,7 @@ +import java.io.File +import java.net.URLClassLoader + +object StepTwo extends App { + import scala.reflect.runtime.universe._ + println(typeOf[StepTwo.type]) +}
\ No newline at end of file diff --git a/test/files/run/t6240a/Test.scala b/test/files/run/t6240a/Test.scala new file mode 100644 index 0000000000..05c3678cbe --- /dev/null +++ b/test/files/run/t6240a/Test.scala @@ -0,0 +1,15 @@ +import java.io.File +import scala.sys.process._ + +object Test extends App { + def prop(key: String) = { + val value = System.getProperties.getProperty(key) + assert(value != null, key) + value + } + val testClassesDir = prop("partest.output") + assert(new File(testClassesDir).exists, testClassesDir) + val fullTestClassesClasspath = testClassesDir + prop("path.separator") + prop("java.class.path") + val javaBinary = if (new File(prop("javacmd")).isAbsolute) prop("javacmd") else prop("java.home") + "/bin/" + prop("javacmd") + List(javaBinary, "-cp", testClassesDir, "-Dlaunch.classpath=" + fullTestClassesClasspath, "StepOne").! +}
\ No newline at end of file diff --git a/test/files/run/t6240b.check b/test/files/run/t6240b.check new file mode 100644 index 0000000000..255836105a --- /dev/null +++ b/test/files/run/t6240b.check @@ -0,0 +1 @@ +StepThree.type diff --git a/test/files/run/t6240b/StepOne.java b/test/files/run/t6240b/StepOne.java new file mode 100644 index 0000000000..342d617c79 --- /dev/null +++ b/test/files/run/t6240b/StepOne.java @@ -0,0 +1,41 @@ +import java.io.File; +import java.io.IOException; +import java.lang.ClassNotFoundException; +import java.lang.NoSuchMethodException; +import java.lang.IllegalAccessException; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.net.MalformedURLException; + +public class StepOne { + public static void main(String[] args) + throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, IOException { + String[] launchPaths = System.getProperty("launch.classpath").split(File.pathSeparator); + + // move away StepThree + File tempDir = File.createTempFile("temp", Long.toString(System.nanoTime())); + System.setProperty("launch.step.three", tempDir.getAbsolutePath()); + tempDir.delete(); + tempDir.mkdir(); + File[] testClasses = new File(launchPaths[0]).listFiles(); + for (int i = 0; i < testClasses.length; i++) { + File testClass = testClasses[i]; + if (testClass.getPath().contains("StepThree")) { + File testClassMoved = new File(tempDir.getAbsolutePath() + "/" + testClass.getName()); + testClass.renameTo(testClassMoved); + } + } + + // launch StepTwo + URL[] launchURLs = new URL[launchPaths.length]; + for (int i = 0; i < launchPaths.length; i++) { + launchURLs[i] = new File(launchPaths[i]).toURL(); + } + URLClassLoader classLoader = new URLClassLoader(launchURLs, Object.class.getClassLoader()); + Class<?> stepTwo = classLoader.loadClass("StepTwo"); + Method main = stepTwo.getDeclaredMethod("main", String[].class); + main.invoke(null, (Object)(new String[]{})); + } +} diff --git a/test/files/run/t6240b/StepThree.scala b/test/files/run/t6240b/StepThree.scala new file mode 100644 index 0000000000..210795d68f --- /dev/null +++ b/test/files/run/t6240b/StepThree.scala @@ -0,0 +1,4 @@ +object StepThree extends App { + import scala.reflect.runtime.universe._ + println(typeOf[StepThree.type]) +}
\ No newline at end of file diff --git a/test/files/run/t6240b/StepTwo.scala b/test/files/run/t6240b/StepTwo.scala new file mode 100644 index 0000000000..88e46492e3 --- /dev/null +++ b/test/files/run/t6240b/StepTwo.scala @@ -0,0 +1,10 @@ +import java.io.File +import java.net.URLClassLoader + +object StepTwo extends App { + val classes = new File(System.getProperty("launch.step.three")) + val cl = new URLClassLoader(Array(classes.toURI.toURL), getClass.getClassLoader) + val stepThree = cl.loadClass("StepThree") + val main = stepThree.getDeclaredMethod("main", classOf[Array[String]]) + main.invoke(null, Array[String]()) +}
\ No newline at end of file diff --git a/test/files/run/t6240b/Test.scala b/test/files/run/t6240b/Test.scala new file mode 100644 index 0000000000..05c3678cbe --- /dev/null +++ b/test/files/run/t6240b/Test.scala @@ -0,0 +1,15 @@ +import java.io.File +import scala.sys.process._ + +object Test extends App { + def prop(key: String) = { + val value = System.getProperties.getProperty(key) + assert(value != null, key) + value + } + val testClassesDir = prop("partest.output") + assert(new File(testClassesDir).exists, testClassesDir) + val fullTestClassesClasspath = testClassesDir + prop("path.separator") + prop("java.class.path") + val javaBinary = if (new File(prop("javacmd")).isAbsolute) prop("javacmd") else prop("java.home") + "/bin/" + prop("javacmd") + List(javaBinary, "-cp", testClassesDir, "-Dlaunch.classpath=" + fullTestClassesClasspath, "StepOne").! +}
\ No newline at end of file diff --git a/test/files/run/t6260b.scala b/test/files/run/t6260b.scala new file mode 100644 index 0000000000..dd2cf4bc4e --- /dev/null +++ b/test/files/run/t6260b.scala @@ -0,0 +1,13 @@ +class C[A](val a: A) extends AnyVal + +class DD { + def foo(c: C[String]) = () + def bar[A <: String](c: C[A]) = () + def baz[A](c: C[A]) = () +} + +object Test extends App { + classOf[DD].getMethod("foo", classOf[String]) + classOf[DD].getMethod("bar", classOf[String]) + classOf[DD].getMethod("baz", classOf[Object]) +} diff --git a/test/files/run/t6381.check b/test/files/run/t6381.check index 5070b67e46..c9d4713aa8 100644 --- a/test/files/run/t6381.check +++ b/test/files/run/t6381.check @@ -4,8 +4,10 @@ Type :help for more information. scala> import language.experimental.macros import language.experimental.macros -scala> def pos_impl(c: reflect.macros.Context): c.Expr[String] = - c.literal(c.enclosingPosition.getClass.toString) +scala> def pos_impl(c: reflect.macros.Context): c.Expr[String] = { + import c.universe._ + c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString))) +} pos_impl: (c: scala.reflect.macros.Context)c.Expr[String] scala> def pos = macro pos_impl diff --git a/test/files/run/t6381.scala b/test/files/run/t6381.scala index 859ec3cb30..4c2a40fe87 100644 --- a/test/files/run/t6381.scala +++ b/test/files/run/t6381.scala @@ -3,8 +3,10 @@ import scala.tools.partest.ReplTest object Test extends ReplTest { def code = """ |import language.experimental.macros - |def pos_impl(c: reflect.macros.Context): c.Expr[String] = - | c.literal(c.enclosingPosition.getClass.toString) + |def pos_impl(c: reflect.macros.Context): c.Expr[String] = { + | import c.universe._ + | c.Expr[String](Literal(Constant(c.enclosingPosition.getClass.toString))) + |} |def pos = macro pos_impl |pos |""".stripMargin.trim diff --git a/test/files/run/t6385.scala b/test/files/run/t6385.scala new file mode 100644 index 0000000000..24fc3cd768 --- /dev/null +++ b/test/files/run/t6385.scala @@ -0,0 +1,13 @@ +object Test { + def main(args: Array[String]) { + val y: AA[Int] = C(2) + val c: Int = y.x.y + assert(c == 2) + } +} +trait AA[T] extends Any { + def x: C[T] +} +case class C[T](val y: T) extends AnyVal with AA[T] { + def x = this +} diff --git a/test/files/run/t6555.scala b/test/files/run/t6555.scala index b1a6137786..cc0e4d1bfa 100644 --- a/test/files/run/t6555.scala +++ b/test/files/run/t6555.scala @@ -3,7 +3,7 @@ import java.io.{Console => _, _} object Test extends DirectTest { - override def extraSettings: String = "-usejavacp -Xprint:specialize -d " + testOutput.path + override def extraSettings: String = "-usejavacp -Xprint:specialize -Ydelambdafy:inline -d " + testOutput.path override def code = "class Foo { val f = (param: Int) => param } " diff --git a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala index 94fd99018e..477829f200 100644 --- a/test/files/run/t7008-scala-defined/Impls_Macros_2.scala +++ b/test/files/run/t7008-scala-defined/Impls_Macros_2.scala @@ -3,9 +3,10 @@ import scala.reflect.macros.Context object Macros { def impl(c: Context) = { + import c.universe._ val decls = c.typeOf[ScalaClassWithCheckedExceptions_1[_]].declarations.toList val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) - c.universe.reify(println(c.literal(s).splice)) + reify(println(c.Expr[String](Literal(Constant(s))).splice)) } def foo = macro impl diff --git a/test/files/run/t7008/Impls_Macros_2.scala b/test/files/run/t7008/Impls_Macros_2.scala index 7a17314085..63c3f9d696 100644 --- a/test/files/run/t7008/Impls_Macros_2.scala +++ b/test/files/run/t7008/Impls_Macros_2.scala @@ -3,9 +3,10 @@ import scala.reflect.macros.Context object Macros { def impl(c: Context) = { + import c.universe._ val decls = c.typeOf[JavaClassWithCheckedExceptions_1[_]].declarations.toList val s = decls.sortBy(_.name.toString).map(decl => (s"${decl.name}: ${decl.annotations}")).mkString(scala.compat.Platform.EOL) - c.universe.reify(println(c.literal(s).splice)) + reify(println(c.Expr[String](Literal(Constant(s))).splice)) } def foo = macro impl diff --git a/test/files/run/t7045.check b/test/files/run/t7045.check new file mode 100644 index 0000000000..28134535c8 --- /dev/null +++ b/test/files/run/t7045.check @@ -0,0 +1,2 @@ +D with C +D with C diff --git a/test/files/run/t7045.scala b/test/files/run/t7045.scala new file mode 100644 index 0000000000..f41baca05e --- /dev/null +++ b/test/files/run/t7045.scala @@ -0,0 +1,12 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +class C +class D { self: C => } + +object Test extends App { + val d = cm.staticClass("D") + println(d.selfType) + d.typeSignature + println(d.selfType) +}
\ No newline at end of file diff --git a/test/files/run/t7047/Impls_Macros_1.scala b/test/files/run/t7047/Impls_Macros_1.scala index 2992e3efe4..a5d55c3a42 100644 --- a/test/files/run/t7047/Impls_Macros_1.scala +++ b/test/files/run/t7047/Impls_Macros_1.scala @@ -12,7 +12,7 @@ object Macros { } catch { case _: Exception => } - c.literalNull + c.Expr[Null](Literal(Constant(null))) } def foo = macro impl diff --git a/test/files/run/t7240.check b/test/files/run/t7240.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t7240.check +++ /dev/null diff --git a/test/files/run/t7341.check b/test/files/run/t7341.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t7341.check +++ /dev/null diff --git a/test/files/run/t7375b/Macros_1.scala b/test/files/run/t7375b/Macros_1.scala index 70e79cc2b4..7a307805db 100644 --- a/test/files/run/t7375b/Macros_1.scala +++ b/test/files/run/t7375b/Macros_1.scala @@ -11,7 +11,7 @@ object Macros { def foo = macro impl def impl(c: Context) = { import c.universe._ - def test[T: c.TypeTag] = reify(println(c.literal(c.reifyRuntimeClass(c.typeOf[T]).toString).splice)).tree + def test[T: c.TypeTag] = reify(println(c.Expr[String](Literal(Constant(c.reifyRuntimeClass(c.typeOf[T]).toString))).splice)).tree def tests = Block(List(test[C1], test[C2], test[F1], test[F2]), Literal(Constant(()))) c.Expr[Unit](tests) } diff --git a/test/files/run/t7510.check b/test/files/run/t7510.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t7510.check +++ /dev/null diff --git a/test/files/run/t7852.check b/test/files/run/t7852.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/t7852.check +++ /dev/null diff --git a/test/files/run/toolbox_parse_package.check b/test/files/run/toolbox_parse_package.check new file mode 100644 index 0000000000..46465980a0 --- /dev/null +++ b/test/files/run/toolbox_parse_package.check @@ -0,0 +1,8 @@ +package foo { + object bar extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + } + } +} diff --git a/test/files/run/toolbox_parse_package.scala b/test/files/run/toolbox_parse_package.scala new file mode 100644 index 0000000000..62412a50d7 --- /dev/null +++ b/test/files/run/toolbox_parse_package.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val toolbox = cm.mkToolBox() + println(toolbox.parse("package foo { object bar }")) +}
\ No newline at end of file diff --git a/test/files/run/typetags_without_scala_reflect_manifest_lookup.check b/test/files/run/typetags_without_scala_reflect_manifest_lookup.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/typetags_without_scala_reflect_manifest_lookup.check +++ /dev/null |