forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor migration warnings (scala#19102)
Now we have a single way to define migration warning versions and a single place to see all the deprecations we still need to address.
- Loading branch information
Showing
9 changed files
with
122 additions
and
90 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
compiler/src/dotty/tools/dotc/config/MigrationVersion.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package dotty.tools | ||
package dotc | ||
package config | ||
|
||
import SourceVersion.* | ||
import Feature.* | ||
import core.Contexts.Context | ||
|
||
class MigrationVersion(val warnFrom: SourceVersion, val errorFrom: SourceVersion): | ||
assert(warnFrom.ordinal <= errorFrom.ordinal) | ||
def needsPatch(using Context): Boolean = | ||
sourceVersion.isMigrating && sourceVersion.isAtLeast(errorFrom) | ||
|
||
object MigrationVersion: | ||
|
||
val Scala2to3 = MigrationVersion(`3.0`, `3.0`) | ||
|
||
val OverrideValParameter = MigrationVersion(`3.0`, future) | ||
|
||
// we tighten for-comprehension without `case` to error in 3.4, | ||
// but we keep pat-defs as warnings for now ("@unchecked"), | ||
// until we propose an alternative way to assert exhaustivity to the typechecker. | ||
val ForComprehensionPatternWithoutCase = MigrationVersion(`3.2`, `3.4`) | ||
val ForComprehensionUncheckedPathDefs = MigrationVersion(`3.2`, future) | ||
|
||
val NonLocalReturns = MigrationVersion(`3.2`, future) | ||
|
||
val AscriptionAfterPattern = MigrationVersion(`3.3`, future) | ||
|
||
val AlphanumericInfix = MigrationVersion(`3.4`, future) | ||
val RemoveThisQualifier = MigrationVersion(`3.4`, future) | ||
val UninitializedVars = MigrationVersion(`3.4`, future) | ||
val VarargSpliceAscription = MigrationVersion(`3.4`, future) | ||
val WildcardType = MigrationVersion(`3.4`, future) | ||
val WithOperator = MigrationVersion(`3.4`, future) | ||
val FunctionUnderscore = MigrationVersion(`3.4`, future) | ||
|
||
val ImportWildcard = MigrationVersion(future, future) | ||
val ImportRename = MigrationVersion(future, future) | ||
val ParameterEnclosedByParenthesis = MigrationVersion(future, future) | ||
|
||
end MigrationVersion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.