@@ -119,8 +119,14 @@ trait BCodeSkelBuilder extends BCodeHelpers {
119
119
// TODO should we do this transformation earlier, say in Constructors? Or would that just cause
120
120
// pain for scala-{js, native}?
121
121
122
- for (f <- claszSymbol.info.decls.filter(_.isField))
123
- f.setFlag(JavaStatic )
122
+ // TODO: enable once we change lazy val encoding
123
+ //
124
+ // Lazy val encoding assumes bitmap fields are non-static
125
+ //
126
+ // See `tests/run/given-var.scala`
127
+ //
128
+ // for (f <- claszSymbol.info.decls.filter(_.isField))
129
+ // f.setFlag(JavaStatic)
124
130
125
131
val (clinits, body) = impl.body.partition(stat => stat.isInstanceOf [DefDef ] && stat.symbol.isStaticConstructor)
126
132
@@ -146,13 +152,18 @@ trait BCodeSkelBuilder extends BCodeHelpers {
146
152
).entered
147
153
148
154
val thisMap = new TreeMap {
149
- override def transform (tree : Tree )(using Context ) = tree match {
150
- case tree : This if tree.symbol == claszSymbol =>
151
- ref(claszSymbol.sourceModule)
152
- case ident : Ident =>
153
- super .transform(desugarIdent(ident))
154
- case tree =>
155
- super .transform(tree)
155
+ override def transform (tree : Tree )(using Context ) = {
156
+ val tp = tree.tpe.substThis(claszSymbol.asClass, claszSymbol.sourceModule.termRef)
157
+ tree.withType(tp) match {
158
+ case tree : This if tree.symbol == claszSymbol =>
159
+ ref(claszSymbol.sourceModule)
160
+ case Apply (fun @ Select (Super (qual, _), _), args) if qual.symbol == claszSymbol =>
161
+ ref(claszSymbol.sourceModule).select(fun.symbol).appliedToArgs(args)
162
+ // case ident: Ident =>
163
+ // super.transform(desugarIdent(ident))
164
+ case tree =>
165
+ super .transform(tree)
166
+ }
156
167
}
157
168
}
158
169
0 commit comments