From 8ac4db2c31419d77d507ffc164f29b452728782d Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 2 Oct 2025 08:42:42 -0600 Subject: [PATCH 1/2] . --- compiler/src/dotty/tools/dotc/ast/Positioned.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Positioned.scala b/compiler/src/dotty/tools/dotc/ast/Positioned.scala index 5475935ba918..6cad6fa0bd92 100644 --- a/compiler/src/dotty/tools/dotc/ast/Positioned.scala +++ b/compiler/src/dotty/tools/dotc/ast/Positioned.scala @@ -55,11 +55,11 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src def sourcePos(using Context): SourcePosition = val info = WrappedSourceFile.locateMagicHeader(source) info match - case HasHeader(offset, originalFile) => - if span.start >= offset then // This span is in user code + // This span is in user code + case HasHeader(offset, originalFile) + if span != NoSpan && span.start >= offset => originalFile.atSpan(span.shift(-offset)) - else // Otherwise, return the source position in the wrapper code - source.atSpan(span) + // Otherwise, return the source position in the wrapper code case _ => source.atSpan(span) /** This positioned item, widened to `SrcPos`. Used to make clear we only need the From 55b470f8cb946bd7032b39ff51b8833d0e3bef64 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Thu, 2 Oct 2025 08:46:08 -0600 Subject: [PATCH 2/2] . --- compiler/src/dotty/tools/dotc/ast/Positioned.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Positioned.scala b/compiler/src/dotty/tools/dotc/ast/Positioned.scala index 6cad6fa0bd92..23d01371d174 100644 --- a/compiler/src/dotty/tools/dotc/ast/Positioned.scala +++ b/compiler/src/dotty/tools/dotc/ast/Positioned.scala @@ -57,7 +57,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Src info match // This span is in user code case HasHeader(offset, originalFile) - if span != NoSpan && span.start >= offset => + if span.exists && span.start >= offset => originalFile.atSpan(span.shift(-offset)) // Otherwise, return the source position in the wrapper code case _ => source.atSpan(span)