File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ class Compiler {
67
67
new Constructors ,
68
68
new FunctionalInterfaces ),
69
69
List (new LambdaLift , // in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here
70
+ new ElimStaticThis ,
70
71
new Flatten ,
71
72
new RestoreScopes ),
72
73
List (/* new PrivateToStatic,*/
Original file line number Diff line number Diff line change
1
+ package dotty .tools .dotc
2
+ package transform
3
+
4
+ import core ._
5
+ import Contexts .Context
6
+ import Flags ._
7
+ import dotty .tools .dotc .core .StdNames ._
8
+ import dotty .tools .dotc .core .SymDenotations .SymDenotation
9
+ import TreeTransforms .{MiniPhaseTransform , TransformerInfo }
10
+
11
+ /** Replace This references to module classes in static methods by global identifiers to the
12
+ * corresponding modules.
13
+ */
14
+ class ElimStaticThis extends MiniPhaseTransform {
15
+ import ast .tpd ._
16
+ def phaseName : String = " elimStaticThis"
17
+
18
+ override def transformThis (tree : This )(implicit ctx : Context , info : TransformerInfo ): Tree =
19
+ if (! tree.symbol.is(Package ) && ctx.owner.enclosingMethod.is(JavaStatic )) {
20
+ assert(tree.symbol.is(ModuleClass ))
21
+ ref(tree.symbol.sourceModule)
22
+ }
23
+ else tree
24
+ }
You can’t perform that action at this time.
0 commit comments