Skip to content

Commit a235205

Browse files
committed
Future migration warning for alphanumeric infix operator
1 parent dc012c3 commit a235205

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,21 +1075,21 @@ trait Checking {
10751075
!name.isOperatorName &&
10761076
!meth.isDeclaredInfix &&
10771077
!meth.maybeOwner.is(Scala2x) &&
1078-
!infixOKSinceFollowedBy(tree.right) &&
1079-
sourceVersion.isAtLeast(future) =>
1078+
!infixOKSinceFollowedBy(tree.right) =>
10801079
val (kind, alternative) =
10811080
if (ctx.mode.is(Mode.Type))
10821081
("type", (n: Name) => s"prefix syntax $n[...]")
10831082
else if (ctx.mode.is(Mode.Pattern))
10841083
("extractor", (n: Name) => s"prefix syntax $n(...)")
10851084
else
10861085
("method", (n: Name) => s"method syntax .$n(...)")
1087-
def rewriteMsg = Message.rewriteNotice("The latter", options = "-deprecation")
1088-
report.deprecationWarning(
1086+
def rewriteMsg = Message.rewriteNotice("The latter", version = `future-migration`)
1087+
report.errorOrMigrationWarning(
10891088
em"""Alphanumeric $kind $name is not declared ${hlAsKeyword("infix")}; it should not be used as infix operator.
10901089
|Instead, use ${alternative(name)} or backticked identifier `$name`.$rewriteMsg""",
1091-
tree.op.srcPos)
1092-
if (ctx.settings.deprecation.value) {
1090+
tree.op.srcPos,
1091+
from = future)
1092+
if sourceVersion == `future-migration` then {
10931093
patch(Span(tree.op.span.start, tree.op.span.start), "`")
10941094
patch(Span(tree.op.span.end, tree.op.span.end), "`")
10951095
}

tests/neg/rewrite-messages.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
| ^^^
99
| Alphanumeric method foo is not declared infix; it should not be used as infix operator.
1010
| Instead, use method syntax .foo(...) or backticked identifier `foo`.
11-
| The latter can be rewritten automatically under -rewrite -deprecation.
11+
| The latter can be rewritten automatically under -rewrite -source future-migration.

0 commit comments

Comments
 (0)