Skip to content

Commit 9b8ab6e

Browse files
committed
Use source file from TASTy attribute when available
1 parent 8f71739 commit 9b8ab6e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,12 @@ object Symbols extends SymUtils {
486486
mySource = ctx.getSource(file)
487487
else
488488
mySource = defn.patchSource(this)
489+
if !mySource.exists then
490+
val compUnitInfo = compilationUnitInfo
491+
if compUnitInfo != null then
492+
compUnitInfo.tastyInfo.flatMap(_.attributes.sourceFile) match
493+
case Some(path) => mySource = ctx.getSource(path)
494+
case _ =>
489495
if !mySource.exists then
490496
mySource = atPhaseNoLater(flattenPhase) {
491497
denot.topLevelClass.unforcedAnnotation(defn.SourceFileAnnot) match

compiler/src/dotty/tools/dotc/core/tasty/Attributes.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class Attributes(
1212
booleanTags.contains(TastyFormat.SCALA2STANDARDLIBRARYattr)
1313
def explicitNulls: Boolean =
1414
booleanTags.contains(TastyFormat.EXPLICITNULLSattr)
15-
def sourceFile: String =
16-
stringTagValues(TastyFormat.SOURCEFILEattr)
15+
def sourceFile: Option[String] =
16+
stringTagValues.get(TastyFormat.SOURCEFILEattr)
1717
}
1818

1919
object Attributes:

0 commit comments

Comments
 (0)