aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-06-02 11:06:07 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-06-02 11:13:55 +0200
commit4afa3ffe68f450c1f47018892489a0f2a9b4b9b5 (patch)
treeb8648b8bfe2475e72338d57a53164b49eb93725e /src
parentf0787353e407a01a4b0a5f814c3d0feeff7cd87e (diff)
downloaddotty-4afa3ffe68f450c1f47018892489a0f2a9b4b9b5.tar.gz
dotty-4afa3ffe68f450c1f47018892489a0f2a9b4b9b5.tar.bz2
dotty-4afa3ffe68f450c1f47018892489a0f2a9b4b9b5.zip
Revert "Fix ElimStaticThis#transformIdent"
This reverts commit 3d240ad40ccfb570174ec9758bfe68ba4e91eefb. This commit got in without succeding the review. It broke what already was working(inner static objects), and made impossible moving static methods from companion object to companion class. Additionally, commenting or removing assertions is not the way to go, and should not pass review. See discussion here: https://github.com/dotty-staging/dotty/commit/3d240ad40ccfb570174ec9758bfe68ba4e91eefb
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/Compiler.scala2
-rw-r--r--src/dotty/tools/dotc/transform/ElimStaticThis.scala11
2 files changed, 4 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index 41e77c61f..d7ef44144 100644
--- a/src/dotty/tools/dotc/Compiler.scala
+++ b/src/dotty/tools/dotc/Compiler.scala
@@ -67,8 +67,8 @@ class Compiler {
new Constructors,
new FunctionalInterfaces),
List(new LambdaLift, // in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here
- new Flatten,
new ElimStaticThis,
+ new Flatten,
new RestoreScopes),
List(/*new PrivateToStatic,*/
new ExpandPrivate,
diff --git a/src/dotty/tools/dotc/transform/ElimStaticThis.scala b/src/dotty/tools/dotc/transform/ElimStaticThis.scala
index c60990477..7df29b0b0 100644
--- a/src/dotty/tools/dotc/transform/ElimStaticThis.scala
+++ b/src/dotty/tools/dotc/transform/ElimStaticThis.scala
@@ -9,7 +9,6 @@ import dotty.tools.dotc.core.StdNames._
import dotty.tools.dotc.core.SymDenotations.SymDenotation
import TreeTransforms.{MiniPhaseTransform, TransformerInfo}
import dotty.tools.dotc.core.Types.{ThisType, TermRef}
-import Phases.Phase
/** Replace This references to module classes in static methods by global identifiers to the
* corresponding modules.
@@ -18,8 +17,6 @@ class ElimStaticThis extends MiniPhaseTransform {
import ast.tpd._
def phaseName: String = "elimStaticThis"
- override def runsAfter: Set[Class[_ <: Phase]] = Set(classOf[Flatten])
-
override def transformThis(tree: This)(implicit ctx: Context, info: TransformerInfo): Tree =
if (!tree.symbol.is(Package) && ctx.owner.enclosingMethod.is(JavaStatic)) {
assert(tree.symbol.is(ModuleClass))
@@ -28,12 +25,10 @@ class ElimStaticThis extends MiniPhaseTransform {
else tree
override def transformIdent(tree: tpd.Ident)(implicit ctx: Context, info: TransformerInfo): tpd.Tree = {
- val meth = ctx.owner.enclosingMethod
- // We cannot use meth.enclosingClass because it skips other static classes,
- // so instead we require this phase to run after Flatten and use meth.owner
- if (meth.is(JavaStatic) && meth.owner.is(ModuleClass)) {
+ if (ctx.owner.enclosingMethod.is(JavaStatic)) {
tree.tpe match {
- case TermRef(thiz: ThisType, _) if (thiz.underlying.typeSymbol == meth.owner) =>
+ case TermRef(thiz: ThisType, _) =>
+ assert(thiz.underlying.typeSymbol.is(ModuleClass))
ref(thiz.underlying.typeSymbol.sourceModule).select(tree.symbol)
case _ => tree
}