Skip to content

Commit 863e4cb

Browse files
committed
Move Flatten and RestoreScopes to last group
LambdaLift cannot run at same phase as Flatten, so it's better to move Flatten one phase later. Some check files that dependent on the order in which symbols were accessed needed to be updated.
1 parent 13d4b4d commit 863e4cb

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ class Compiler {
9898
List(new LinkScala2Impls, // Redirect calls to trait methods defined by Scala 2.x, so that they now go to their implementations
9999
new LambdaLift, // Lifts out nested functions to class scope, storing free variables in environments
100100
// Note: in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here
101-
new ElimStaticThis, // Replace `this` references to static objects by global identifiers
102-
new Flatten, // Lift all inner classes to package scope
103-
new RestoreScopes), // Repair scopes rendered invalid by moving definitions in prior phases of the group
104-
List(new RenameLifted, // Renames lifted classes to local numbering scheme
101+
new ElimStaticThis), // Replace `this` references to static objects by global identifiers
102+
List(new Flatten, // Lift all inner classes to package scope
103+
new RestoreScopes, // Repair scopes rendered invalid by moving definitions in prior phases of the group
104+
new RenameLifted, // Renames lifted classes to local numbering scheme
105105
new TransformWildcards, // Replace wildcards with default values
106106
new MoveStatics, // Move static methods to companion classes
107107
new ExpandPrivate, // Widen private definitions accessed from nested classes

compiler/src/dotty/tools/dotc/transform/RenameLifted.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class RenameLifted extends MiniPhaseTransform with SymTransformer { thisTransfor
1616

1717
override def phaseName = "renameLifted"
1818

19-
override def runsAfterGroupsOf: Set[Class[_ <: Phases.Phase]] = Set(classOf[RestoreScopes])
19+
// Not clear why this should run after restoreScopes
20+
// override def runsAfterGroupsOf: Set[Class[_ <: Phases.Phase]] = Set(classOf[RestoreScopes])
2021

2122
override def treeTransformPhase(implicit ctx: Context, info: TransformerInfo) =
2223
groupEndPhase

compiler/src/dotty/tools/dotc/transform/RestoreScopes.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class RestoreScopes extends MiniPhaseTransform with IdentityDenotTransformer { t
2424

2525
override def changesMembers = true // the phase affects scopes, applying tree transformations of previous phases
2626

27+
override def treeTransformPhase(implicit ctx: Context, info: TransformerInfo) =
28+
groupEndPhase
29+
2730
/* Note: We need to wait until we see a package definition because
2831
* DropEmptyConstructors changes template members when analyzing the
2932
* enclosing package definitions. So by the time RestoreScopes gets to

tests/run/i2738.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
foo
2-
bar$2
3-
foo
42
bar$1
3+
foo
4+
bar$2
55
baz
66
Test$qux$1$
77
baz

tests/run/i3006.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
f$3
2-
f$2
31
f$1
42
f$2
3+
f$3
54
f$1
5+
f$2

tests/run/i3006b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Foo$$init$$$bar$2
21
Foo$$init$$$bar$1
2+
Foo$$init$$$bar$2
33
Bar$$init$$$bar$1

0 commit comments

Comments
 (0)