diff options
-rw-r--r-- | src/dotty/tools/dotc/core/SymbolLoaders.scala | 11 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 1 | ||||
-rw-r--r-- | test/test/ShowClassTests.scala | 6 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala index 097ab8e9e..8c128e808 100644 --- a/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -52,6 +52,7 @@ class SymbolLoaders { (modul, _) => completer.proxy withDecls newScope withSourceModule modul, assocFile = completer.sourceFileOrNull) enterNew(owner, module, completer, scope) + enterNew(owner, module.moduleClass, completer, scope) } /** Enter package with given `name` into scope of `owner` @@ -149,14 +150,18 @@ class SymbolLoaders { def doComplete(root: SymDenotation) { assert(root is PackageClass, root) + def maybeModuleClass(classRep: ClassPath#ClassRep) = classRep.name.last == '$' val pre = root.owner.thisType root.info = ClassInfo(pre, root.symbol.asClass, Nil, preDecls, TermRef.withSym(pre, sourceModule)) if (!sourceModule.isCompleted) sourceModule.completer.complete(sourceModule) if (!root.isRoot) { - for (classRep <- classpath.classes) { - initializeFromClassPath(root.symbol, classRep) - } + for (classRep <- classpath.classes) + if (!maybeModuleClass(classRep)) + initializeFromClassPath(root.symbol, classRep) + for (classRep <- classpath.classes) + if (maybeModuleClass(classRep) && !root.decls.lookup(classRep.name.toTypeName).exists) + initializeFromClassPath(root.symbol, classRep) } if (!root.isEmptyPackage) { for (pkg <- classpath.packages) { diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index d0d517c19..1f8c475ab 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -345,6 +345,7 @@ object Symbols { final def entered(implicit ctx: Context): this.type = { assert(this.owner.isClass, this.owner.denot) // !!! DEBUG this.owner.asClass.enter(this) + if (this is Module) this.owner.asClass.enter(this.moduleClass) this } diff --git a/test/test/ShowClassTests.scala b/test/test/ShowClassTests.scala index 4f4aa0907..779c2daf9 100644 --- a/test/test/ShowClassTests.scala +++ b/test/test/ShowClassTests.scala @@ -48,9 +48,9 @@ class ShowClassTests extends DottyTest { sym <- pkg.info.decls if sym.owner == pkg.moduleClass && !(sym.name contains '$') ) { println(s"showing $sym in ${pkg.fullName}") - if (sym is Package) showPackage(sym.asTerm) - else if (sym.isClass) showClass(sym) - else if (sym is Module) showClass(sym.moduleClass) + if (sym is PackageVal) showPackage(sym.asTerm) + else if (sym.isClass && !(sym is Module)) showClass(sym) + else if (sym is ModuleVal) showClass(sym.moduleClass) } } } |