Skip to content

Commit 5d70ad7

Browse files
committed
Avoid issues when calling methods on root package symbol
SymDenotations#topLevelClass: don't throw an exception Symbols#associateFile: avoid infinite loop
1 parent f9858a4 commit 5d70ad7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ object SymDenotations {
868868
*/
869869
final def topLevelClass(implicit ctx: Context): Symbol = {
870870
def topLevel(d: SymDenotation): Symbol = {
871-
if ((d is PackageClass) || (d.owner is PackageClass)) d.symbol
871+
if (d.isEffectiveRoot || (d is PackageClass) || (d.owner is PackageClass)) d.symbol
872872
else topLevel(d.owner)
873873
}
874874
val sym = topLevel(this)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ object Symbols {
517517

518518
/** The source or class file from which this class was generated, null if not applicable. */
519519
override def associatedFile(implicit ctx: Context): AbstractFile =
520-
if (assocFile != null || (this.owner is PackageClass)) assocFile
520+
if (assocFile != null || (this.owner is PackageClass) || this.isEffectiveRoot) assocFile
521521
else super.associatedFile
522522

523523
final def classDenot(implicit ctx: Context): ClassDenotation =

0 commit comments

Comments
 (0)