From bec459a554d978f19dc0b40289d9179dbc28de78 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 18 Jun 2012 14:11:00 +0200 Subject: enables reification of anonymous classes --- src/compiler/scala/reflect/reify/Errors.scala | 5 ----- src/compiler/scala/reflect/reify/Reifier.scala | 14 -------------- test/files/neg/t5334_1.check | 4 ---- test/files/neg/t5334_1.scala | 9 --------- test/files/neg/t5334_2.check | 4 ---- test/files/neg/t5334_2.scala | 9 --------- test/pending/run/t5334_1.scala | 9 +++++++++ test/pending/run/t5334_2.scala | 9 +++++++++ 8 files changed, 18 insertions(+), 45 deletions(-) delete mode 100644 test/files/neg/t5334_1.check delete mode 100644 test/files/neg/t5334_1.scala delete mode 100644 test/files/neg/t5334_2.check delete mode 100644 test/files/neg/t5334_2.scala create mode 100644 test/pending/run/t5334_1.scala create mode 100644 test/pending/run/t5334_2.scala diff --git a/src/compiler/scala/reflect/reify/Errors.scala b/src/compiler/scala/reflect/reify/Errors.scala index 714795503b..1b72b3075b 100644 --- a/src/compiler/scala/reflect/reify/Errors.scala +++ b/src/compiler/scala/reflect/reify/Errors.scala @@ -17,11 +17,6 @@ trait Errors { // expected errors: these can happen if the user casually writes whatever.reify(...) // hence we don't crash here, but nicely report a typechecking error and bail out asap - def CannotReifyReifeeThatHasTypeLocalToReifee(tree: Tree) = { - val msg = "implementation restriction: cannot reify block of type %s that involves a type declared inside the block being reified. consider casting the return value to a suitable type".format(tree.tpe) - throw new ReificationError(tree.pos, msg) - } - def CannotReifyType(tpe: Type) = { val msg = "implementation restriction: cannot reify type %s (%s)".format(tpe, tpe.kind) throw new ReificationError(defaultErrorPosition, msg) diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala index 00f25f0d8b..8fba7274be 100644 --- a/src/compiler/scala/reflect/reify/Reifier.scala +++ b/src/compiler/scala/reflect/reify/Reifier.scala @@ -68,20 +68,6 @@ abstract class Reifier extends States val pipeline = mkReificationPipeline val rtree = pipeline(tree) - // consider the following code snippet - // - // val x = reify { class C; new C } - // - // inferred type for x will be C - // but C ceases to exist after reification so this type is clearly incorrect - // however, reify is "just" a library function, so it cannot affect type inference - // - // hence we crash here even though the reification itself goes well - // fortunately, all that it takes to fix the error is to cast "new C" to Object - // so I'm not very much worried about introducing this restriction - if (tree.tpe exists (sub => sub.typeSymbol.isLocalToReifee)) - CannotReifyReifeeThatHasTypeLocalToReifee(tree) - val tpe = typer.packedType(tree, NoSymbol) val ReifiedType(_, _, tpeSymtab, _, rtpe, tpeReificationIsConcrete) = `package`.reifyType(global)(typer, universe, mirror, tpe, concrete = false) state.reificationIsConcrete &= tpeReificationIsConcrete diff --git a/test/files/neg/t5334_1.check b/test/files/neg/t5334_1.check deleted file mode 100644 index eca854964a..0000000000 --- a/test/files/neg/t5334_1.check +++ /dev/null @@ -1,4 +0,0 @@ -t5334_1.scala:5: error: implementation restriction: cannot reify block of type C 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/files/neg/t5334_1.scala b/test/files/neg/t5334_1.scala deleted file mode 100644 index b75badb145..0000000000 --- a/test/files/neg/t5334_1.scala +++ /dev/null @@ -1,9 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.tools.reflect.Eval - -object Test extends App { - reify { - class C { override def toString = "C" } - new C - }.eval -} \ No newline at end of file diff --git a/test/files/neg/t5334_2.check b/test/files/neg/t5334_2.check deleted file mode 100644 index e21f0d5967..0000000000 --- a/test/files/neg/t5334_2.check +++ /dev/null @@ -1,4 +0,0 @@ -t5334_2.scala:5: error: implementation restriction: cannot reify block of type List[(C, C)] 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/files/neg/t5334_2.scala b/test/files/neg/t5334_2.scala deleted file mode 100644 index e082e3b8e3..0000000000 --- a/test/files/neg/t5334_2.scala +++ /dev/null @@ -1,9 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.tools.reflect.Eval - -object Test extends App { - reify { - class C { override def toString() = "C" } - List((new C, new C)) - }.eval -} \ No newline at end of file diff --git a/test/pending/run/t5334_1.scala b/test/pending/run/t5334_1.scala new file mode 100644 index 0000000000..b75badb145 --- /dev/null +++ b/test/pending/run/t5334_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + class C { override def toString = "C" } + new C + }.eval +} \ No newline at end of file diff --git a/test/pending/run/t5334_2.scala b/test/pending/run/t5334_2.scala new file mode 100644 index 0000000000..e082e3b8e3 --- /dev/null +++ b/test/pending/run/t5334_2.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ +import scala.tools.reflect.Eval + +object Test extends App { + reify { + class C { override def toString() = "C" } + List((new C, new C)) + }.eval +} \ No newline at end of file -- cgit v1.2.3