From 814cf34fb00f9ccb001249f4b3445ebc4f9942c9 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 12 Apr 2012 01:59:46 +0200 Subject: Next generation of macros Implements SIP 16: Self-cleaning macros: http://bit.ly/wjjXTZ Features: * Macro defs * Reification * Type tags * Manifests aliased to type tags * Extended reflection API * Several hundred tests * 1111 changed files Not yet implemented: * Reification of refined types * Expr.value splicing * Named and default macro expansions * Intricacies of interaction between macros and implicits * Emission of debug information for macros (compliant with JSR-45) Dedicated to Yuri Alekseyevich Gagarin --- test/pending/neg/reify_packed.check | 4 ++++ test/pending/neg/reify_packed.scala | 10 +++++++++ test/pending/run/macro-expand-default.flags | 1 + .../pending/run/macro-expand-default/Impls_1.scala | 10 +++++++++ .../run/macro-expand-default/Macros_Test_2.scala | 8 +++++++ ...o-expand-implicit-macro-has-context-bound.check | 1 + ...o-expand-implicit-macro-has-context-bound.flags | 1 + .../Impls_1.scala | 10 +++++++++ .../Macros_Test_2.scala | 4 ++++ test/pending/run/macro-expand-named.flags | 1 + test/pending/run/macro-expand-named/Impls_1.scala | 10 +++++++++ .../run/macro-expand-named/Macros_Test_2.scala | 5 +++++ .../run/macro-expand-tparams-prefix-e1.check | 3 +++ .../run/macro-expand-tparams-prefix-e1.flags | 1 + .../macro-expand-tparams-prefix-e1/Impls_1.scala | 12 +++++++++++ .../Macros_Test_2.scala | 13 +++++++++++ .../run/macro-expand-tparams-prefix-f1.check | 3 +++ .../run/macro-expand-tparams-prefix-f1.flags | 1 + .../macro-expand-tparams-prefix-f1/Impls_1.scala | 12 +++++++++++ .../Macros_Test_2.scala | 13 +++++++++++ test/pending/run/macro-overload.check | 4 ---- test/pending/run/macro-overload.flags | 1 - test/pending/run/macro-overload/Macros_1.scala | 9 -------- test/pending/run/macro-overload/Test_2.scala | 6 ------ test/pending/run/macro-quasiinvalidbody-a.check | 1 + test/pending/run/macro-quasiinvalidbody-a.flags | 1 + .../run/macro-quasiinvalidbody-a/Impls_1.scala | 5 +++++ .../macro-quasiinvalidbody-a/Macros_Test_2.scala | 10 +++++++++ test/pending/run/macro-quasiinvalidbody-b.check | 1 + test/pending/run/macro-quasiinvalidbody-b.flags | 1 + .../run/macro-quasiinvalidbody-b/Impls_1.scala | 7 ++++++ .../macro-quasiinvalidbody-b/Macros_Test_2.scala | 10 +++++++++ test/pending/run/macro-reify-array.flags | 1 + test/pending/run/macro-reify-array/Macros_1.scala | 11 ++++++++++ test/pending/run/macro-reify-array/Test_2.scala | 4 ++++ test/pending/run/macro-reify-eval-vs-value.flags | 1 + .../run/macro-reify-eval-vs-value/Macros_1.scala | 25 ++++++++++++++++++++++ .../run/macro-reify-eval-vs-value/Test_2.scala | 5 +++++ ...cro-reify-groundtypetag-hktypeparams-tags.check | 2 ++ .../Test.scala | 9 ++++++++ test/pending/run/macro-reify-tagful-b.check | 1 + test/pending/run/macro-reify-tagful-b.flags | 1 + .../run/macro-reify-tagful-b/Macros_1.scala | 11 ++++++++++ test/pending/run/macro-reify-tagful-b/Test_2.scala | 4 ++++ test/pending/run/macro-reify-tagless-b.check | 3 +++ test/pending/run/macro-reify-tagless-b.flags | 1 + .../run/macro-reify-tagless-b/Impls_Macros_1.scala | 11 ++++++++++ .../pending/run/macro-reify-tagless-b/Test_2.scala | 11 ++++++++++ .../macro-reify-typetag-hktypeparams-notags.check | 2 ++ .../Test.scala | 9 ++++++++ .../macro-reify-typetag-hktypeparams-tags.check | 2 ++ .../Test.scala | 9 ++++++++ test/pending/run/reify_addressbook.scala | 12 +++-------- test/pending/run/reify_brainf_ck.scala | 12 +++-------- test/pending/run/reify_callccinterpreter.scala | 12 +++-------- test/pending/run/reify_classfileann_b.check | 0 test/pending/run/reify_classfileann_b.scala | 24 --------------------- test/pending/run/reify_closure2b.scala | 9 ++------ test/pending/run/reify_closure3b.scala | 9 ++------ test/pending/run/reify_closure4b.scala | 9 ++------ test/pending/run/reify_closure5b.scala | 9 ++------ test/pending/run/reify_closure8b.check | 1 - test/pending/run/reify_closure8b.scala | 16 -------------- test/pending/run/reify_closure9a.scala | 11 +++------- test/pending/run/reify_closure9b.scala | 11 +++------- test/pending/run/reify_closures11.scala | 11 +++------- test/pending/run/reify_csv.scala | 12 +++-------- test/pending/run/reify_gadts.scala | 12 +++-------- test/pending/run/reify_lazyevaluation.scala | 12 +++-------- test/pending/run/reify_newimpl_07.scala | 13 +++++++++++ test/pending/run/reify_newimpl_08.scala | 15 +++++++++++++ test/pending/run/reify_newimpl_35.scala | 10 +++++++++ test/pending/run/reify_newimpl_46.scala | 12 +++++++++++ test/pending/run/reify_newimpl_53.scala | 15 +++++++++++++ test/pending/run/reify_properties.scala | 12 +++-------- test/pending/run/reify_simpleinterpreter.scala | 12 +++-------- test/pending/run/t5258a.check | 1 + test/pending/run/t5258a.scala | 5 +++++ test/pending/run/t5258b.scala | 12 ++--------- test/pending/run/t5258c.scala | 12 ++--------- test/pending/run/t5271_1.scala | 12 +++-------- test/pending/run/t5271_2.scala | 12 +++-------- test/pending/run/t5271_3.scala | 12 +++-------- test/pending/run/t5418.scala | 12 +++-------- 84 files changed, 410 insertions(+), 241 deletions(-) create mode 100644 test/pending/neg/reify_packed.check create mode 100644 test/pending/neg/reify_packed.scala create mode 100644 test/pending/run/macro-expand-default.flags create mode 100644 test/pending/run/macro-expand-default/Impls_1.scala create mode 100644 test/pending/run/macro-expand-default/Macros_Test_2.scala create mode 100644 test/pending/run/macro-expand-implicit-macro-has-context-bound.check create mode 100644 test/pending/run/macro-expand-implicit-macro-has-context-bound.flags create mode 100644 test/pending/run/macro-expand-implicit-macro-has-context-bound/Impls_1.scala create mode 100644 test/pending/run/macro-expand-implicit-macro-has-context-bound/Macros_Test_2.scala create mode 100644 test/pending/run/macro-expand-named.flags create mode 100644 test/pending/run/macro-expand-named/Impls_1.scala create mode 100644 test/pending/run/macro-expand-named/Macros_Test_2.scala create mode 100644 test/pending/run/macro-expand-tparams-prefix-e1.check create mode 100644 test/pending/run/macro-expand-tparams-prefix-e1.flags create mode 100644 test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala create mode 100644 test/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala create mode 100644 test/pending/run/macro-expand-tparams-prefix-f1.check create mode 100644 test/pending/run/macro-expand-tparams-prefix-f1.flags create mode 100644 test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala create mode 100644 test/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala delete mode 100644 test/pending/run/macro-overload.check delete mode 100644 test/pending/run/macro-overload.flags delete mode 100644 test/pending/run/macro-overload/Macros_1.scala delete mode 100644 test/pending/run/macro-overload/Test_2.scala create mode 100644 test/pending/run/macro-quasiinvalidbody-a.check create mode 100644 test/pending/run/macro-quasiinvalidbody-a.flags create mode 100644 test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala create mode 100644 test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala create mode 100644 test/pending/run/macro-quasiinvalidbody-b.check create mode 100644 test/pending/run/macro-quasiinvalidbody-b.flags create mode 100644 test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala create mode 100644 test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala create mode 100644 test/pending/run/macro-reify-array.flags create mode 100644 test/pending/run/macro-reify-array/Macros_1.scala create mode 100644 test/pending/run/macro-reify-array/Test_2.scala create mode 100644 test/pending/run/macro-reify-eval-vs-value.flags create mode 100644 test/pending/run/macro-reify-eval-vs-value/Macros_1.scala create mode 100644 test/pending/run/macro-reify-eval-vs-value/Test_2.scala create mode 100644 test/pending/run/macro-reify-groundtypetag-hktypeparams-tags.check create mode 100644 test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala create mode 100644 test/pending/run/macro-reify-tagful-b.check create mode 100644 test/pending/run/macro-reify-tagful-b.flags create mode 100644 test/pending/run/macro-reify-tagful-b/Macros_1.scala create mode 100644 test/pending/run/macro-reify-tagful-b/Test_2.scala create mode 100644 test/pending/run/macro-reify-tagless-b.check create mode 100644 test/pending/run/macro-reify-tagless-b.flags create mode 100644 test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala create mode 100644 test/pending/run/macro-reify-tagless-b/Test_2.scala create mode 100644 test/pending/run/macro-reify-typetag-hktypeparams-notags.check create mode 100644 test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala create mode 100644 test/pending/run/macro-reify-typetag-hktypeparams-tags.check create mode 100644 test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala delete mode 100644 test/pending/run/reify_classfileann_b.check delete mode 100644 test/pending/run/reify_classfileann_b.scala delete mode 100644 test/pending/run/reify_closure8b.check delete mode 100644 test/pending/run/reify_closure8b.scala create mode 100644 test/pending/run/reify_newimpl_07.scala create mode 100644 test/pending/run/reify_newimpl_08.scala create mode 100644 test/pending/run/reify_newimpl_35.scala create mode 100644 test/pending/run/reify_newimpl_46.scala create mode 100644 test/pending/run/reify_newimpl_53.scala create mode 100644 test/pending/run/t5258a.check create mode 100644 test/pending/run/t5258a.scala (limited to 'test/pending') diff --git a/test/pending/neg/reify_packed.check b/test/pending/neg/reify_packed.check new file mode 100644 index 0000000000..adba330d56 --- /dev/null +++ b/test/pending/neg/reify_packed.check @@ -0,0 +1,4 @@ +reify_packed.scala:6: error: implementation restriction: cannot reify block of type List[_$1] that involves a type declared inside the block being reified. consider casting the return value to a suitable type. + reify { + ^ +one error found diff --git a/test/pending/neg/reify_packed.scala b/test/pending/neg/reify_packed.scala new file mode 100644 index 0000000000..0240f2a4b5 --- /dev/null +++ b/test/pending/neg/reify_packed.scala @@ -0,0 +1,10 @@ +object Test extends App { + reify { + class C { override def toString() = "C" } + val ret = List((new C, new C)) + ret.asInstanceOf[List[_]] + }; + + val toolbox = mkToolBox() + println(toolbox.runExpr(code.tree)) +} diff --git a/test/pending/run/macro-expand-default.flags b/test/pending/run/macro-expand-default.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-expand-default.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-expand-default/Impls_1.scala b/test/pending/run/macro-expand-default/Impls_1.scala new file mode 100644 index 0000000000..fefe8fc4e2 --- /dev/null +++ b/test/pending/run/macro-expand-default/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/pending/run/macro-expand-default/Macros_Test_2.scala b/test/pending/run/macro-expand-default/Macros_Test_2.scala new file mode 100644 index 0000000000..92fe84d04a --- /dev/null +++ b/test/pending/run/macro-expand-default/Macros_Test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + def foo(x: Int = 2, y: Int = -40) = macro Impls.foo + foo(y = -40, x = 2) + foo(x = 2, y = -40) + foo(x = 100) + foo(y = 100) + foo() +} \ No newline at end of file diff --git a/test/pending/run/macro-expand-implicit-macro-has-context-bound.check b/test/pending/run/macro-expand-implicit-macro-has-context-bound.check new file mode 100644 index 0000000000..ac4213d6e9 --- /dev/null +++ b/test/pending/run/macro-expand-implicit-macro-has-context-bound.check @@ -0,0 +1 @@ +43 \ No newline at end of file diff --git a/test/pending/run/macro-expand-implicit-macro-has-context-bound.flags b/test/pending/run/macro-expand-implicit-macro-has-context-bound.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-expand-implicit-macro-has-context-bound.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-expand-implicit-macro-has-context-bound/Impls_1.scala b/test/pending/run/macro-expand-implicit-macro-has-context-bound/Impls_1.scala new file mode 100644 index 0000000000..5c50576281 --- /dev/null +++ b/test/pending/run/macro-expand-implicit-macro-has-context-bound/Impls_1.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[U](c: Ctx)(x: c.Expr[U])(evidence: c.Expr[Numeric[U]]) = { + import c.mirror._ + val plusOne = Apply(Select(evidence.tree, newTermName("plus")), List(x.tree, Literal(Constant(1)))) + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(plusOne)) + Expr[Unit](body) + } +} diff --git a/test/pending/run/macro-expand-implicit-macro-has-context-bound/Macros_Test_2.scala b/test/pending/run/macro-expand-implicit-macro-has-context-bound/Macros_Test_2.scala new file mode 100644 index 0000000000..7d16b773a6 --- /dev/null +++ b/test/pending/run/macro-expand-implicit-macro-has-context-bound/Macros_Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + def foo[U: Numeric](x: U) = macro Impls.foo[U] + foo(42) +} \ No newline at end of file diff --git a/test/pending/run/macro-expand-named.flags b/test/pending/run/macro-expand-named.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-expand-named.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-expand-named/Impls_1.scala b/test/pending/run/macro-expand-named/Impls_1.scala new file mode 100644 index 0000000000..fefe8fc4e2 --- /dev/null +++ b/test/pending/run/macro-expand-named/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/pending/run/macro-expand-named/Macros_Test_2.scala b/test/pending/run/macro-expand-named/Macros_Test_2.scala new file mode 100644 index 0000000000..abebcf8448 --- /dev/null +++ b/test/pending/run/macro-expand-named/Macros_Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + def foo(x: Int, y: Int) = macro Impls.foo + foo(y = -40, x = 2) + foo(x = 2, y = -40) +} \ No newline at end of file diff --git a/test/pending/run/macro-expand-tparams-prefix-e1.check b/test/pending/run/macro-expand-tparams-prefix-e1.check new file mode 100644 index 0000000000..4fa05a7678 --- /dev/null +++ b/test/pending/run/macro-expand-tparams-prefix-e1.check @@ -0,0 +1,3 @@ +TypeTag(List[Int]) +TypeTag(String) +TypeTag(Boolean) diff --git a/test/pending/run/macro-expand-tparams-prefix-e1.flags b/test/pending/run/macro-expand-tparams-prefix-e1.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-expand-tparams-prefix-e1.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Impls_1.scala new file mode 100644 index 0000000000..bc880fdf77 --- /dev/null +++ b/test/pending/run/macro-expand-tparams-prefix-e1/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/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala b/test/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala new file mode 100644 index 0000000000..5c863804d0 --- /dev/null +++ b/test/pending/run/macro-expand-tparams-prefix-e1/Macros_Test_2.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + class D[T: TypeTag] { + class C[U: TypeTag] { + def foo[V] = macro Impls.foo[List[T], U, V] + foo[Boolean] + } + } + + val outer1 = new D[Int] + new outer1.C[String] +} \ No newline at end of file diff --git a/test/pending/run/macro-expand-tparams-prefix-f1.check b/test/pending/run/macro-expand-tparams-prefix-f1.check new file mode 100644 index 0000000000..d15226143a --- /dev/null +++ b/test/pending/run/macro-expand-tparams-prefix-f1.check @@ -0,0 +1,3 @@ +TypeTag(List[T]) +TypeTag(U) +TypeTag(Boolean) diff --git a/test/pending/run/macro-expand-tparams-prefix-f1.flags b/test/pending/run/macro-expand-tparams-prefix-f1.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-expand-tparams-prefix-f1.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Impls_1.scala new file mode 100644 index 0000000000..bc880fdf77 --- /dev/null +++ b/test/pending/run/macro-expand-tparams-prefix-f1/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/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala b/test/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala new file mode 100644 index 0000000000..bc8e7ac75c --- /dev/null +++ b/test/pending/run/macro-expand-tparams-prefix-f1/Macros_Test_2.scala @@ -0,0 +1,13 @@ +import scala.reflect.mirror._ + +object Test extends App { + class D[T] { + class C[U] { + def foo[V] = macro Impls.foo[List[T], U, V] + foo[Boolean] + } + } + + val outer1 = new D[Int] + new outer1.C[String] +} \ No newline at end of file diff --git a/test/pending/run/macro-overload.check b/test/pending/run/macro-overload.check deleted file mode 100644 index 764f914e48..0000000000 --- a/test/pending/run/macro-overload.check +++ /dev/null @@ -1,4 +0,0 @@ -object-Int -object-String -class-Int -class-String \ No newline at end of file diff --git a/test/pending/run/macro-overload.flags b/test/pending/run/macro-overload.flags deleted file mode 100644 index 7fea2ff901..0000000000 --- a/test/pending/run/macro-overload.flags +++ /dev/null @@ -1 +0,0 @@ --Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-overload/Macros_1.scala b/test/pending/run/macro-overload/Macros_1.scala deleted file mode 100644 index f24c69ea7b..0000000000 --- a/test/pending/run/macro-overload/Macros_1.scala +++ /dev/null @@ -1,9 +0,0 @@ -object Macros { - def macro bar(x: Int): Int = Apply(Select(Select(Ident("scala"), newTermName("Predef")), newTermName("println")), List(Literal(Constant("object-Int")))) - def macro bar(x: String): String = Apply(Select(Select(Ident("scala"), newTermName("Predef")), newTermName("println")), List(Literal(Constant("object-String")))) -} - -class Macros { - def macro bar(x: Int): Int = Apply(Select(Select(Ident("scala"), newTermName("Predef")), newTermName("println")), List(Literal(Constant("class-Int")))) - def macro bar(x: String): String = Apply(Select(Select(Ident("scala"), newTermName("Predef")), newTermName("println")), List(Literal(Constant("class-String")))) -} \ No newline at end of file diff --git a/test/pending/run/macro-overload/Test_2.scala b/test/pending/run/macro-overload/Test_2.scala deleted file mode 100644 index 75f6572e03..0000000000 --- a/test/pending/run/macro-overload/Test_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test extends App { - Macros.bar(2) - Macros.bar("2") - new Macros.bar(2) - new Macros.bar("2") -} \ No newline at end of file diff --git a/test/pending/run/macro-quasiinvalidbody-a.check b/test/pending/run/macro-quasiinvalidbody-a.check new file mode 100644 index 0000000000..f70d7bba4a --- /dev/null +++ b/test/pending/run/macro-quasiinvalidbody-a.check @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/test/pending/run/macro-quasiinvalidbody-a.flags b/test/pending/run/macro-quasiinvalidbody-a.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-quasiinvalidbody-a.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala b/test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala new file mode 100644 index 0000000000..0da37cd5c0 --- /dev/null +++ b/test/pending/run/macro-quasiinvalidbody-a/Impls_1.scala @@ -0,0 +1,5 @@ +import scala.reflect.makro.{Context => Ctx} + +trait Impls { + def impl(c: Ctx)(x: c.Expr[Any]) = x +} \ No newline at end of file diff --git a/test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala b/test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala new file mode 100644 index 0000000000..04a43080bd --- /dev/null +++ b/test/pending/run/macro-quasiinvalidbody-a/Macros_Test_2.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros extends Impls { + def foo(x: Any) = macro impl +} + +object Test extends App { + import Macros._ + println(foo(42)) +} \ No newline at end of file diff --git a/test/pending/run/macro-quasiinvalidbody-b.check b/test/pending/run/macro-quasiinvalidbody-b.check new file mode 100644 index 0000000000..f70d7bba4a --- /dev/null +++ b/test/pending/run/macro-quasiinvalidbody-b.check @@ -0,0 +1 @@ +42 \ No newline at end of file diff --git a/test/pending/run/macro-quasiinvalidbody-b.flags b/test/pending/run/macro-quasiinvalidbody-b.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-quasiinvalidbody-b.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala b/test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala new file mode 100644 index 0000000000..d84d04974f --- /dev/null +++ b/test/pending/run/macro-quasiinvalidbody-b/Impls_1.scala @@ -0,0 +1,7 @@ +import scala.reflect.makro.{Context => Ctx} + +trait ImplContainer { + object Impls { + def foo(c: Ctx)(x: c.Expr[Any]) = x + } +} \ No newline at end of file diff --git a/test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala b/test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala new file mode 100644 index 0000000000..82f88b62e4 --- /dev/null +++ b/test/pending/run/macro-quasiinvalidbody-b/Macros_Test_2.scala @@ -0,0 +1,10 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros extends ImplContainer { + def foo(x: Any) = macro Impls.foo +} + +object Test extends App { + import Macros._ + println(foo(42)) +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-array.flags b/test/pending/run/macro-reify-array.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-reify-array.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-reify-array/Macros_1.scala b/test/pending/run/macro-reify-array/Macros_1.scala new file mode 100644 index 0000000000..af42321484 --- /dev/null +++ b/test/pending/run/macro-reify-array/Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def foo[T](s: String) = macro Impls.foo[T] + + object Impls { + def foo[T: c.TypeTag](c: Ctx)(s: c.Expr[T]) = c.reify { + Array(s.eval) + } + } +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-array/Test_2.scala b/test/pending/run/macro-reify-array/Test_2.scala new file mode 100644 index 0000000000..e40d5b40e0 --- /dev/null +++ b/test/pending/run/macro-reify-array/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val arr = Macros.foo("hello", "world") + println(arr.getClass) +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-eval-vs-value.flags b/test/pending/run/macro-reify-eval-vs-value.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-reify-eval-vs-value.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-reify-eval-vs-value/Macros_1.scala b/test/pending/run/macro-reify-eval-vs-value/Macros_1.scala new file mode 100644 index 0000000000..98dd93b0f8 --- /dev/null +++ b/test/pending/run/macro-reify-eval-vs-value/Macros_1.scala @@ -0,0 +1,25 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def fooEval(s: String) = macro Impls.fooEval + def fooValue(s: String) = macro Impls.fooValue + + object Impls { + def fooEval(c: Ctx)(s: c.Expr[String]) = c.reify { + println("hello " + s.eval) + println("hello " + s.eval) + } + + def fooValue(c: Ctx)(s: c.Expr[String]) = c.reify { + { + println("hello " + s.value) + def sayHello = println(s.value) + sayHello + } + println("hello " + s.eval); + { + println("hello " + s.eval) + } + } + } +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-eval-vs-value/Test_2.scala b/test/pending/run/macro-reify-eval-vs-value/Test_2.scala new file mode 100644 index 0000000000..8e62e6e0e7 --- /dev/null +++ b/test/pending/run/macro-reify-eval-vs-value/Test_2.scala @@ -0,0 +1,5 @@ +object Test extends App { + Macros.fooEval({ println("in ur logz"); "world"}) + println("======================") + Macros.fooValue({ println("i can has cheezburger?"); "world"}) +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags.check b/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags.check new file mode 100644 index 0000000000..7e4b000c52 --- /dev/null +++ b/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags.check @@ -0,0 +1,2 @@ +TypeTag(List[Int]) +TypeTag(List[List[Int]]) diff --git a/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala b/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala new file mode 100644 index 0000000000..4b264d83af --- /dev/null +++ b/test/pending/run/macro-reify-groundtypetag-hktypeparams-tags/Test.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test extends App { + def fooTypeTagHK[C[_]: GroundTypeTag, T: GroundTypeTag] = { + println(implicitly[GroundTypeTag[C[T]]]) + println(implicitly[GroundTypeTag[List[C[T]]]]) + } + fooTypeTagHK[List, Int] +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-tagful-b.check b/test/pending/run/macro-reify-tagful-b.check new file mode 100644 index 0000000000..5bd9fe2156 --- /dev/null +++ b/test/pending/run/macro-reify-tagful-b.check @@ -0,0 +1 @@ +List(List(hello world)) diff --git a/test/pending/run/macro-reify-tagful-b.flags b/test/pending/run/macro-reify-tagful-b.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-reify-tagful-b.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-reify-tagful-b/Macros_1.scala b/test/pending/run/macro-reify-tagful-b/Macros_1.scala new file mode 100644 index 0000000000..38b839330b --- /dev/null +++ b/test/pending/run/macro-reify-tagful-b/Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def foo[T](s: T) = macro Impls.foo[List[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/pending/run/macro-reify-tagful-b/Test_2.scala b/test/pending/run/macro-reify-tagful-b/Test_2.scala new file mode 100644 index 0000000000..142234901f --- /dev/null +++ b/test/pending/run/macro-reify-tagful-b/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val list: List[List[String]] = Macros.foo(List("hello world")) + println(list) +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-tagless-b.check b/test/pending/run/macro-reify-tagless-b.check new file mode 100644 index 0000000000..49acd94ad6 --- /dev/null +++ b/test/pending/run/macro-reify-tagless-b.check @@ -0,0 +1,3 @@ +error: macro must not return an expr that contains free type variables (namely: T). have you forgot to use c.TypeTag annotations for type parameters external to a reifee? + +java.lang.Error: reflective compilation has failed diff --git a/test/pending/run/macro-reify-tagless-b.flags b/test/pending/run/macro-reify-tagless-b.flags new file mode 100644 index 0000000000..7fea2ff901 --- /dev/null +++ b/test/pending/run/macro-reify-tagless-b.flags @@ -0,0 +1 @@ +-Xmacros \ No newline at end of file diff --git a/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala b/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala new file mode 100644 index 0000000000..fac7ba5b98 --- /dev/null +++ b/test/pending/run/macro-reify-tagless-b/Impls_Macros_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.makro.{Context => Ctx} + +object Macros { + def foo[T](s: T) = macro Impls.foo[List[T]] + + object Impls { + def foo[T](c: Ctx)(s: c.Expr[T]) = c.reify { + List(s.eval) + } + } +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-tagless-b/Test_2.scala b/test/pending/run/macro-reify-tagless-b/Test_2.scala new file mode 100644 index 0000000000..419ee42101 --- /dev/null +++ b/test/pending/run/macro-reify-tagless-b/Test_2.scala @@ -0,0 +1,11 @@ +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)))) + println(tree.eval) +} diff --git a/test/pending/run/macro-reify-typetag-hktypeparams-notags.check b/test/pending/run/macro-reify-typetag-hktypeparams-notags.check new file mode 100644 index 0000000000..db8a19d5f7 --- /dev/null +++ b/test/pending/run/macro-reify-typetag-hktypeparams-notags.check @@ -0,0 +1,2 @@ +TypeTag(C[T]) +TypeTag(List[C[T]]) diff --git a/test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala b/test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala new file mode 100644 index 0000000000..9a370189a7 --- /dev/null +++ b/test/pending/run/macro-reify-typetag-hktypeparams-notags/Test.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test extends App { + def fooNoTypeTagHK[C[_], T] = { + println(implicitly[TypeTag[C[T]]]) + println(implicitly[TypeTag[List[C[T]]]]) + } + fooNoTypeTagHK[List, Int] +} \ No newline at end of file diff --git a/test/pending/run/macro-reify-typetag-hktypeparams-tags.check b/test/pending/run/macro-reify-typetag-hktypeparams-tags.check new file mode 100644 index 0000000000..7e4b000c52 --- /dev/null +++ b/test/pending/run/macro-reify-typetag-hktypeparams-tags.check @@ -0,0 +1,2 @@ +TypeTag(List[Int]) +TypeTag(List[List[Int]]) diff --git a/test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala b/test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala new file mode 100644 index 0000000000..0358da9b0d --- /dev/null +++ b/test/pending/run/macro-reify-typetag-hktypeparams-tags/Test.scala @@ -0,0 +1,9 @@ +import scala.reflect.mirror._ + +object Test extends App { + def fooTypeTagHK[C[_]: TypeTag, T: TypeTag] = { + println(implicitly[TypeTag[C[T]]]) + println(implicitly[TypeTag[List[C[T]]]]) + } + fooTypeTagHK[List, Int] +} \ No newline at end of file diff --git a/test/pending/run/reify_addressbook.scala b/test/pending/run/reify_addressbook.scala index 54dd5545bd..7cb6dc08fd 100644 --- a/test/pending/run/reify_addressbook.scala +++ b/test/pending/run/reify_addressbook.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 { case class Person(name: String, age: Int) /** An AddressBook takes a variable number of arguments @@ -62,9 +60,5 @@ object Test extends App { ; println(page) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/reify_brainf_ck.scala b/test/pending/run/reify_brainf_ck.scala index 0034644b81..e4bcb257bd 100644 --- a/test/pending/run/reify_brainf_ck.scala +++ b/test/pending/run/reify_brainf_ck.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 { import scala.annotation._ trait Func[T] { @@ -76,9 +74,5 @@ object Test extends App { <.#>+++++++++++[<+++++>-]<.>++++++++[<++ +>-]<.+++.------.--------.[-]>++++++++[<++++> -]<+.[-]++++++++++.""") - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/reify_callccinterpreter.scala b/test/pending/run/reify_callccinterpreter.scala index 96ae9c5c17..0e23f75dcc 100644 --- a/test/pending/run/reify_callccinterpreter.scala +++ b/test/pending/run/reify_callccinterpreter.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 { type Answer = Value; /** @@ -85,9 +83,5 @@ object Test extends App { println(test(term0)) println(test(term1)) println(test(term2)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/reify_classfileann_b.check b/test/pending/run/reify_classfileann_b.check deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/test/pending/run/reify_classfileann_b.scala b/test/pending/run/reify_classfileann_b.scala deleted file mode 100644 index c31826377a..0000000000 --- a/test/pending/run/reify_classfileann_b.scala +++ /dev/null @@ -1,24 +0,0 @@ -import scala.reflect._ -import scala.reflect.api._ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - -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{ - 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 compile - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(tree) -} \ No newline at end of file diff --git a/test/pending/run/reify_closure2b.scala b/test/pending/run/reify_closure2b.scala index b9c0063290..f9ed16d309 100644 --- a/test/pending/run/reify_closure2b.scala +++ b/test/pending/run/reify_closure2b.scala @@ -1,17 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - object Test extends App { def foo(y: Int): Int => Int = { class Foo(y: Int) { - val fun = reflect.Code.lift{(x: Int) => { + val fun = reflect.mirror.reify{(x: Int) => { x + y }} } - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(new Foo(y).fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/pending/run/reify_closure3b.scala b/test/pending/run/reify_closure3b.scala index 8f161dbff3..8ef0a60c66 100644 --- a/test/pending/run/reify_closure3b.scala +++ b/test/pending/run/reify_closure3b.scala @@ -1,19 +1,14 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - object Test extends App { def foo(y: Int): Int => Int = { class Foo(y: Int) { def y1 = y - val fun = reflect.Code.lift{(x: Int) => { + val fun = reflect.mirror.reify{(x: Int) => { x + y1 }} } - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(new Foo(y).fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/pending/run/reify_closure4b.scala b/test/pending/run/reify_closure4b.scala index 238795d4dd..9eeb01b459 100644 --- a/test/pending/run/reify_closure4b.scala +++ b/test/pending/run/reify_closure4b.scala @@ -1,19 +1,14 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - object Test extends App { def foo(y: Int): Int => Int = { class Foo(y: Int) { val y1 = y - val fun = reflect.Code.lift{(x: Int) => { + val fun = reflect.mirror.reify{(x: Int) => { x + y1 }} } - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(new Foo(y).fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/pending/run/reify_closure5b.scala b/test/pending/run/reify_closure5b.scala index bdb2583e8a..51f1ec318d 100644 --- a/test/pending/run/reify_closure5b.scala +++ b/test/pending/run/reify_closure5b.scala @@ -1,17 +1,12 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - object Test extends App { def foo[T](ys: List[T]): Int => Int = { class Foo[T](ys: List[T]) { - val fun = reflect.Code.lift{(x: Int) => { + val fun = reflect.mirror.reify{(x: Int) => { x + ys.length }} } - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(new Foo(ys).fun.tree) dyn.asInstanceOf[Int => Int] } diff --git a/test/pending/run/reify_closure8b.check b/test/pending/run/reify_closure8b.check deleted file mode 100644 index 9a037142aa..0000000000 --- a/test/pending/run/reify_closure8b.check +++ /dev/null @@ -1 +0,0 @@ -10 \ No newline at end of file diff --git a/test/pending/run/reify_closure8b.scala b/test/pending/run/reify_closure8b.scala deleted file mode 100644 index 38031c217b..0000000000 --- a/test/pending/run/reify_closure8b.scala +++ /dev/null @@ -1,16 +0,0 @@ -import scala.reflect.Code._ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox - -object Test extends App { - class Foo(y: Int) { - def fun = lift{y} - } - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - val dyn = toolbox.runExpr(new Foo(10).fun.tree) - val foo = dyn.asInstanceOf[Int] - println(foo) -} diff --git a/test/pending/run/reify_closure9a.scala b/test/pending/run/reify_closure9a.scala index 185f4ffca1..1fc18cfa13 100644 --- a/test/pending/run/reify_closure9a.scala +++ b/test/pending/run/reify_closure9a.scala @@ -1,16 +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 { def foo(y: Int) = { 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(y).fun.tree) dyn.asInstanceOf[Int] } diff --git a/test/pending/run/reify_closure9b.scala b/test/pending/run/reify_closure9b.scala index ad279fac6d..32b05d00ee 100644 --- a/test/pending/run/reify_closure9b.scala +++ b/test/pending/run/reify_closure9b.scala @@ -1,16 +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 { def foo(y: Int) = { class Foo(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(y).fun.tree) dyn.asInstanceOf[Int] } diff --git a/test/pending/run/reify_closures11.scala b/test/pending/run/reify_closures11.scala index 2c4177b8f2..ceb224c6d6 100644 --- a/test/pending/run/reify_closures11.scala +++ b/test/pending/run/reify_closures11.scala @@ -1,16 +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 { def fun() = { def z() = 2 - lift{z} + reify{z} } - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) + val toolbox = mkToolBox() val dyn = toolbox.runExpr(fun().tree) val foo = dyn.asInstanceOf[Int] println(foo) diff --git a/test/pending/run/reify_csv.scala b/test/pending/run/reify_csv.scala index a6a616fab0..966521575c 100644 --- a/test/pending/run/reify_csv.scala +++ b/test/pending/run/reify_csv.scala @@ -1,6 +1,4 @@ -import scala.tools.nsc.reporters._ -import scala.tools.nsc.Settings -import reflect.runtime.Mirror.ToolBox +import scala.reflect.mirror._ object Test extends App { val csv = """ @@ -18,7 +16,7 @@ object Test extends App { val fields = csv.head.split(";").map{_.trim()}.toList println(fields) - val code = scala.reflect.Code.lift({ + reify({ object Csv { case class record(`phase name`: String, id: String, description: String) @@ -33,9 +31,5 @@ object Test extends App { } Csv.record.parse(csv) foreach println - }) - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }).eval } diff --git a/test/pending/run/reify_gadts.scala b/test/pending/run/reify_gadts.scala index 9feb7a5726..652a7d99d8 100644 --- a/test/pending/run/reify_gadts.scala +++ b/test/pending/run/reify_gadts.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 { /* The syntax tree of a toy language */ abstract class Term[T] @@ -36,9 +34,5 @@ object Test extends App { } println( eval(If(IsZero(Lit(1)), Lit(41), Succ(Lit(41))))) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/reify_lazyevaluation.scala b/test/pending/run/reify_lazyevaluation.scala index 0720a7c979..1a0c858914 100644 --- a/test/pending/run/reify_lazyevaluation.scala +++ b/test/pending/run/reify_lazyevaluation.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 lazyLib { /** Delay the evaluation of an expression until it is needed. */ @@ -56,9 +54,5 @@ object Test extends App { println("sl2 = " + sl2) println("sl2() = " + sl2()) println("sl2 = " + sl2) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/reify_newimpl_07.scala b/test/pending/run/reify_newimpl_07.scala new file mode 100644 index 0000000000..13ca6bda8b --- /dev/null +++ b/test/pending/run/reify_newimpl_07.scala @@ -0,0 +1,13 @@ +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/pending/run/reify_newimpl_08.scala b/test/pending/run/reify_newimpl_08.scala new file mode 100644 index 0000000000..e2faa3c9af --- /dev/null +++ b/test/pending/run/reify_newimpl_08.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + val code = reify { + class C(val y: Int) { + val code = reify { + reify{y}.eval + } + } + + new C(2).code.eval + } + + println(code.eval) +} \ No newline at end of file diff --git a/test/pending/run/reify_newimpl_35.scala b/test/pending/run/reify_newimpl_35.scala new file mode 100644 index 0000000000..5e1d163e9e --- /dev/null +++ b/test/pending/run/reify_newimpl_35.scala @@ -0,0 +1,10 @@ +import scala.tools.partest.ReplTest + +object Test extends ReplTest { + override def extraSettings = "-Xlog-free-types" + def code = """ +import scala.reflect.mirror._ +def foo[T: TypeTag] = reify{List[T]()} +println(foo) + """ +} diff --git a/test/pending/run/reify_newimpl_46.scala b/test/pending/run/reify_newimpl_46.scala new file mode 100644 index 0000000000..840d695e83 --- /dev/null +++ b/test/pending/run/reify_newimpl_46.scala @@ -0,0 +1,12 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C[T[_] >: Null] { + val code = reify{val x: T[String] = null; println("ima worx"); x} + println(freeTypes(code)) + val T = freeTypes(code)(0) + mkToolBox().runExpr(code, Map(T -> definitions.ListClass.asType)) + } + + new C[List] +} \ No newline at end of file diff --git a/test/pending/run/reify_newimpl_53.scala b/test/pending/run/reify_newimpl_53.scala new file mode 100644 index 0000000000..26645dea6a --- /dev/null +++ b/test/pending/run/reify_newimpl_53.scala @@ -0,0 +1,15 @@ +import scala.reflect.mirror._ + +object Test extends App { + class C[T >: Null] { + val code = reify{ + val tt = implicitly[TypeTag[T]] + println("mah typetag is: %s".format(tt)) + } + 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/pending/run/reify_properties.scala b/test/pending/run/reify_properties.scala index 265c344b8e..5cacc262ac 100644 --- a/test/pending/run/reify_properties.scala +++ b/test/pending/run/reify_properties.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 { /** A mutable property whose getter and setter may be customized. */ case class Property[T](init: T) { private var value: T = init @@ -54,9 +52,5 @@ object Test extends App { println("user1: " + user1) println("user2: " + user2) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/reify_simpleinterpreter.scala b/test/pending/run/reify_simpleinterpreter.scala index 4762afb3cc..2193edeea7 100644 --- a/test/pending/run/reify_simpleinterpreter.scala +++ b/test/pending/run/reify_simpleinterpreter.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 { case class M[A](value: A) { def bind[B](k: A => M[B]): M[B] = k(value) def map[B](f: A => B): M[B] = bind(x => unitM(f(x))) @@ -73,9 +71,5 @@ object Test extends App { println(test(term0)) println(test(term1)) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/t5258a.check b/test/pending/run/t5258a.check new file mode 100644 index 0000000000..4e0b2da04c --- /dev/null +++ b/test/pending/run/t5258a.check @@ -0,0 +1 @@ +int \ No newline at end of file diff --git a/test/pending/run/t5258a.scala b/test/pending/run/t5258a.scala new file mode 100644 index 0000000000..755d135468 --- /dev/null +++ b/test/pending/run/t5258a.scala @@ -0,0 +1,5 @@ +object Test extends App { + reify { + println(classOf[Int]) + }.eval +} \ No newline at end of file diff --git a/test/pending/run/t5258b.scala b/test/pending/run/t5258b.scala index 3a603095b3..8ad1ff114e 100644 --- a/test/pending/run/t5258b.scala +++ b/test/pending/run/t5258b.scala @@ -1,14 +1,6 @@ -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{ + reify { class C println(classOf[C]) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } \ No newline at end of file diff --git a/test/pending/run/t5258c.scala b/test/pending/run/t5258c.scala index b0d16ba0b1..1f76391162 100644 --- a/test/pending/run/t5258c.scala +++ b/test/pending/run/t5258c.scala @@ -1,14 +1,6 @@ -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{ + reify { object E extends Enumeration { val foo, bar = Value } println(E.foo) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } \ No newline at end of file diff --git a/test/pending/run/t5271_1.scala b/test/pending/run/t5271_1.scala index afbd8fe465..fae64350e3 100644 --- a/test/pending/run/t5271_1.scala +++ b/test/pending/run/t5271_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 { case class C(foo: Int, bar: Int) - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/t5271_2.scala b/test/pending/run/t5271_2.scala index d85d945973..d25e1fe804 100644 --- a/test/pending/run/t5271_2.scala +++ b/test/pending/run/t5271_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 { 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) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/t5271_3.scala b/test/pending/run/t5271_3.scala index 5a624de903..65a03ae323 100644 --- a/test/pending/run/t5271_3.scala +++ b/test/pending/run/t5271_3.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 { 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) - toolbox.runExpr(code.tree) + }.eval } diff --git a/test/pending/run/t5418.scala b/test/pending/run/t5418.scala index fe813cf5ae..9b0a954e47 100644 --- a/test/pending/run/t5418.scala +++ b/test/pending/run/t5418.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 { new Object().getClass - }; - - val reporter = new ConsoleReporter(new Settings) - val toolbox = new ToolBox(reporter) - toolbox.runExpr(code.tree) + }.eval } \ No newline at end of file -- cgit v1.2.3