Skip to content

Commit a9696ac

Browse files
committed
Under -source:3.3 and below, always use the legacy match type algorithm.
This should improve consistency with the actual earlier compilers, since it means the matching algorithm will be intact. Note that the new behavior of `provablyDisjoint` is always applied, even under `-source:3.3`. This includes using `provablyDisjoint` instead of `provablyEmpty`. So it is still possible that something behaves differently than the actual earlier compilers.
1 parent d5be9ae commit a9696ac

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import Hashable.*
3232
import Uniques.*
3333
import collection.mutable
3434
import config.Config
35+
import config.Feature.sourceVersion
36+
import config.SourceVersion
3537
import annotation.{tailrec, constructorOnly}
3638
import scala.util.hashing.{ MurmurHash3 => hashing }
3739
import config.Printers.{core, typr, matchTypes}
@@ -5120,6 +5122,9 @@ object Types {
51205122
object MatchTypeCaseSpec:
51215123
def analyze(cas: Type)(using Context): MatchTypeCaseSpec =
51225124
cas match
5125+
case cas: HKTypeLambda if !sourceVersion.isAtLeast(SourceVersion.`3.4`) =>
5126+
// Always apply the legacy algorithm under -source:3.3 and below
5127+
LegacyPatMat(cas)
51235128
case cas: HKTypeLambda =>
51245129
val defn.MatchCase(pat, body) = cas.resultType: @unchecked
51255130
val missing = checkCapturesPresent(cas, pat)

tests/neg/6570.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
| does not uniquely determine parameter x in
1515
| case UpperBoundParametricVariant.Cov[x] => Base.N[x]
1616
| The computed bounds for the parameter are:
17-
| x <: Int
17+
| x >: Int
1818
|
1919
| longer explanation available when compiling with `-explain`
2020
-- [E007] Type Mismatch Error: tests/neg/6570.scala:29:29 --------------------------------------------------------------
@@ -98,7 +98,7 @@
9898
| does not uniquely determine parameter t in
9999
| case UpperBoundVariant.Cov[t] => Base.N[t]
100100
| The computed bounds for the parameter are:
101-
| t <: Int
101+
| t >: Int
102102
|
103103
| longer explanation available when compiling with `-explain`
104104
-- [E007] Type Mismatch Error: tests/neg/6570.scala:107:29 -------------------------------------------------------------

0 commit comments

Comments
 (0)