Skip to content

Commit a29c082

Browse files
committed
introduce gradualErrorOrMigrationWarning
1 parent 5c19bd0 commit a29c082

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,13 @@ object report:
6868
if ctx.settings.YdebugTypeError.value then ex.printStackTrace()
6969

7070
def errorOrMigrationWarning(msg: Message, pos: SrcPos = NoSourcePosition, from: SourceVersion)(using Context): Unit =
71-
if sourceVersion.isAtLeast(from) then
72-
if sourceVersion.isMigrating && sourceVersion.ordinal <= from.ordinal then migrationWarning(msg, pos)
73-
else error(msg, pos)
71+
gradualErrorOrMigrationWarning(msg, pos, from, from)
72+
73+
def gradualErrorOrMigrationWarning(msg: Message, pos: SrcPos = NoSourcePosition, warnFrom: SourceVersion, errorFrom: SourceVersion)(using Context): Unit =
74+
if sourceVersion.isAtLeast(warnFrom) then
75+
if sourceVersion.isMigrating && sourceVersion.ordinal <= errorFrom.ordinal then migrationWarning(msg, pos)
76+
else if sourceVersion.isAtLeast(errorFrom) then error(msg, pos)
77+
else warning(msg, pos)
7478

7579
def restrictionError(msg: Message, pos: SrcPos = NoSourcePosition)(using Context): Unit =
7680
error(msg.mapMsg("Implementation restriction: " + _), pos)

0 commit comments

Comments
 (0)