Skip to content

Commit

Permalink
Under -source:3.3 and below, always use the legacy match type algorithm.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sjrd committed Nov 24, 2023
1 parent d5be9ae commit a9696ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import Hashable.*
import Uniques.*
import collection.mutable
import config.Config
import config.Feature.sourceVersion
import config.SourceVersion
import annotation.{tailrec, constructorOnly}
import scala.util.hashing.{ MurmurHash3 => hashing }
import config.Printers.{core, typr, matchTypes}
Expand Down Expand Up @@ -5120,6 +5122,9 @@ object Types {
object MatchTypeCaseSpec:
def analyze(cas: Type)(using Context): MatchTypeCaseSpec =
cas match
case cas: HKTypeLambda if !sourceVersion.isAtLeast(SourceVersion.`3.4`) =>
// Always apply the legacy algorithm under -source:3.3 and below
LegacyPatMat(cas)
case cas: HKTypeLambda =>
val defn.MatchCase(pat, body) = cas.resultType: @unchecked
val missing = checkCapturesPresent(cas, pat)
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/6570.check
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| does not uniquely determine parameter x in
| case UpperBoundParametricVariant.Cov[x] => Base.N[x]
| The computed bounds for the parameter are:
| x <: Int
| x >: Int
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/6570.scala:29:29 --------------------------------------------------------------
Expand Down Expand Up @@ -98,7 +98,7 @@
| does not uniquely determine parameter t in
| case UpperBoundVariant.Cov[t] => Base.N[t]
| The computed bounds for the parameter are:
| t <: Int
| t >: Int
|
| longer explanation available when compiling with `-explain`
-- [E007] Type Mismatch Error: tests/neg/6570.scala:107:29 -------------------------------------------------------------
Expand Down

0 comments on commit a9696ac

Please sign in to comment.