Skip to content

Commit 6a5c037

Browse files
Improve with in type migration warning (#18852)
2 parents eb7fbff + 121e28f commit 6a5c037

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,12 +1756,13 @@ object Parsers {
17561756
if in.token == LBRACE || in.token == INDENT then
17571757
t
17581758
else
1759+
val withSpan = Span(withOffset, withOffset + 4)
17591760
report.errorOrMigrationWarning(
17601761
DeprecatedWithOperator(rewriteNotice(`future-migration`)),
1761-
in.sourcePos(withOffset),
1762+
source.atSpan(withSpan),
17621763
from = future)
17631764
if sourceVersion == `future-migration` then
1764-
patch(source, Span(withOffset, withOffset + 4), "&")
1765+
patch(source, withSpan, "&")
17651766
atSpan(startOffset(t)) { makeAndType(t, withType()) }
17661767
else t
17671768

tests/neg/with-type-operator-future-migration.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-- [E003] Syntax Error: tests/neg/with-type-operator-future-migration.scala:5:13 ---------------------------------------
22
5 |def foo: Int with String = ??? // error
3-
| ^
3+
| ^^^^
44
| with as a type operator has been deprecated; use & instead
55
| This construct can be rewritten automatically under -rewrite -source future-migration.
66
|

0 commit comments

Comments
 (0)