From 9e018407915c8bb5db9ec9d4e16676f9fa64da4f Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 27 Nov 2023 14:30:12 +0100 Subject: [PATCH] Do not add `@SourceFile` annotations --- compiler/src/dotty/tools/dotc/core/Annotations.scala | 2 -- compiler/src/dotty/tools/dotc/transform/PostTyper.scala | 4 ---- 2 files changed, 6 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index 43c753458f6e..e11149fd2d37 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -245,8 +245,6 @@ object Annotations { else None } - def makeSourceFile(path: String, span: Span)(using Context): Annotation = - apply(defn.SourceFileAnnot, Literal(Constant(path)), span) } @sharable val EmptyAnnotation = Annotation(EmptyTree) diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 817debc2eba9..4b691471c421 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -419,10 +419,6 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase => em"The type of a class parent cannot refer to constructor parameters, but ${parent.tpe} refers to ${illegalRefs.map(_.name.show).mkString(",")}", parent.srcPos) // Add SourceFile annotation to top-level classes if sym.owner.is(Package) then - if ctx.compilationUnit.source.exists && sym != defn.SourceFileAnnot then - val reference = ctx.settings.sourceroot.value - val relativePath = util.SourceFile.relativePath(ctx.compilationUnit.source, reference) - sym.addAnnotation(Annotation.makeSourceFile(relativePath, tree.span)) if sym != defn.WithPureFunsAnnot && sym != defn.CaptureCheckedAnnot then if Feature.ccEnabled then sym.addAnnotation(Annotation(defn.CaptureCheckedAnnot, tree.span))