aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/Symbols.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-03-14 01:18:21 +0100
committerGuillaume Martres <smarter@ubuntu.com>2017-03-14 01:23:41 +0100
commit30ddc5ae0d032ce1d0feb028cf9af35c98af24ac (patch)
treecd810e21ca0997739820ea62bf2556538897506c /compiler/src/dotty/tools/dotc/core/Symbols.scala
parentb3194406d8e1a28690faee12257b53f9dcf49506 (diff)
downloaddotty-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.scala11
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
}
}