Skip to content

Commit

Permalink
Improve with in type migration warning (#18852)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki authored Nov 6, 2023
2 parents eb7fbff + 121e28f commit 6a5c037
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/with-type-operator-future-migration.check
Original file line number Diff line number Diff line change
@@ -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.
|
Expand Down

0 comments on commit 6a5c037

Please sign in to comment.