File tree 4 files changed +9
-2
lines changed
compiler/src/dotty/tools/dotc
4 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -5214,6 +5214,10 @@ object Types extends TypeUtils {
5214
5214
def thatReducesUsingGadt (tp : Type )(using Context ): Boolean = tp.underlyingMatchType match
5215
5215
case mt : MatchType => mt.reducesUsingGadt
5216
5216
case _ => false
5217
+
5218
+ object Normalizing :
5219
+ def unapply (tp : Type )(using Context ): Option [Type ] =
5220
+ Some (tp.tryNormalize).filter(_.exists)
5217
5221
}
5218
5222
5219
5223
enum MatchTypeCasePattern :
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ object TypeTestsCasts {
135
135
def recur (X : Type , P : Type ): String = trace(s " recur( ${X .show}, ${P .show}) " ) {
136
136
(X <:< P ) ||| P .dealias.match
137
137
case _ : SingletonType => " "
138
- case tp if tp.isMatchAlias => recur(X , tp.tryNormalize )
138
+ case MatchType . Normalizing (tp) => recur(X , tp)
139
139
case _ : TypeProxy
140
140
if isAbstract(P ) => i " it refers to an abstract type member or type parameter "
141
141
case defn.ArrayOf (tpT) =>
Original file line number Diff line number Diff line change @@ -23,3 +23,5 @@ type MS = Matcher[S]
23
23
24
24
type S2 = MS
25
25
type MS2 = Matcher [S2 ]
26
+
27
+ type Mstuck = Matcher [Nothing ]
Original file line number Diff line number Diff line change 1
- //> using options -Xfatal-warnings -deprecation -feature
2
1
3
2
@ main def main = {
4
3
println(patternMatch[String ](" abc" ))
19
18
if s.isInstanceOf [S2 ] then Some [s.type & Matcher [String ]](s.asInstanceOf [s.type & Matcher [String ]]) else None }))
20
19
println(patternMatch[String ](" abc" )(using (s : Any ) => {
21
20
if s.isInstanceOf [MS2 ] then Some [s.type & Matcher [String ]](s.asInstanceOf [s.type & Matcher [String ]]) else None }))
21
+ println(patternMatch[String ](" abc" )(using (s : Any ) => {
22
+ if s.isInstanceOf [Mstuck ] then Some [s.type & Matcher [String ]](s.asInstanceOf [s.type & Matcher [String ]]) else None })) // warn
22
23
}
You can’t perform that action at this time.
0 commit comments