Skip to content

Commit 3948861

Browse files
committed
Fix unpickling an inner class in a Scala2 object without companion
When we unpickle a Scala2 module we might not have a companion class to unpickle, when this happen we call markAbsent() on the denotation of the companion class, which means that calls to companionModule will not work. Fixed by falling back to the more robust scalacLinkedClass.
1 parent 13f6a91 commit 3948861

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,12 @@ class ClassfileParser(
827827
def getMember(sym: Symbol, name: Name)(implicit ctx: Context): Symbol =
828828
if (static)
829829
if (sym == classRoot.symbol) staticScope.lookup(name)
830-
else sym.companionModule.info.member(name).symbol
830+
else {
831+
var module = sym.companionModule
832+
if (module == NoSymbol && sym.isAbsent)
833+
module = sym.scalacLinkedClass
834+
module.info.member(name).symbol
835+
}
831836
else
832837
if (sym == classRoot.symbol) instanceScope.lookup(name)
833838
else sym.info.member(name).symbol

0 commit comments

Comments
 (0)