Skip to content

Commit 8c754e6

Browse files
committed
Disable legacy match types under source version >= 3.4.
Instead of through the flag -Yno-legacy-match-types. Codebases that require legacy match types will need to use `-source:3.3` to compile from now on.
1 parent 2e4460c commit 8c754e6

File tree

13 files changed

+13
-14
lines changed

13 files changed

+13
-14
lines changed

Diff for: compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ private sealed trait YSettings:
347347
val YprintPos: Setting[Boolean] = BooleanSetting("-Yprint-pos", "Show tree positions.")
348348
val YprintPosSyms: Setting[Boolean] = BooleanSetting("-Yprint-pos-syms", "Show symbol definitions positions.")
349349
val YnoDeepSubtypes: Setting[Boolean] = BooleanSetting("-Yno-deep-subtypes", "Throw an exception on deep subtyping call stacks.")
350-
val YnoLegacyMatchTypes: Setting[Boolean] = BooleanSetting("-Yno-legacy-match-types", "Refuse to reduce match types with legacy/unspecified patterns")
351350
val YnoPatmatOpt: Setting[Boolean] = BooleanSetting("-Yno-patmat-opt", "Disable all pattern matching optimizations.")
352351
val YplainPrinter: Setting[Boolean] = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
353352
val YprintSyms: Setting[Boolean] = BooleanSetting("-Yprint-syms", "When printing trees print info in symbols instead of corresponding info in trees.")

Diff for: compiler/src/dotty/tools/dotc/core/TypeComparer.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import TypeOps.refineUsingParent
1010
import collection.mutable
1111
import util.{Stats, NoSourcePosition, EqHashMap}
1212
import config.Config
13-
import config.Feature.migrateTo3
13+
import config.Feature.{migrateTo3, sourceVersion}
1414
import config.Printers.{subtyping, gadts, matchTypes, noPrinter}
15+
import config.SourceVersion
1516
import TypeErasure.{erasedLub, erasedGlb}
1617
import TypeApplications._
1718
import Variances.{Variance, variancesConform}
@@ -3455,7 +3456,7 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
34553456
MatchResult.Stuck
34563457

34573458
def recur(remaining: List[MatchTypeCaseSpec]): Type = remaining match
3458-
case (cas: MatchTypeCaseSpec.LegacyPatMat) :: _ if ctx.settings.YnoLegacyMatchTypes.value =>
3459+
case (cas: MatchTypeCaseSpec.LegacyPatMat) :: _ if sourceVersion.isAtLeast(SourceVersion.`3.4`) =>
34593460
val errorText = MatchTypeTrace.legacyPatternText(scrut, cas)
34603461
ErrorType(reporting.MatchTypeLegacyPattern(errorText))
34613462
case cas :: remaining1 =>

Diff for: compiler/test/dotty/tools/vulpix/TestConfiguration.scala

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ object TestConfiguration {
1919
val checkOptions = Array(
2020
// "-Yscala2-unpickler", s"${Properties.scalaLibrary}",
2121
"-Yno-deep-subtypes",
22-
"-Yno-legacy-match-types",
2322
"-Yno-double-bindings",
2423
"-Yforce-sbt-phases",
2524
"-Xsemanticdb",

Diff for: tests/neg/6570.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
object Base {
44
trait Trait1

Diff for: tests/pos/10747-shapeless-min.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
trait Monoidal {
44
type to[_] <: Tuple

Diff for: tests/pos/8647.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
final class Two[A, B]()
44

Diff for: tests/pos/9757.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
type RemoveFrom[R, A] = R match {
44
case A & newType => newType

Diff for: tests/pos/i10242.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
// https://github.com/lampepfl/dotty/issues/10242
44
type Foo[A, B <: A] = A

Diff for: tests/pos/i15155.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
import scala.reflect.ClassTag
44
// https://github.com/json4s/json4s/blob/355d8751391773e0d79d04402a4f9fb7bfc684ec/ext/src/main/scala-3/org/json4s/ext/package.scala#L4-L8

Diff for: tests/pos/i16706.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
import scala.deriving.Mirror
44
import scala.reflect.ClassTag

Diff for: tests/pos/i17395.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
trait TC[T]
44

Diff for: tests/pos/i5625b.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
object Test {
44

Diff for: tests/run-macros/tasty-simplified/quoted_2.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// scalac: -Yno-legacy-match-types:false
1+
// scalac: -source:3.3
22

33
import Macros.simplified
44

0 commit comments

Comments
 (0)