From 63ff0c6ca4fb6453af206ce6f271720c9dc4cd7e Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 11 Jan 2023 17:16:46 +0000 Subject: [PATCH] Don't treat package object's methods as package members --- compiler/src/dotty/tools/dotc/core/SymDenotations.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index e267bc51758f..8e3315744540 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -2515,9 +2515,12 @@ object SymDenotations { multi.filterWithPredicate(_.symbol.associatedFile == chosen) end dropStale - if symbol eq defn.ScalaPackageClass then + if name == nme.CONSTRUCTOR then + NoDenotation // packages don't have constructors, even if package objects do. + else if symbol eq defn.ScalaPackageClass then + // revert order: search package first, then nested package objects val denots = super.computeMembersNamed(name) - if denots.exists || name == nme.CONSTRUCTOR then denots + if denots.exists then denots else recur(packageObjs, NoDenotation) else recur(packageObjs, NoDenotation) end computeMembersNamed