From b6411818b2e84c0a28c501e2814de4cfde720208 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 23 Mar 2017 20:38:55 +0100 Subject: 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`. --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/typer') diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 706e8b5bf..4077d8d65 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -570,8 +570,8 @@ class Namer { typer: Typer => /** Create links between companion object and companion class */ def createLinks(classTree: TypeDef, moduleTree: TypeDef)(implicit ctx: Context) = { - val claz = ctx.denotNamed(classTree.name.encode).symbol - val modl = ctx.denotNamed(moduleTree.name.encode).symbol + val claz = ctx.effectiveScope.lookup(classTree.name.encode) + val modl = ctx.effectiveScope.lookup(moduleTree.name.encode) ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, claz, modl).entered ctx.synthesizeCompanionMethod(nme.COMPANION_MODULE_METHOD, modl, claz).entered } @@ -613,10 +613,10 @@ class Namer { typer: Typer => // example where this matters. if (ctx.owner.is(PackageClass)) { for (cdef @ TypeDef(moduleName, _) <- moduleDef.values) { - val moduleSym = ctx.denotNamed(moduleName.encode).symbol + val moduleSym = ctx.effectiveScope.lookup(moduleName.encode) if (moduleSym.isDefinedInCurrentRun) { val className = moduleName.stripModuleClassSuffix.toTypeName - val classSym = ctx.denotNamed(className.encode).symbol + val classSym = ctx.effectiveScope.lookup(className.encode) if (!classSym.isDefinedInCurrentRun) { val absentClassSymbol = ctx.newClassSymbol(ctx.owner, className, EmptyFlags, _ => NoType) enterSymbol(absentClassSymbol) -- cgit v1.2.3