diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-05-12 18:30:53 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-05-12 18:30:53 +0200 |
commit | 89bacb9c25a58454ff1878e67f7ea07ffc8c269f (patch) | |
tree | 51f1ff6c66aebe1b6109b1cffcc2bb8e4cf760a3 /tests/pending/run/t7817-tree-gen.scala | |
parent | a0fa33deafbea1bf53edc068c5ed9db5592822f9 (diff) | |
download | dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.tar.gz dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.tar.bz2 dotty-89bacb9c25a58454ff1878e67f7ea07ffc8c269f.zip |
Run tests as they were in scala.
Diffstat (limited to 'tests/pending/run/t7817-tree-gen.scala')
-rw-r--r-- | tests/pending/run/t7817-tree-gen.scala | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/pending/run/t7817-tree-gen.scala b/tests/pending/run/t7817-tree-gen.scala new file mode 100644 index 000000000..a8317fda6 --- /dev/null +++ b/tests/pending/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")))) + } + } +} |