Skip to content

Commit 0000d23

Browse files
Only replace *new* errors by warnings under -migration
This makes `errorOrMigrationWarning` monotonic from the sourceVersion onto ok < warn < error For example, ForComprehensionPatternWithoutCase: - became an error in 3.4, - was hence a warning in 3.4-migration, - but it should still be an error in 3.5-migration.
1 parent 5da1855 commit 0000d23

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: compiler/src/dotty/tools/dotc/report.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ object report:
9999

100100
def errorOrMigrationWarning(msg: Message, pos: SrcPos, migrationVersion: MigrationVersion)(using Context): Unit =
101101
if sourceVersion.isAtLeast(migrationVersion.errorFrom) then
102-
if !sourceVersion.isMigrating then error(msg, pos)
102+
if sourceVersion != migrationVersion.errorFrom.prevMigrating then error(msg, pos)
103103
else if ctx.settings.rewrite.value.isEmpty then migrationWarning(msg, pos)
104104
else if sourceVersion.isAtLeast(migrationVersion.warnFrom) then warning(msg, pos)
105105

Diff for: tests/neg/migrate-once.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//> using options -source:3.5-migration
2+
3+
object Test:
4+
for Some(x) <- Seq(Option(1)) yield x // error
5+
// was warn before changes, but should warn only until 3.4-migration

0 commit comments

Comments
 (0)