Skip to content

Commit

Permalink
Improve with in type migration warning
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Nov 6, 2023
1 parent 5623c1b commit 121e28f
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 121e28f

Please sign in to comment.