@@ -1071,12 +1071,17 @@ trait Checking {
10711071 def checkValidInfix (tree : untpd.InfixOp , meth : Symbol )(using Context ): Unit = {
10721072 tree.op match {
10731073 case id @ Ident (name : Name ) =>
1074+ def methCompiledBeforeDeprecation =
1075+ meth.tastyVersion match
1076+ case Some (version) => version.minor < 4 // compiled before 3.4
1077+ case _ => false // compiled with the current compiler
10741078 name.toTermName match {
10751079 case name : SimpleName
10761080 if ! untpd.isBackquoted(id) &&
10771081 ! name.isOperatorName &&
10781082 ! meth.isDeclaredInfix &&
10791083 ! meth.maybeOwner.is(Scala2x ) &&
1084+ ! methCompiledBeforeDeprecation &&
10801085 ! infixOKSinceFollowedBy(tree.right) =>
10811086 val (kind, alternative) =
10821087 if (ctx.mode.is(Mode .Type ))
@@ -1085,13 +1090,14 @@ trait Checking {
10851090 (" extractor" , (n : Name ) => s " prefix syntax $n(...) " )
10861091 else
10871092 (" method" , (n : Name ) => s " method syntax . $n(...) " )
1088- def rewriteMsg = Message .rewriteNotice(" The latter" , version = `future -migration`)
1089- report.errorOrMigrationWarning (
1093+ def rewriteMsg = Message .rewriteNotice(" The latter" , version = `3.4 -migration`)
1094+ report.gradualErrorOrMigrationWarning (
10901095 em """ Alphanumeric $kind $name is not declared ${hlAsKeyword(" infix" )}; it should not be used as infix operator.
10911096 |Instead, use ${alternative(name)} or backticked identifier ` $name`. $rewriteMsg""" ,
10921097 tree.op.srcPos,
1093- from = future)
1094- if sourceVersion == `future-migration` then {
1098+ warnFrom = `3.4`,
1099+ errorFrom = future)
1100+ if sourceVersion.isMigrating && sourceVersion.isAtLeast(`3.4-migration`) then {
10951101 patch(Span (tree.op.span.start, tree.op.span.start), " `" )
10961102 patch(Span (tree.op.span.end, tree.op.span.end), " `" )
10971103 }
0 commit comments