Skip to content

Commit d575d34

Browse files
committed
Handle class field uniformly
1 parent 4279d62 commit d575d34

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

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

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,16 @@ trait BCodeSkelBuilder extends BCodeHelpers {
128128
MethodType(Nil)(_ => Nil, _ => defn.UnitType),
129129
privateWithin = NoSymbol,
130130
coord = claszSymbol.coord
131-
)
131+
).entered
132132

133-
// We don't need to enter this field into the decls of claszSymbol.info as this is added manually to the generated class
134-
// in addModuleInstanceField. TODO: try adding it to the decls and making the usual field generation do the right thing.
135133
val moduleField = ctx.newSymbol(
136134
claszSymbol,
137135
str.MODULE_INSTANCE_FIELD.toTermName,
138136
JavaStatic | Private,
139137
claszSymbol.typeRef,
140138
privateWithin = NoSymbol,
141139
coord = claszSymbol.coord
142-
)
140+
).entered
143141

144142
val thisMap = new TreeTypeMap(
145143
treeMap = {
@@ -191,7 +189,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
191189
addClassFields()
192190

193191
innerClassBufferASM ++= classBTypeFromSymbol(claszSymbol).info.memberClasses
194-
gen(impl)
192+
gen(cd.rhs)
195193
addInnerClassesASM(cnode, innerClassBufferASM.toList)
196194

197195
if (AsmUtils.traceClassEnabled && cnode.name.contains(AsmUtils.traceClassPattern))
@@ -236,12 +234,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
236234
cnode.visitAttribute(if (ssa.isDefined) pickleMarkerLocal else pickleMarkerForeign)
237235
emitAnnotations(cnode, claszSymbol.annotations ++ ssa)
238236

239-
if (isCZStaticModule || isCZParcelable) {
240-
241-
if (isCZStaticModule) { addModuleInstanceField() }
242-
243-
} else {
244-
237+
if (!isCZStaticModule && !isCZParcelable) {
245238
val skipStaticForwarders = (claszSymbol.isInterface || claszSymbol.is(Module) || ctx.settings.XnoForwarders.value)
246239
if (!skipStaticForwarders) {
247240
val lmoc = claszSymbol.companionModule
@@ -262,21 +255,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
262255

263256
} // end of method initJClass
264257

265-
/*
266-
* can-multi-thread
267-
*/
268-
private def addModuleInstanceField(): Unit = {
269-
val fv =
270-
cnode.visitField(GenBCodeOps.PublicStaticFinal, // TODO confirm whether we really don't want ACC_SYNTHETIC nor ACC_DEPRECATED
271-
str.MODULE_INSTANCE_FIELD,
272-
"L" + thisName + ";",
273-
null, // no java-generic-signature
274-
null // no initial value
275-
)
276-
277-
fv.visitEnd()
278-
}
279-
280258
/*
281259
* must-single-thread
282260
*/

0 commit comments

Comments
 (0)