Skip to content

Commit

Permalink
Only apply future patches on future-migration (#18820)
Browse files Browse the repository at this point in the history
Align patch behavior with other migrations warning/errors of
`future-migration`/`future` .
  • Loading branch information
nicolasstucki authored Nov 2, 2023
2 parents e2b38f9 + 0c66054 commit afeb541
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3525,7 +3525,8 @@ object Parsers {
em"`_` is no longer supported for a wildcard $exprName; use `*` instead${rewriteNotice(`future-migration`)}",
in.sourcePos(),
from = future)
patch(source, Span(in.offset, in.offset + 1), "*")
if sourceVersion == `future-migration` then
patch(source, Span(in.offset, in.offset + 1), "*")
ImportSelector(atSpan(in.skipToken()) { Ident(nme.WILDCARD) })

/** 'given [InfixType]' */
Expand All @@ -3544,9 +3545,10 @@ object Parsers {
em"The $exprName renaming `a => b` is no longer supported ; use `a as b` instead${rewriteNotice(`future-migration`)}",
in.sourcePos(),
from = future)
patch(source, Span(in.offset, in.offset + 2),
if testChar(in.offset - 1, ' ') && testChar(in.offset + 2, ' ') then "as"
else " as ")
if sourceVersion == `future-migration` then
patch(source, Span(in.offset, in.offset + 2),
if testChar(in.offset - 1, ' ') && testChar(in.offset + 2, ' ') then "as"
else " as ")
atSpan(startOffset(from), in.skipToken()) {
val to = if in.token == USCORE then wildcardIdent() else termIdent()
ImportSelector(from, if to.name == nme.ERROR then EmptyTree else to)
Expand Down

0 comments on commit afeb541

Please sign in to comment.