Skip to content

Commit

Permalink
Disable legacy match types under source version >= 3.4.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjrd committed Aug 10, 2023
1 parent 111e021 commit f0339b3
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ private sealed trait YSettings:
val YprintPos: Setting[Boolean] = BooleanSetting("-Yprint-pos", "Show tree positions.")
val YprintPosSyms: Setting[Boolean] = BooleanSetting("-Yprint-pos-syms", "Show symbol definitions positions.")
val YnoDeepSubtypes: Setting[Boolean] = BooleanSetting("-Yno-deep-subtypes", "Throw an exception on deep subtyping call stacks.")
val YnoLegacyMatchTypes: Setting[Boolean] = BooleanSetting("-Yno-legacy-match-types", "Refuse to reduce match types with legacy/unspecified patterns")
val YnoPatmatOpt: Setting[Boolean] = BooleanSetting("-Yno-patmat-opt", "Disable all pattern matching optimizations.")
val YplainPrinter: Setting[Boolean] = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
val YprintSyms: Setting[Boolean] = BooleanSetting("-Yprint-syms", "When printing trees print info in symbols instead of corresponding info in trees.")
Expand Down
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import TypeOps.refineUsingParent
import collection.mutable
import util.{Stats, NoSourcePosition, EqHashMap}
import config.Config
import config.Feature.migrateTo3
import config.Feature.{migrateTo3, sourceVersion}
import config.Printers.{subtyping, gadts, matchTypes, noPrinter}
import config.SourceVersion
import TypeErasure.{erasedLub, erasedGlb}
import TypeApplications._
import Variances.{Variance, variancesConform}
Expand Down Expand Up @@ -3455,7 +3456,7 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
MatchResult.Stuck

def recur(remaining: List[MatchTypeCaseSpec]): Type = remaining match
case (cas: MatchTypeCaseSpec.LegacyPatMat) :: _ if ctx.settings.YnoLegacyMatchTypes.value =>
case (cas: MatchTypeCaseSpec.LegacyPatMat) :: _ if sourceVersion.isAtLeast(SourceVersion.`3.4`) =>
val errorText = MatchTypeTrace.legacyPatternText(scrut, cas)
ErrorType(reporting.MatchTypeLegacyPattern(errorText))
case cas :: remaining1 =>
Expand Down
1 change: 0 additions & 1 deletion compiler/test/dotty/tools/vulpix/TestConfiguration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ object TestConfiguration {
val checkOptions = Array(
// "-Yscala2-unpickler", s"${Properties.scalaLibrary}",
"-Yno-deep-subtypes",
"-Yno-legacy-match-types",
"-Yno-double-bindings",
"-Yforce-sbt-phases",
"-Xsemanticdb",
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/6570.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

object Base {
trait Trait1
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/10747-shapeless-min.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

trait Monoidal {
type to[_] <: Tuple
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/8647.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

final class Two[A, B]()

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/9757.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

type RemoveFrom[R, A] = R match {
case A & newType => newType
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/i10242.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

// https://github.com/lampepfl/dotty/issues/10242
type Foo[A, B <: A] = A
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/i15155.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

import scala.reflect.ClassTag
// https://github.com/json4s/json4s/blob/355d8751391773e0d79d04402a4f9fb7bfc684ec/ext/src/main/scala-3/org/json4s/ext/package.scala#L4-L8
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/i16706.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

import scala.deriving.Mirror
import scala.reflect.ClassTag
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/i17395.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

trait TC[T]

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/i5625b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

object Test {

Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/tasty-simplified/quoted_2.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Yno-legacy-match-types:false
// scalac: -source:3.3

import Macros.simplified

Expand Down

0 comments on commit f0339b3

Please sign in to comment.