File tree 1 file changed +12
-4
lines changed
compiler/src/dotty/tools/dotc/core
1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1007,10 +1007,18 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1007
1007
case tp1 : MatchType =>
1008
1008
def compareMatch = tp2 match {
1009
1009
case tp2 : MatchType =>
1010
- val scrutinee1 = tp1.scrutinee match
1011
- case tp : TermRef if tp.symbol.is(InlineProxy ) => tp.info
1012
- case tp => tp.widenSkolem
1013
- isSameType(scrutinee1, tp2.scrutinee) &&
1010
+ // we allow a small number of scrutinee types to be widened:
1011
+ // * skolems, which may appear from type avoidance, but are widened in the inferred result type
1012
+ // * inline proxies, which is inlining's solution to the same problem
1013
+ def widenScrutinee (scrutinee1 : Type ) = scrutinee1 match
1014
+ case tp : TermRef if tp.symbol.is(InlineProxy ) => tp.info
1015
+ case tp => tp.widenSkolem
1016
+ def checkScrutinee (scrutinee1 : Type ): Boolean =
1017
+ isSameType(scrutinee1, tp2.scrutinee) || {
1018
+ val widenScrutinee1 = widenScrutinee(scrutinee1)
1019
+ (widenScrutinee1 ne scrutinee1) && checkScrutinee(widenScrutinee1)
1020
+ }
1021
+ checkScrutinee(tp1.scrutinee) &&
1014
1022
tp1.cases.corresponds(tp2.cases)(isSubType)
1015
1023
case _ => false
1016
1024
}
You can’t perform that action at this time.
0 commit comments