Skip to content

Commit 4a0646c

Browse files
committed
Don't report warning in migration when rewriting
1 parent 1ea177d commit 4a0646c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

compiler/src/dotty/tools/dotc/report.scala

+4-3
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ object report:
6767
error(ex.toMessage, pos, sticky = true)
6868
if ctx.settings.YdebugTypeError.value then ex.printStackTrace()
6969

70-
def errorOrMigrationWarning(msg: Message, pos: SrcPos = NoSourcePosition, from: SourceVersion)(using Context): Unit =
70+
def errorOrMigrationWarning(msg: => Message, pos: SrcPos = NoSourcePosition, from: SourceVersion)(using Context): Unit =
7171
if sourceVersion.isAtLeast(from) then
72-
if sourceVersion.isMigrating && sourceVersion.ordinal <= from.ordinal then migrationWarning(msg, pos)
72+
if sourceVersion.isMigrating && sourceVersion.ordinal <= from.ordinal then
73+
if ctx.settings.rewrite.value.isEmpty then migrationWarning(msg, pos)
7374
else error(msg, pos)
7475

75-
def gradualErrorOrMigrationWarning(msg: Message, pos: SrcPos = NoSourcePosition, warnFrom: SourceVersion, errorFrom: SourceVersion)(using Context): Unit =
76+
def gradualErrorOrMigrationWarning(msg: => Message, pos: SrcPos = NoSourcePosition, warnFrom: SourceVersion, errorFrom: SourceVersion)(using Context): Unit =
7677
if sourceVersion.isAtLeast(errorFrom) then errorOrMigrationWarning(msg, pos, errorFrom)
7778
else if sourceVersion.isAtLeast(warnFrom) then warning(msg, pos)
7879

compiler/test/dotty/tools/dotc/CompilationTests.scala

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class CompilationTests {
7373
aggregateTests(
7474
compileFile("tests/rewrites/rewrites.scala", scala2CompatMode.and("-rewrite", "-indent")),
7575
compileFile("tests/rewrites/rewrites3x.scala", defaultOptions.and("-rewrite", "-source", "future-migration")),
76+
compileFile("tests/rewrites/rewrites3x.scala", defaultOptions.and("-rewrite", "-source", "future-migration", "-Xfatal-warnings")),
7677
compileFile("tests/rewrites/filtering-fors.scala", defaultOptions.and("-rewrite", "-source", "3.2-migration")),
7778
compileFile("tests/rewrites/refutable-pattern-bindings.scala", defaultOptions.and("-rewrite", "-source", "3.2-migration")),
7879
compileFile("tests/rewrites/i8982.scala", defaultOptions.and("-indent", "-rewrite")),

0 commit comments

Comments
 (0)