summaryrefslogtreecommitdiff
path: root/test/files/run/t7817-tree-gen.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-09-06 16:26:16 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-09-09 23:32:24 +0200
commit292134a4ab5a10052046a722c0b3192b3bfabae7 (patch)
treeaa205b8921b7ae0a228b2c79c45043f38ca5b952 /test/files/run/t7817-tree-gen.scala
parentce98bb437b0f2743c08a654df4110f940458af54 (diff)
downloadscala-292134a4ab5a10052046a722c0b3192b3bfabae7.tar.gz
scala-292134a4ab5a10052046a722c0b3192b3bfabae7.tar.bz2
scala-292134a4ab5a10052046a722c0b3192b3bfabae7.zip
SI-7817 Tests to show the foibles of mkAttributedRef
To `package`, or not `package`, that is the question. This lines marked with !!! get this wrong, and be remedied by the next commit. This problem is culpable for the crash in the enclosed `pending` test.
Diffstat (limited to 'test/files/run/t7817-tree-gen.scala')
-rw-r--r--test/files/run/t7817-tree-gen.scala65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/files/run/t7817-tree-gen.scala b/test/files/run/t7817-tree-gen.scala
new file mode 100644
index 0000000000..a8317fda6e
--- /dev/null
+++ b/test/files/run/t7817-tree-gen.scala
@@ -0,0 +1,65 @@
+import scala.tools.partest._
+
+// Testing that `mkAttributedRef` doesn't incude the package object test.`package`,
+// under joint and separate compilation.
+
+package testSep { class C { object O } }
+package testSep2 { object `package` { object PO; def bar = 0 } }
+class DSep { object P }
+
+object Test extends CompilerTest {
+ import global._
+ override def extraSettings = super.extraSettings + " -d " + testOutput.path
+ override def sources = List(
+ """
+ package test { class C { object O } }
+ class D { object P }
+ package test2 { object `package` { object PO; def bar = 0 } }
+ """
+ )
+ def check(source: String, unit: CompilationUnit) = enteringTyper {
+ def checkTree(msg: String, t: => Tree) = {
+ val run = currentRun
+ import run._
+ val phases = List(typerPhase, picklerPhase, refchecksPhase, uncurryPhase, specializePhase,
+ explicitouterPhase, erasurePhase, posterasurePhase, flattenPhase, mixinPhase, cleanupPhase)
+ for (phase <- phases) {
+ enteringPhase(phase) {
+ val error = t.exists(t => t.symbol == NoSymbol)
+ val errorStr = if (error) "!!!" else " - "
+ println(f"$phase%18s [$msg%12s] $errorStr $t")
+ }
+ }
+ println("")
+ }
+ import rootMirror._
+
+ println("\n\nJoint Compilation:\n")
+
+ {
+ val c = staticClass("test.C")
+ val o = c.info.decl(TermName("O"))
+ checkTree("O", gen.mkAttributedQualifier(o.moduleClass.thisType))
+ val d = staticClass("D")
+ val p = d.info.decl(TermName("P"))
+ checkTree("P", gen.mkAttributedQualifier(p.moduleClass.thisType))
+ val po = staticModule("test2.package").moduleClass.info.decl(TermName("PO"))
+ checkTree("test2.PO", gen.mkAttributedQualifier(po.moduleClass.thisType))
+ checkTree("test2.bar", gen.mkAttributedRef(po.owner.info.decl(TermName("bar"))))
+ }
+
+ println("\n\nSeparate Compilation:\n")
+
+ {
+ val c = typeOf[testSep.C].typeSymbol
+ val o = c.info.decl(TermName("O"))
+ checkTree("O", gen.mkAttributedQualifier(o.moduleClass.thisType))
+ val d = staticClass("DSep")
+ val p = d.info.decl(TermName("P"))
+ checkTree("P", gen.mkAttributedQualifier(p.moduleClass.thisType))
+ val po = staticModule("test2.package").moduleClass.info.decl(TermName("PO"))
+ checkTree("PO", gen.mkAttributedQualifier(po.moduleClass.thisType))
+ checkTree("testSep2.bar", gen.mkAttributedRef(po.owner.info.decl(TermName("bar"))))
+ }
+ }
+}