Skip to content

Commit 3adfcea

Browse files
committed
Handle undesugared ident
1 parent a2d9003 commit 3adfcea

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import dotty.tools.dotc.core.Flags._
1818
import dotty.tools.dotc.core.StdNames._
1919
import dotty.tools.dotc.core.Symbols._
2020
import dotty.tools.dotc.core.Types._
21+
import dotty.tools.dotc.core.Contexts._
2122
import dotty.tools.dotc.util.Spans._
2223
import dotty.tools.dotc.report
2324
import dotty.tools.dotc.transform.SymUtils._
@@ -140,20 +141,22 @@ trait BCodeSkelBuilder extends BCodeHelpers {
140141
coord = claszSymbol.coord
141142
).entered
142143

143-
val thisMap = new TreeTypeMap(
144-
treeMap = {
144+
val thisMap = new TreeMap {
145+
override def transform(tree: Tree)(using Context) = tree match {
145146
case tree: This if tree.symbol == claszSymbol =>
146147
ref(claszSymbol.sourceModule)
148+
case ident: Ident =>
149+
super.transform(desugarIdent(ident))
147150
case tree =>
148-
tree
149-
},
150-
oldOwners = claszSymbol.primaryConstructor :: Nil,
151-
newOwners = clInitSymbol :: Nil
152-
)
151+
super.transform(tree)
152+
}
153+
}
154+
155+
def rewire(stat: Tree) = thisMap.transform(stat).changeOwner(claszSymbol.primaryConstructor, clInitSymbol)
153156

154157
val callConstructor = New(claszSymbol.typeRef).select(claszSymbol.primaryConstructor).appliedToArgs(Nil)
155158
val assignModuleField = Assign(ref(moduleField), callConstructor)
156-
val remainingConstrStatsSubst = remainingConstrStats.map(thisMap(_))
159+
val remainingConstrStatsSubst = remainingConstrStats.map(rewire)
157160
val clinit = DefDef(
158161
clInitSymbol,
159162
Block(assignModuleField :: remainingConstrStatsSubst, unitLiteral)

0 commit comments

Comments
 (0)