From ca2fb9d4890b0fd58e071b0c7baae8bdeaf9fcd4 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Mon, 29 Feb 2016 21:18:52 +0100 Subject: Avoid issues when calling methods on root package symbol SymDenotations#topLevelClass: don't throw an exception Symbols#associateFile: avoid infinite loop --- src/dotty/tools/dotc/core/SymDenotations.scala | 2 +- src/dotty/tools/dotc/core/Symbols.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 78acd8f1a..ff99f3b55 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -868,7 +868,7 @@ object SymDenotations { */ final def topLevelClass(implicit ctx: Context): Symbol = { def topLevel(d: SymDenotation): Symbol = { - if ((d is PackageClass) || (d.owner is PackageClass)) d.symbol + if (d.isEffectiveRoot || (d is PackageClass) || (d.owner is PackageClass)) d.symbol else topLevel(d.owner) } val sym = topLevel(this) diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 4c1654e47..1b605e24f 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -519,7 +519,7 @@ object Symbols { /** The source or class file from which this class was generated, null if not applicable. */ override def associatedFile(implicit ctx: Context): AbstractFile = - if (assocFile != null || (this.owner is PackageClass)) assocFile + if (assocFile != null || (this.owner is PackageClass) || this.isEffectiveRoot) assocFile else super.associatedFile final def classDenot(implicit ctx: Context): ClassDenotation = -- cgit v1.2.3