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