diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-12-15 14:22:14 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-01-26 15:41:07 +0100 |
commit | f21b1ce7fda9022d6d805a708882c5a2ab241f41 (patch) | |
tree | 8b8de4a28a0dcc6e4118e2986708074c55a42055 /src/compiler/scala/tools/nsc/transform/Flatten.scala | |
parent | eb4b06544a4362231357686c39beef9dbe00d932 (diff) | |
download | scala-f21b1ce7fda9022d6d805a708882c5a2ab241f41.tar.gz scala-f21b1ce7fda9022d6d805a708882c5a2ab241f41.tar.bz2 scala-f21b1ce7fda9022d6d805a708882c5a2ab241f41.zip |
SI-4859 Don't elide qualifiers when selecting nested modules.
Otherwise we fail to throw in:
{???; Predef}.DummyImplicit.dummyImplicit
We still elide the initialization of `Outer` in `Outer.Inner.foo`
as before, although that seems a little dubious to me.
In total, we had to change RefChecks, Flatten, and GenICode
to effect this change. A recently fixed bug in tail call elimination
was also due to assuming that the the qualifier of a Select node
wasn't worthy of traversal. Let's keep a close eye out for more
instances of this problem.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/Flatten.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/Flatten.scala | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Flatten.scala b/src/compiler/scala/tools/nsc/transform/Flatten.scala index 7fe3a5da5c..85516f1995 100644 --- a/src/compiler/scala/tools/nsc/transform/Flatten.scala +++ b/src/compiler/scala/tools/nsc/transform/Flatten.scala @@ -12,6 +12,7 @@ import scala.collection.mutable.ListBuffer abstract class Flatten extends InfoTransform { import global._ + import treeInfo.isExprSafeToInline /** the following two members override abstract members in Transform */ val phaseName: String = "flatten" @@ -117,7 +118,13 @@ abstract class Flatten extends InfoTransform { liftedDefs(sym.enclosingTopLevelClass.owner) += tree EmptyTree case Select(qual, name) if sym.isStaticModule && !sym.isTopLevel => - exitingFlatten(atPos(tree.pos)(gen.mkAttributedRef(sym))) + exitingFlatten { + atPos(tree.pos) { + val ref = gen.mkAttributedRef(sym) + if (isExprSafeToInline(qual)) ref + else Block(List(qual), ref).setType(tree.tpe) // need to execute the qualifier but refer directly to the lifted module. + } + } case _ => tree } |