Skip to content

Commit c8b4da8

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 16cf4f2 commit c8b4da8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import Hashable.*
3030
import Uniques.*
3131
import collection.mutable
3232
import config.Config
33+
import config.Feature.sourceVersion
34+
import config.SourceVersion
3335
import annotation.{tailrec, constructorOnly}
3436
import scala.util.hashing.{ MurmurHash3 => hashing }
3537
import config.Printers.{core, typr, matchTypes}
@@ -5117,6 +5119,9 @@ object Types extends TypeUtils {
51175119
object MatchTypeCaseSpec:
51185120
def analyze(cas: Type)(using Context): MatchTypeCaseSpec =
51195121
cas match
5122+
case cas: HKTypeLambda if !sourceVersion.isAtLeast(SourceVersion.`3.4`) =>
5123+
// Always apply the legacy algorithm under -source:3.3 and below
5124+
LegacyPatMat(cas)
51205125
case cas: HKTypeLambda =>
51215126
val defn.MatchCase(pat, body) = cas.resultType: @unchecked
51225127
val missing = checkCapturesPresent(cas, pat)

tests/neg/6570.check

+2-2
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)