diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2017-03-14 01:18:21 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2017-03-14 01:23:41 +0100 |
commit | 30ddc5ae0d032ce1d0feb028cf9af35c98af24ac (patch) | |
tree | cd810e21ca0997739820ea62bf2556538897506c /compiler/src/dotty/tools/dotc/core/Symbols.scala | |
parent | b3194406d8e1a28690faee12257b53f9dcf49506 (diff) | |
download | dotty-30ddc5ae0d032ce1d0feb028cf9af35c98af24ac.tar.gz dotty-30ddc5ae0d032ce1d0feb028cf9af35c98af24ac.tar.bz2 dotty-30ddc5ae0d032ce1d0feb028cf9af35c98af24ac.zip |
Fix Symbol#sourceFile not working after Flatten
The SourceFile annotation is only present on the non-flattened top-level
class.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/Symbols.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/Symbols.scala | 11 |
1 files changed, 7 insertions, 4 deletions
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 } } |