1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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"))))
}
}
}
|