diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-16 12:27:16 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-16 12:27:16 -0700 |
commit | 0a0c8aef93adcfaae75c0c056c360fa9d4ffb50c (patch) | |
tree | 0792b3760185bc8e36ae2c8578fde1e6939ea4b0 /test | |
parent | 71ddc4f78623ee70798b5ab409bfd72648f92568 (diff) | |
parent | 4a273659e0e25ccfe7ea9d4eafa4a9c87ee2fc82 (diff) | |
download | scala-0a0c8aef93adcfaae75c0c056c360fa9d4ffb50c.tar.gz scala-0a0c8aef93adcfaae75c0c056c360fa9d4ffb50c.tar.bz2 scala-0a0c8aef93adcfaae75c0c056c360fa9d4ffb50c.zip |
Merge pull request #2843 from xeno-by/topic/kill-introduce-top-level
kills introduceTopLevel
Diffstat (limited to 'test')
18 files changed, 0 insertions, 180 deletions
diff --git a/test/files/run/macro-expand-unapply-b.check b/test/files/run/macro-expand-unapply-b.check deleted file mode 100644 index 5272f0d00a..0000000000 --- a/test/files/run/macro-expand-unapply-b.check +++ /dev/null @@ -1,2 +0,0 @@ -(1,List(2)) -List(1) diff --git a/test/files/run/macro-expand-unapply-b.flags b/test/files/run/macro-expand-unapply-b.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-expand-unapply-b.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala b/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala deleted file mode 100644 index d0300bdf7e..0000000000 --- a/test/files/run/macro-expand-unapply-b/Impls_Macros_1.scala +++ /dev/null @@ -1,37 +0,0 @@ -import language.experimental.macros -import scala.reflect.macros.Context - -object Macros { - implicit class ContextExtensions(c: StringContext) { - object q { - def unapply(x: Any): Option[Any] = macro impl - } - } - - def impl(c: Context)(x: c.Expr[Any]): c.Expr[Option[Any]] = { - import c.universe._ - import Flag._ - - // parts here will be string literals - static parts of the string interpolation - // e.g. for q"$x, $y" parts will be Literal(Constant("")), Literal(Constant(", ")) and Literal(Constant("")) - val Apply(Select(Select(Apply(_, List(Apply(_, parts))), _), _), _) = c.macroApplication - val nresults = parts.length - 1 - - def results() = - ((1 to (nresults - 1)).toList map (i => Literal(Constant(i)))) :+ // (n - 1) results of type Int - Apply(Ident(TermName("List")), List(Literal(Constant(nresults)))) // and also one result of a different type - def extractorBody() = - if (nresults == 0) Literal(Constant(true)) - else if (nresults == 1) Apply(Ident(TermName("Some")), results()) - else Apply(Ident(TermName("Some")), List(Apply(Ident(TermName("Tuple" + nresults)), results()))) - - val name = TermName(java.util.UUID.randomUUID().toString.replace("-", "")) - val mdef = ModuleDef(NoMods, name, Template(List(Select(Ident(TermName("scala")), TypeName("AnyRef"))), emptyValDef, List( - DefDef(Modifiers(), nme.CONSTRUCTOR, List(), List(List()), TypeTree(), - Block(List(pendingSuperCall), Literal(Constant(())))), - DefDef(Modifiers(), TermName("unapply"), List(), List(List(ValDef(Modifiers(PARAM), TermName("x"), Ident(TypeName("Any")), EmptyTree))), TypeTree(), - extractorBody())))) - c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef) - c.Expr[Option[Any]](Apply(Select(Ident(name), TermName("unapply")), List(x.tree))) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-expand-unapply-b/Test_2.scala b/test/files/run/macro-expand-unapply-b/Test_2.scala deleted file mode 100644 index 5352160dfe..0000000000 --- a/test/files/run/macro-expand-unapply-b/Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -object Test extends App { - import Macros._ - def whatever() = null - val q"$x1, $y1" = whatever() - println(x1, y1) - val q"$x2" = whatever() - println(x2) -} diff --git a/test/files/run/macro-toplevel-companion-a.check b/test/files/run/macro-toplevel-companion-a.check deleted file mode 100644 index e69de29bb2..0000000000 --- a/test/files/run/macro-toplevel-companion-a.check +++ /dev/null diff --git a/test/files/run/macro-toplevel-companion-a.flags b/test/files/run/macro-toplevel-companion-a.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-toplevel-companion-a.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala deleted file mode 100644 index 23e8694ddc..0000000000 --- a/test/files/run/macro-toplevel-companion-a/Impls_Macros_1.scala +++ /dev/null @@ -1,14 +0,0 @@ -import scala.reflect.macros.Context -import language.experimental.macros - -object Macros { - def impl(c: Context) = { - import c.universe._ - val synthetic = reify{ class C { override def toString = "C" }; object C { implicit val c = new C } }.tree - val defs = synthetic.asInstanceOf[Block].stats.asInstanceOf[List[ImplDef]] - if (c.topLevelRef(TypeName("C")).isEmpty) c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, defs: _*) - c.literalUnit - } - - def foo = macro impl -}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-a/Test_2.scala b/test/files/run/macro-toplevel-companion-a/Test_2.scala deleted file mode 100644 index 78b65b5b1f..0000000000 --- a/test/files/run/macro-toplevel-companion-a/Test_2.scala +++ /dev/null @@ -1,8 +0,0 @@ -import Macros._ - -object Test extends App { - foo; - implicitly[C]; - foo; - implicitly[C]; -}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-b.check b/test/files/run/macro-toplevel-companion-b.check deleted file mode 100644 index bd30dc75d3..0000000000 --- a/test/files/run/macro-toplevel-companion-b.check +++ /dev/null @@ -1,4 +0,0 @@ -reflective compilation has failed: - -Companions 'class C' and 'object C' must be defined in same file: - Found in <synthetic file name> and <synthetic file name> diff --git a/test/files/run/macro-toplevel-companion-b.flags b/test/files/run/macro-toplevel-companion-b.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-toplevel-companion-b.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala b/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala deleted file mode 100644 index f30adc2965..0000000000 --- a/test/files/run/macro-toplevel-companion-b/Impls_Macros_1.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.reflect.macros.Context -import language.experimental.macros - -object Macros { - def impl(c: Context) = { - import c.universe._ - val Block(List(cdef: ClassDef), _) = reify{ class C }.tree - val classRef = c.topLevelRef(TypeName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, cdef) - val Block(List(mdef: ModuleDef), _) = reify{ object C }.tree - val moduleRef = c.topLevelRef(TermName("C")) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, mdef) - c.literalUnit - } - - def foo = macro impl -}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-b/Test_2.scala b/test/files/run/macro-toplevel-companion-b/Test_2.scala deleted file mode 100644 index 4e766bde89..0000000000 --- a/test/files/run/macro-toplevel-companion-b/Test_2.scala +++ /dev/null @@ -1,11 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.runtime.{universe => ru} -import scala.reflect.runtime.{currentMirror => cm} -import scala.tools.reflect.{ToolBox, ToolBoxError} -import Macros._ - -object Test extends App { - val tb = cm.mkToolBox() - try tb.compile(Select(Ident(TermName("Macros")), TermName("foo"))) - catch { case ToolBoxError(message, _) => println("""(Found in|and) .*?compileLateSynthetic-.*?\.scala""".r.replaceAllIn(message, m => m.group(1) + " <synthetic file name>")) } -}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-c.check b/test/files/run/macro-toplevel-companion-c.check deleted file mode 100644 index 4052c472f8..0000000000 --- a/test/files/run/macro-toplevel-companion-c.check +++ /dev/null @@ -1,3 +0,0 @@ -error: Companions 'class C' and 'object C' must be defined in same file: - Found in <synthetic file name> and newSource1.scala - diff --git a/test/files/run/macro-toplevel-companion-c.flags b/test/files/run/macro-toplevel-companion-c.flags deleted file mode 100644 index cd66464f2f..0000000000 --- a/test/files/run/macro-toplevel-companion-c.flags +++ /dev/null @@ -1 +0,0 @@ --language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-toplevel-companion-c.scala b/test/files/run/macro-toplevel-companion-c.scala deleted file mode 100644 index c315f8b942..0000000000 --- a/test/files/run/macro-toplevel-companion-c.scala +++ /dev/null @@ -1,51 +0,0 @@ -import scala.tools.partest._ -import java.io._ - -object Test extends DirectTest { - def code = ??? - - def macros_1 = """ - package test - - import scala.reflect.macros.Context - import language.experimental.macros - - object Macros { - def impl(c: Context) = { - import c.universe._ - val Block(List(cdef: ClassDef), _) = reify{ class C }.tree - val ref = c.topLevelRef(TypeName("test.C")) orElse c.introduceTopLevel("test", cdef) - c.literalUnit - } - - def foo = macro impl - } - """ - def compileMacros() = { - val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect")) mkString sys.props("path.separator") - compileString(newCompiler("-language:experimental.macros", "-cp", classpath, "-d", testOutput.path))(macros_1) - } - - def test_2 = """ - package test - object C { Macros.foo } - """ - def compileTest() = { - val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") - compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(test_2) - } - - def show(): Unit = { - // redirect err to string, for logging - val prevErr = System.err - val baos = new ByteArrayOutputStream() - System.setErr(new PrintStream(baos)) - log("Compiling Macros_1...") - if (compileMacros()) { - log("Compiling Test_2...") - if (compileTest()) log("Success!") else log("Failed...") - } - println("""(Found in|and) .*?compileLateSynthetic-.*?\.scala""".r.replaceAllIn(baos.toString, m => m.group(1) + " <synthetic file name>")) - System.setErr(prevErr) - } -}
\ No newline at end of file diff --git a/test/files/run/macro-toplevel.check b/test/files/run/macro-toplevel.check deleted file mode 100644 index 257c3764fd..0000000000 --- a/test/files/run/macro-toplevel.check +++ /dev/null @@ -1,2 +0,0 @@ -I've been created from Macros.foo -I've been created from Macros.foo diff --git a/test/files/run/macro-toplevel/Macros_1.scala b/test/files/run/macro-toplevel/Macros_1.scala deleted file mode 100644 index f681c86735..0000000000 --- a/test/files/run/macro-toplevel/Macros_1.scala +++ /dev/null @@ -1,15 +0,0 @@ -import scala.reflect.macros.Context -import language.experimental.macros - -object Macros { - def impl(c: Context) = { - import c.universe._ - val msg = "I've been created from " + c.macroApplication - val Block(List(synthetic: ClassDef), _) = reify{ class SomeUniqueName { def hello = c.literal(msg).splice } }.tree - val ref = c.topLevelRef(synthetic.name) orElse c.introduceTopLevel(nme.EMPTY_PACKAGE_NAME.toString, synthetic) - c.Expr[String](Select(Apply(Select(New(ref), nme.CONSTRUCTOR), List()), TermName("hello"))) - } - - def foo = macro impl - def foo2 = macro impl -} diff --git a/test/files/run/macro-toplevel/Test_2.scala b/test/files/run/macro-toplevel/Test_2.scala deleted file mode 100644 index eee2d6ae13..0000000000 --- a/test/files/run/macro-toplevel/Test_2.scala +++ /dev/null @@ -1,6 +0,0 @@ -import Macros._ - -object Test extends App { - println(Macros.foo) - println(Macros.foo2) -}
\ No newline at end of file |