Skip to content

Commit 4279d62

Browse files
committed
Remove old init code in constructor
1 parent a47690e commit 4279d62

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -701,22 +701,6 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
701701
else genSynchronized(app, expectedType)
702702

703703
case Apply(fun @ DesugaredSelect(Super(_, _), _), args) =>
704-
def initModule(): Unit = {
705-
// we initialize the MODULE$ field immediately after the super ctor
706-
if (!isModuleInitialized &&
707-
jMethodName == INSTANCE_CONSTRUCTOR_NAME &&
708-
fun.symbol.javaSimpleName == INSTANCE_CONSTRUCTOR_NAME &&
709-
claszSymbol.isStaticModuleClass) {
710-
isModuleInitialized = true
711-
mnode.visitVarInsn(asm.Opcodes.ALOAD, 0)
712-
mnode.visitFieldInsn(
713-
asm.Opcodes.PUTSTATIC,
714-
thisName,
715-
str.MODULE_INSTANCE_FIELD,
716-
"L" + thisName + ";"
717-
)
718-
}
719-
}
720704
// 'super' call: Note: since constructors are supposed to
721705
// return an instance of what they construct, we have to take
722706
// special care. On JVM they are 'void', and Scala forbids (syntactically)
@@ -726,7 +710,6 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
726710
mnode.visitVarInsn(asm.Opcodes.ALOAD, 0)
727711
genLoadArguments(args, paramTKs(app))
728712
generatedType = genCallMethod(fun.symbol, InvokeStyle.Super, app.span)
729-
initModule()
730713

731714
// 'new' constructor call: Note: since constructors are
732715
// thought to return an instance of what they construct,

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
332332
var isMethSymStaticCtor = false
333333
var returnType: BType = null
334334
var methSymbol: Symbol = null
335-
// in GenASM this is local to genCode(), ie should get false whenever a new method is emitted (including fabricated ones eg addStaticInit())
336-
var isModuleInitialized = false
337335
// used by genLoadTry() and genSynchronized()
338336
var earlyReturnVar: Symbol = null
339337
var shouldEmitCleanup = false
@@ -532,7 +530,6 @@ trait BCodeSkelBuilder extends BCodeHelpers {
532530
assert(varsInScope == null, "Unbalanced entering/exiting of GenBCode's genBlock().")
533531
// check previous invocation of genDefDef unregistered as many cleanups as it registered.
534532
assert(cleanups == Nil, "Previous invocation of genDefDef didn't unregister as many cleanups as it registered.")
535-
isModuleInitialized = false
536533
earlyReturnVar = null
537534
shouldEmitCleanup = false
538535

0 commit comments

Comments
 (0)