Skip to content

Commit f2a2dfc

Browse files
Merge pull request #9607 from dotty-staging/fix-requiredSymbol
Don't swallow errors in requiredSymbol
2 parents b251a0f + ff340bd commit f2a2dfc

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,10 @@ object Denotations {
295295
(p: Symbol => Boolean)
296296
(using Context): Symbol =
297297
disambiguate(p) match {
298-
case m @ MissingRef(ownerd, name) =>
299-
if (generateStubs) {
300-
if (ctx.settings.YdebugMissingRefs.value) m.ex.printStackTrace()
301-
newStubSymbol(ownerd.symbol, name, source)
302-
}
303-
else NoSymbol
304-
case NoDenotation | _: NoQualifyingRef =>
298+
case m @ MissingRef(ownerd, name) if generateStubs =>
299+
if ctx.settings.YdebugMissingRefs.value then m.ex.printStackTrace()
300+
newStubSymbol(ownerd.symbol, name, source)
301+
case NoDenotation | _: NoQualifyingRef | _: MissingRef =>
305302
def argStr = if (args.isEmpty) "" else i" matching ($args%, %)"
306303
val msg =
307304
if (site.exists) i"$site does not have a member $kind $name$argStr"

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -908,13 +908,11 @@ object Symbols {
908908
def requiredClassRef(path: PreName)(using Context): TypeRef = requiredClass(path).typeRef
909909

910910
/** Get ClassSymbol if class is either defined in current compilation run
911-
* or present on classpath.
912-
* Returns NoSymbol otherwise. */
913-
def getClassIfDefined(path: PreName)(using Context): Symbol = {
914-
val name = path.toTypeName
915-
staticRef(name, generateStubs = false)
916-
.requiredSymbol("class", name, generateStubs = false)(_.isClass)
917-
}
911+
* or present on classpath. Returns NoSymbol otherwise.
912+
*/
913+
def getClassIfDefined(path: PreName)(using Context): Symbol =
914+
staticRef(path.toTypeName, generateStubs = false)
915+
.disambiguate(_.isClass).symbol
918916

919917
/** Get a List of ClassSymbols which are either defined in current compilation
920918
* run or present on classpath.
@@ -923,13 +921,11 @@ object Symbols {
923921
paths.map(getClassIfDefined).filter(_.exists).map(_.asInstanceOf[ClassSymbol])
924922

925923
/** Get ClassSymbol if package is either defined in current compilation run
926-
* or present on classpath.
927-
* Returns NoSymbol otherwise. */
928-
def getPackageClassIfDefined(path: PreName)(using Context): Symbol = {
929-
val name = path.toTypeName
930-
staticRef(name, isPackage = true, generateStubs = false)
931-
.requiredSymbol("package", name, generateStubs = false)(_ is PackageClass)
932-
}
924+
* or present on classpath. Returns NoSymbol otherwise.
925+
*/
926+
def getPackageClassIfDefined(path: PreName)(using Context): Symbol =
927+
staticRef(path.toTypeName, isPackage = true, generateStubs = false)
928+
.disambiguate(_ is PackageClass).symbol
933929

934930
def requiredModule(path: PreName)(using Context): TermSymbol = {
935931
val name = path.toTermName

0 commit comments

Comments
 (0)