Skip to content

Commit

Permalink
Replace usages of MatchType.InDisguise by underlyingMatchType
Browse files Browse the repository at this point in the history
  • Loading branch information
EugeneFlesselle committed Mar 31, 2024
1 parent 796f0eb commit c2030ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ object TypeOps:
defn.MatchCase(simplify(pat, theMap), body)
case tp: AppliedType =>
tp.tycon match
case tycon: TypeRef if tycon.info.isInstanceOf[MatchAlias] =>
case tycon: TypeRef if tp.isMatchAlias =>
isFullyDefined(tp, ForceDegree.all)
case _ =>
val normed = tp.tryNormalize
Expand Down
17 changes: 3 additions & 14 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5151,20 +5151,9 @@ object Types extends TypeUtils {
def apply(bound: Type, scrutinee: Type, cases: List[Type])(using Context): MatchType =
unique(new CachedMatchType(bound, scrutinee, cases))

def thatReducesUsingGadt(tp: Type)(using Context): Boolean = tp match
case MatchType.InDisguise(mt) => mt.reducesUsingGadt
case mt: MatchType => mt.reducesUsingGadt
case _ => false

/** Extractor for match types hidden behind an AppliedType/MatchAlias. */
object InDisguise:
def unapply(tp: AppliedType)(using Context): Option[MatchType] = tp match
case AppliedType(tycon: TypeRef, args) => tycon.info match
case MatchAlias(alias) => alias.applyIfParameterized(args) match
case mt: MatchType => Some(mt)
case _ => None
case _ => None
case _ => None
def thatReducesUsingGadt(tp: Type)(using Context): Boolean = tp.underlyingMatchType match
case mt: MatchType => mt.reducesUsingGadt
case _ => false
}

enum MatchTypeCasePattern:
Expand Down
4 changes: 1 addition & 3 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1841,11 +1841,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
case _ => false
}

val result = pt match {
val result = pt.underlyingMatchType match {
case mt: MatchType if isMatchTypeShaped(mt) =>
typedDependentMatchFinish(tree, sel1, selType, tree.cases, mt)
case MatchType.InDisguise(mt) if isMatchTypeShaped(mt) =>
typedDependentMatchFinish(tree, sel1, selType, tree.cases, mt)
case _ =>
typedMatchFinish(tree, sel1, selType, tree.cases, pt)
}
Expand Down

0 comments on commit c2030ea

Please sign in to comment.