Skip to content

Commit 9ceef59

Browse files
committed
Prepare for @SourceFile removal
The only missing step is in the TODO added in this commit.
1 parent c755be1 commit 9ceef59

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,6 @@ object Annotations {
244244
}
245245
else None
246246
}
247-
248-
def makeSourceFile(path: String, span: Span)(using Context): Annotation =
249-
apply(defn.SourceFileAnnot, Literal(Constant(path)), span)
250247
}
251248

252249
@sharable val EmptyAnnotation = Annotation(EmptyTree)

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,13 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
417417
if illegalRefs.nonEmpty then
418418
report.error(
419419
em"The type of a class parent cannot refer to constructor parameters, but ${parent.tpe} refers to ${illegalRefs.map(_.name.show).mkString(",")}", parent.srcPos)
420-
// Add SourceFile annotation to top-level classes
421420
if sym.owner.is(Package) then
421+
// Add SourceFile annotation to top-level classes
422+
// TODO remove this annotation once the reference compiler uses the TASTy source file attribute.
422423
if ctx.compilationUnit.source.exists && sym != defn.SourceFileAnnot then
423424
val reference = ctx.settings.sourceroot.value
424425
val relativePath = util.SourceFile.relativePath(ctx.compilationUnit.source, reference)
425-
sym.addAnnotation(Annotation.makeSourceFile(relativePath, tree.span))
426+
sym.addAnnotation(Annotation(defn.SourceFileAnnot, Literal(Constants.Constant(relativePath)), tree.span))
426427
else
427428
if !sym.is(Param) && !sym.owner.isOneOf(AbstractOrTrait) then
428429
Checking.checkGoodBounds(tree.symbol)

0 commit comments

Comments
 (0)