Skip to content

Commit f8a7c5d

Browse files
committed
Don't report warning in migration when rewriting
1 parent a569057 commit f8a7c5d

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ object report:
8282

8383
def errorOrMigrationWarning(msg: Message, pos: SrcPos, from: SourceVersion)(using Context): Unit =
8484
if sourceVersion.isAtLeast(from) then
85-
if sourceVersion.isMigrating && sourceVersion.ordinal <= from.ordinal then migrationWarning(msg, pos)
85+
if sourceVersion.isMigrating && sourceVersion.ordinal <= from.ordinal then
86+
if ctx.settings.rewrite.value.isEmpty then migrationWarning(msg, pos)
8687
else error(msg, pos)
8788

8889
def gradualErrorOrMigrationWarning(msg: Message, pos: SrcPos, warnFrom: SourceVersion, errorFrom: SourceVersion)(using Context): Unit =

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

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class CompilationTests {
7575
aggregateTests(
7676
compileFile("tests/rewrites/rewrites.scala", scala2CompatMode.and("-rewrite", "-indent")),
7777
compileFile("tests/rewrites/rewrites3x.scala", defaultOptions.and("-rewrite", "-source", "future-migration")),
78+
compileFile("tests/rewrites/rewrites3x.scala", defaultOptions.and("-rewrite", "-source", "future-migration", "-Xfatal-warnings")),
7879
compileFile("tests/rewrites/filtering-fors.scala", defaultOptions.and("-rewrite", "-source", "3.2-migration")),
7980
compileFile("tests/rewrites/refutable-pattern-bindings.scala", defaultOptions.and("-rewrite", "-source", "3.2-migration")),
8081
compileFile("tests/rewrites/i8982.scala", defaultOptions.and("-indent", "-rewrite")),

0 commit comments

Comments
 (0)