File tree 1 file changed +13
-1
lines changed
compiler/src/dotty/tools/dotc/transform
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,19 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
335
335
&& ctx.compilationUnit.source.exists
336
336
&& sym != defn.SourceFileAnnot
337
337
then
338
- sym.addAnnotation(Annotation .makeSourceFile(ctx.compilationUnit.source.file.path))
338
+ def sourcerootPath =
339
+ java.nio.file.Paths .get(ctx.settings.sourceroot.value)
340
+ .toAbsolutePath
341
+ .normalize
342
+ val file = ctx.compilationUnit.source.file
343
+ val relativePath =
344
+ if file.path.startsWith(str.REPL_SESSION_LINE ) then
345
+ file.path
346
+ else
347
+ val jpath = file.jpath
348
+ if jpath.isAbsolute then sourcerootPath.relativize(jpath.normalize).toString
349
+ else jpath.normalize.toString
350
+ sym.addAnnotation(Annotation .makeSourceFile(relativePath))
339
351
else (tree.rhs, sym.info) match
340
352
case (rhs : LambdaTypeTree , bounds : TypeBounds ) =>
341
353
VarianceChecker .checkLambda(rhs, bounds)
You can’t perform that action at this time.
0 commit comments