aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Namer.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-03-23 20:38:55 +0100
committerGuillaume Martres <smarter@ubuntu.com>2017-03-24 17:54:24 +0100
commitb6411818b2e84c0a28c501e2814de4cfde720208 (patch)
tree44b948ae6c9803809e0729c180048ae11e4b82d6 /compiler/src/dotty/tools/dotc/typer/Namer.scala
parent65455bbcaace514ea34a30a3fc102c8ecee16498 (diff)
downloaddotty-b6411818b2e84c0a28c501e2814de4cfde720208.tar.gz
dotty-b6411818b2e84c0a28c501e2814de4cfde720208.tar.bz2
dotty-b6411818b2e84c0a28c501e2814de4cfde720208.zip
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`.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer/Namer.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Namer.scala8
1 files changed, 4 insertions, 4 deletions
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)