From 30ddc5ae0d032ce1d0feb028cf9af35c98af24ac Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Tue, 14 Mar 2017 01:18:21 +0100 Subject: Fix Symbol#sourceFile not working after Flatten The SourceFile annotation is only present on the non-flattened top-level class. --- compiler/src/dotty/tools/dotc/core/Symbols.scala | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'compiler') diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index c5e064478..9d1d6481d 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -496,12 +496,15 @@ object Symbols { final def sourceFile(implicit ctx: Context): AbstractFile = { val file = associatedFile if (file != null && !file.path.endsWith("class")) file - else denot.topLevelClass.getAnnotation(defn.SourceFileAnnot) match { - case Some(sourceAnnot) => sourceAnnot.argumentConstant(0) match { - case Some(Constant(path: String)) => AbstractFile.getFile(path) + else { + val topLevelCls = denot.topLevelClass(ctx.withPhaseNoLater(ctx.flattenPhase)) + topLevelCls.getAnnotation(defn.SourceFileAnnot) match { + case Some(sourceAnnot) => sourceAnnot.argumentConstant(0) match { + case Some(Constant(path: String)) => AbstractFile.getFile(path) + case none => null + } case none => null } - case none => null } } -- cgit v1.2.3