diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index a1fb5632d77f..805c25ad40e4 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1756,12 +1756,13 @@ object Parsers { if in.token == LBRACE || in.token == INDENT then t else + val withSpan = Span(withOffset, withOffset + 4) report.errorOrMigrationWarning( DeprecatedWithOperator(rewriteNotice(`future-migration`)), - in.sourcePos(withOffset), + source.atSpan(withSpan), from = future) if sourceVersion == `future-migration` then - patch(source, Span(withOffset, withOffset + 4), "&") + patch(source, withSpan, "&") atSpan(startOffset(t)) { makeAndType(t, withType()) } else t diff --git a/tests/neg/with-type-operator-future-migration.check b/tests/neg/with-type-operator-future-migration.check index 29ea1d5aad4c..845601349c83 100644 --- a/tests/neg/with-type-operator-future-migration.check +++ b/tests/neg/with-type-operator-future-migration.check @@ -1,6 +1,6 @@ -- [E003] Syntax Error: tests/neg/with-type-operator-future-migration.scala:5:13 --------------------------------------- 5 |def foo: Int with String = ??? // error - | ^ + | ^^^^ | with as a type operator has been deprecated; use & instead | This construct can be rewritten automatically under -rewrite -source future-migration. |