Skip to content

Commit 6b37935

Browse files
committed
apply code review suggestions
1 parent c5c1d60 commit 6b37935

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

compiler/src/dotty/tools/dotc/config/Feature.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ object Feature:
9090
*/
9191
def warnOnMigration(msg: Message, pos: SrcPos, version: SourceVersion)(using Context): Boolean =
9292
if sourceVersion.isMigrating && sourceVersion.stable == version
93-
|| (version == `3.0` || version == `3.1` || version == `3.2`) && migrateTo3
93+
|| (version == `3.0` || version == `3.1`) && migrateTo3
9494
then
9595
report.migrationWarning(msg, pos)
9696
true

compiler/src/dotty/tools/dotc/config/SourceVersion.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ enum SourceVersion:
1717

1818
def isAtLeast(v: SourceVersion) = stable.ordinal >= v.ordinal
1919

20+
def isBetween(low: SourceVersion, high: SourceVersion): Boolean =
21+
require(low.ordinal < high.ordinal)
22+
isAtLeast(low) && stable.ordinal <= high.ordinal
23+
2024
object SourceVersion extends Property.Key[SourceVersion]:
2125
def defaultSourceVersion = `3.2`
2226

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
16191619
tree.selector.removeAttachment(desugar.CheckIrrefutable) match {
16201620
case Some(checkMode) if !sel.tpe.hasAnnotation(defn.UncheckedAnnot) =>
16211621
val isPatDef = checkMode == desugar.MatchCheck.IrrefutablePatDef
1622-
if !checkIrrefutable(sel, pat, isPatDef) && sourceVersion.isAtLeast(`3.2`) && sourceVersion.isMigrating then
1622+
if !checkIrrefutable(sel, pat, isPatDef)
1623+
&& sourceVersion.isMigrating
1624+
&& sourceVersion.isBetween(`3.2`, `future`)
1625+
then
16231626
if isPatDef then uncheckedBrackets(tree.selector) match
16241627
case None =>
16251628
patch(Span(tree.selector.span.end), ": @unchecked")

docs/_docs/reference/language-versions/source-compatibility.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,24 @@ movedTo: https://docs.scala-lang.org/scala3/reference/language-versions.html
66

77
Scala 3 does NOT guarantee source compatibility between different minor language versions (e.g. some syntax valid in 3.x might get deprecated and then phased out in 3.y for y > x). There are also some syntax structures that were valid in Scala 2 but are not anymore in Scala 3. However the compiler provides a possibility to specify the desired version of syntax used in a particular file or globally for a run of the compiler to make migration between versions easier.
88

9-
The default Scala language syntax version currently supported by the Dotty compiler is [`3.0`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$3/0$.html). There are also other language versions that can be specified instead:
9+
The default Scala language syntax version currently supported by the Dotty compiler is [`3.2`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$3/2$.html). There are also other language versions that can be specified instead:
1010

11-
- [`3.0-migration`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$3/0-migration$.html): Same as `3.0` but with a Scala 2 compatibility mode that helps moving Scala 2.13 sources over to Scala 3. In particular, it
11+
- [`3.0-migration`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$3/0-migration$.html): Same as
12+
`3.0` and `3.1`, but with a Scala 2 compatibility mode that helps moving Scala 2.13 sources over to Scala 3. In particular, it
1213

1314
- flags some Scala 2 constructs that are disallowed in Scala 3 as migration warnings instead of hard errors,
1415
- changes some rules to be more lenient and backwards compatible with Scala 2.13
1516
- gives some additional warnings where the semantics has changed between Scala 2.13 and 3.0
1617
- in conjunction with `-rewrite`, offer code rewrites from Scala 2.13 to 3.0.
1718

18-
- [`future`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$future$.html): A preview of changes introduced in the next versions after 3.0. In the doc pages here we refer to the language version with these changes as `3.1`, but it might be that some of these changes will be rolled out in later `3.x` versions.
19-
19+
- [`3.0`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$3/0$.html), [`3.1`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$3/1$.html): the default set of features included in scala versions `3.0.0` to `3.1.3`.
20+
- [`3.2`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$3/2$.html): the same as `3.0` and `3.1`, but [stricter pattern bindings](https://docs.scala-lang.org/scala3/reference/changed-features/pattern-bindings.html) are now enabled, producing warnings for refutable patterns. These warnings can be silenced to achieve the same runtime behavior, but in `future` they become errors and refutable patterns will not compile.
21+
- [`3.2-migration`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$3/2-migration$.html): the same as `3.2`, but can automatically
22+
migrate sources using the `-rewrite` flag.
23+
- [`future`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$future$.html): A preview of changes introduced in the next versions after the default version, but it might be that some of these changes will be rolled out in later `3.x` versions.
2024
Some Scala 2 specific idioms will be dropped in this version. The feature set supported by this version will be refined over time as we approach its release.
2125

22-
- [`future-migration`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$future-migration$.html): Same as `future` but with additional helpers to migrate from `3.0`. Similarly to the helpers available under `3.0-migration`, these include migration warnings and optional rewrites.
26+
- [`future-migration`](https://scala-lang.org/api/3.x/scala/runtime/stdLibPatches/language$$future-migration$.html): Same as `future` but with additional helpers to migrate from the default version. Similarly to the helpers available under `3.0-migration`, these include migration warnings and optional rewrites.
2327

2428
There are two ways to specify a language version :
2529

0 commit comments

Comments
 (0)