Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e248076

Browse files
committedNov 24, 2023
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 a5e83b9 commit e248076

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
@@ -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}
@@ -5119,6 +5121,9 @@ object Types extends TypeUtils {
51195121
object MatchTypeCaseSpec:
51205122
def analyze(cas: Type)(using Context): MatchTypeCaseSpec =
51215123
cas match
5124+
case cas: HKTypeLambda if !sourceVersion.isAtLeast(SourceVersion.`3.4`) =>
5125+
// Always apply the legacy algorithm under -source:3.3 and below
5126+
LegacyPatMat(cas)
51225127
case cas: HKTypeLambda =>
51235128
val defn.MatchCase(pat, body) = cas.resultType: @unchecked
51245129
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)
Please sign in to comment.