Skip to content

Commit b641181

Browse files
committed
Namer#createCompanionLinks: avoid using denotNamed
The previous commit introduced two new usages of `denotNamed` which broke tests/run/t1987b because `denotNamed` indirectly calls `packageObj` which caches the package object, except that at this point the package object is not yet entered, so the cache was incorrect. We fix this by using `effectiveScope.lookup` instead since we only need to look into the current scope, this is also true for the two existing usage of `denotNamed` in `createCompanionLinks` so they were also replaced by `effectiveScope.lookup`.
1 parent 65455bb commit b641181

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,8 @@ class Namer { typer: Typer =>
570570

571571
/** Create links between companion object and companion class */
572572
def createLinks(classTree: TypeDef, moduleTree: TypeDef)(implicit ctx: Context) = {
573-
val claz = ctx.denotNamed(classTree.name.encode).symbol
574-
val modl = ctx.denotNamed(moduleTree.name.encode).symbol
573+
val claz = ctx.effectiveScope.lookup(classTree.name.encode)
574+
val modl = ctx.effectiveScope.lookup(moduleTree.name.encode)
575575
ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, claz, modl).entered
576576
ctx.synthesizeCompanionMethod(nme.COMPANION_MODULE_METHOD, modl, claz).entered
577577
}
@@ -613,10 +613,10 @@ class Namer { typer: Typer =>
613613
// example where this matters.
614614
if (ctx.owner.is(PackageClass)) {
615615
for (cdef @ TypeDef(moduleName, _) <- moduleDef.values) {
616-
val moduleSym = ctx.denotNamed(moduleName.encode).symbol
616+
val moduleSym = ctx.effectiveScope.lookup(moduleName.encode)
617617
if (moduleSym.isDefinedInCurrentRun) {
618618
val className = moduleName.stripModuleClassSuffix.toTypeName
619-
val classSym = ctx.denotNamed(className.encode).symbol
619+
val classSym = ctx.effectiveScope.lookup(className.encode)
620620
if (!classSym.isDefinedInCurrentRun) {
621621
val absentClassSymbol = ctx.newClassSymbol(ctx.owner, className, EmptyFlags, _ => NoType)
622622
enterSymbol(absentClassSymbol)

0 commit comments

Comments
 (0)