Skip to content

Commit

Permalink
Future migration warning for alphanumeric infix operator
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Nov 3, 2023
1 parent dc012c3 commit f0ede2d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1075,21 +1075,21 @@ trait Checking {
!name.isOperatorName &&
!meth.isDeclaredInfix &&
!meth.maybeOwner.is(Scala2x) &&
!infixOKSinceFollowedBy(tree.right) &&
sourceVersion.isAtLeast(future) =>
!infixOKSinceFollowedBy(tree.right) =>
val (kind, alternative) =
if (ctx.mode.is(Mode.Type))
("type", (n: Name) => s"prefix syntax $n[...]")
else if (ctx.mode.is(Mode.Pattern))
("extractor", (n: Name) => s"prefix syntax $n(...)")
else
("method", (n: Name) => s"method syntax .$n(...)")
def rewriteMsg = Message.rewriteNotice("The latter", options = "-deprecation")
report.deprecationWarning(
def rewriteMsg = Message.rewriteNotice("The latter", version = `future-migration`)
report.errorOrMigrationWarning(
em"""Alphanumeric $kind $name is not declared ${hlAsKeyword("infix")}; it should not be used as infix operator.
|Instead, use ${alternative(name)} or backticked identifier `$name`.$rewriteMsg""",
tree.op.srcPos)
if (ctx.settings.deprecation.value) {
tree.op.srcPos,
from = future)
if sourceVersion == `future-migration` then {
patch(Span(tree.op.span.start, tree.op.span.start), "`")
patch(Span(tree.op.span.end, tree.op.span.end), "`")
}
Expand Down

0 comments on commit f0ede2d

Please sign in to comment.