diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index a9eb9f56caaf..4b857d1f3102 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -295,13 +295,10 @@ object Denotations { (p: Symbol => Boolean) (using Context): Symbol = disambiguate(p) match { - case m @ MissingRef(ownerd, name) => - if (generateStubs) { - if (ctx.settings.YdebugMissingRefs.value) m.ex.printStackTrace() - newStubSymbol(ownerd.symbol, name, source) - } - else NoSymbol - case NoDenotation | _: NoQualifyingRef => + case m @ MissingRef(ownerd, name) if generateStubs => + if ctx.settings.YdebugMissingRefs.value then m.ex.printStackTrace() + newStubSymbol(ownerd.symbol, name, source) + case NoDenotation | _: NoQualifyingRef | _: MissingRef => def argStr = if (args.isEmpty) "" else i" matching ($args%, %)" val msg = if (site.exists) i"$site does not have a member $kind $name$argStr" diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index 5f160a282041..7eaa1f411e07 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -908,13 +908,11 @@ object Symbols { def requiredClassRef(path: PreName)(using Context): TypeRef = requiredClass(path).typeRef /** Get ClassSymbol if class is either defined in current compilation run - * or present on classpath. - * Returns NoSymbol otherwise. */ - def getClassIfDefined(path: PreName)(using Context): Symbol = { - val name = path.toTypeName - staticRef(name, generateStubs = false) - .requiredSymbol("class", name, generateStubs = false)(_.isClass) - } + * or present on classpath. Returns NoSymbol otherwise. + */ + def getClassIfDefined(path: PreName)(using Context): Symbol = + staticRef(path.toTypeName, generateStubs = false) + .disambiguate(_.isClass).symbol /** Get a List of ClassSymbols which are either defined in current compilation * run or present on classpath. @@ -923,13 +921,11 @@ object Symbols { paths.map(getClassIfDefined).filter(_.exists).map(_.asInstanceOf[ClassSymbol]) /** Get ClassSymbol if package is either defined in current compilation run - * or present on classpath. - * Returns NoSymbol otherwise. */ - def getPackageClassIfDefined(path: PreName)(using Context): Symbol = { - val name = path.toTypeName - staticRef(name, isPackage = true, generateStubs = false) - .requiredSymbol("package", name, generateStubs = false)(_ is PackageClass) - } + * or present on classpath. Returns NoSymbol otherwise. + */ + def getPackageClassIfDefined(path: PreName)(using Context): Symbol = + staticRef(path.toTypeName, isPackage = true, generateStubs = false) + .disambiguate(_ is PackageClass).symbol def requiredModule(path: PreName)(using Context): TermSymbol = { val name = path.toTermName