Skip to content

Commit bb57aa9

Browse files
committed
Scala.js: Find module accessor of nested private companions
Forward port of scala-js/scala-js@5f9c128 although only a small change had to be ported. The existing structure of the code in dotc made the other changes irrelevant.
1 parent 5c91a61 commit bb57aa9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

compiler/src/dotty/tools/backend/sjs/JSExportsGen.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -745,11 +745,14 @@ final class JSExportsGen(jsCodeGen: JSCodeGen)(using Context) {
745745
} else {
746746
assert(captures.sizeIs == 1, "expected exactly one capture")
747747

748-
// Find the module accessor.
748+
// Find the module accessor. We cannot use memberBasedOnFlags because of scala-js/scala-js#4526.
749749
val outer = targetSym.originalOwner
750750
val name = atPhase(typerPhase)(targetSym.name.unexpandedName).sourceModuleName
751-
val modAccessor = outer.info.memberBasedOnFlags(name, required = Module).symbol
752-
assert(modAccessor.exists, i"could not find module accessor for ${targetSym.fullName} at $pos")
751+
val modAccessor = outer.info.allMembers.find { denot =>
752+
denot.symbol.is(Module) && denot.name.unexpandedName == name
753+
}.getOrElse {
754+
throw new AssertionError(i"could not find module accessor for ${targetSym.fullName} at $pos")
755+
}.symbol
753756

754757
val receiver = captures.head
755758
if (outer.isJSType)

0 commit comments

Comments
 (0)