Skip to content

Commit 34f1650

Browse files
committed
Both module and class being unpickled need to register links.
1 parent 14e0f72 commit 34f1650

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/dotty/tools/dotc/core/pickling/UnPickler.scala

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,22 @@ object UnPickler {
120120
if (!(denot.flagsUNSAFE is JavaModule)) ensureConstructor(denot.symbol.asClass, decls)
121121

122122
val scalacCompanion = denot.classSymbol.scalacLinkedClass
123-
if (denot.flagsUNSAFE is Module) {
124-
val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, scalacCompanion, denot.classSymbol)
123+
124+
def registerCompanionPair(module: Symbol, claz: Symbol) = {
125+
val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, claz, module)
125126
if (companionClassMethod.exists)
126127
companionClassMethod.entered
127-
} else {
128-
val companionModuleMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_MODULE_METHOD, scalacCompanion, denot.classSymbol)
128+
val companionModuleMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_MODULE_METHOD, module, claz)
129129
if (companionModuleMethod.exists)
130130
companionModuleMethod.entered
131131
}
132132

133+
if (denot.flagsUNSAFE is Module) {
134+
registerCompanionPair(denot.classSymbol, scalacCompanion)
135+
} else {
136+
registerCompanionPair(scalacCompanion, denot.classSymbol)
137+
}
138+
133139
denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, parentRefs, decls, ost)
134140
}
135141
}

0 commit comments

Comments
 (0)