From e2a17d9c8234bf620ba0109f9ab4bae822c20bf0 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 16 Feb 2013 23:42:09 +0100 Subject: resetAttrs now always erases This.tpe The symbol of This, if it points to a package class, isn't touched, just as usual, so that our Select(Select(Select(...))) => This(...) optimization works fine with attr reset. However the tpe is now erased, so that subsequent reflective compilation doesn't spuriously fail when seeing that some subtrees of a tree being compiled are typed. Erasing the tpe doesn't pose even a tiniest problem, because, as it can be seen in typedThis, type is trivially reconstructed from the symbol. --- test/files/run/resetattrs-this.check | 1 + test/files/run/resetattrs-this.scala | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/files/run/resetattrs-this.check create mode 100644 test/files/run/resetattrs-this.scala (limited to 'test') diff --git a/test/files/run/resetattrs-this.check b/test/files/run/resetattrs-this.check new file mode 100644 index 0000000000..27ba77ddaf --- /dev/null +++ b/test/files/run/resetattrs-this.check @@ -0,0 +1 @@ +true diff --git a/test/files/run/resetattrs-this.scala b/test/files/run/resetattrs-this.scala new file mode 100644 index 0000000000..12afa3d712 --- /dev/null +++ b/test/files/run/resetattrs-this.scala @@ -0,0 +1,11 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.ToolBox + +object Test extends App { + val tb = cm.mkToolBox() + val tree = Select(This(cm.staticPackage("scala").moduleClass), newTermName("Predef")) + val ttree = tb.typeCheck(tree) + val rttree = tb.resetAllAttrs(ttree) + println(tb.eval(rttree) == Predef) +} \ No newline at end of file -- cgit v1.2.3