Skip to content

Don't swallow errors in requiredSymbol #9607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 10 additions & 14 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down