From a437a824fe7474e763410d238b98aa8f5731b1df Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 18 Jan 2021 13:37:03 +0100 Subject: [PATCH] Force less when computing the type of a module val Fixes #11141 --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 5 +++-- tests/pos/i11141.scala | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i11141.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 731f1786cac8..77467efc3949 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1328,8 +1328,9 @@ class Namer { typer: Typer => */ def moduleValSig(sym: Symbol)(using Context): Type = { val clsName = sym.name.moduleClassName - val cls = ctx.denotNamed(clsName).suchThat(_.is(ModuleClass)) - .orElse(newStubSymbol(ctx.owner, clsName).assertingErrorsReported) + val cls = ctx.effectiveScope.lookupAll(clsName) + .find(_.is(ModuleClass)) + .getOrElse(newStubSymbol(ctx.owner, clsName).assertingErrorsReported) ctx.owner.thisType.select(clsName, cls) } diff --git a/tests/pos/i11141.scala b/tests/pos/i11141.scala new file mode 100644 index 000000000000..c0fc916ccb35 --- /dev/null +++ b/tests/pos/i11141.scala @@ -0,0 +1,5 @@ +package p +export X._ + +object X: + val A = 42