@@ -1571,21 +1571,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
15711571 val selType = rawSelectorTpe match
15721572 case c : ConstantType if tree.isInline => c
15731573 case otherTpe => otherTpe.widen
1574- /** Extractor for match types hidden behind an AppliedType/MatchAlias */
1575- object MatchTypeInDisguise {
1576- def unapply (tp : AppliedType )(using Context ): Option [MatchType ] = tp match {
1577- case AppliedType (tycon : TypeRef , args) =>
1578- tycon.info match {
1579- case MatchAlias (alias) =>
1580- alias.applyIfParameterized(args) match {
1581- case mt : MatchType => Some (mt)
1582- case _ => None
1583- }
1584- case _ => None
1585- }
1586- case _ => None
1587- }
1588- }
15891574
15901575 /** Does `tree` has the same shape as the given match type?
15911576 * We only support typed patterns with empty guards, but
@@ -1618,7 +1603,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
16181603 }
16191604
16201605 val result = pt match {
1621- case MatchTypeInDisguise (mt) if isMatchTypeShaped(mt) =>
1606+ case MatchType . InDisguise (mt) if isMatchTypeShaped(mt) =>
16221607 typedDependentMatchFinish(tree, sel1, selType, tree.cases, mt)
16231608 case _ =>
16241609 typedMatchFinish(tree, sel1, selType, tree.cases, pt)
@@ -3007,7 +2992,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
30072992 || tree.isDef // ... unless tree is a definition
30082993 then
30092994 interpolateTypeVars(tree, pt, locked)
3010- tree.overwriteType(tree.tpe.simplified)
2995+ val simplified = tree.tpe.simplified
2996+ if ! MatchType .thatReducesUsingGadt(tree.tpe) then // needs a GADT cast. i15743
2997+ tree.overwriteType(simplified)
30112998 tree
30122999
30133000 protected def makeContextualFunction (tree : untpd.Tree , pt : Type )(using Context ): Tree = {
0 commit comments