Skip to content

Commit 253f505

Browse files
committed
address review and remove expose completely
1 parent 74f0c8f commit 253f505

File tree

1 file changed

+4
-53
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+4
-53
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -598,18 +598,14 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
598598
def apply(t: Type): Type = t match {
599599

600600
case tp: TypeRef if tp.symbol.is(TypeParam) && tp.underlying.isInstanceOf[TypeBounds] =>
601-
// See tests/patmat/gadt.scala tests/patmat/exhausting.scala
601+
// See tests/patmat/gadt.scala tests/patmat/exhausting.scala tests/patmat/t9657.scala
602602
val exposed =
603603
if (variance == 0) newTypeVar(tp.underlying.bounds)
604-
else if (variance == 1) expose(tp, true)
605-
else expose(tp, false)
604+
else if (variance == 1) mapOver(tp.underlying.hiBound)
605+
else mapOver(tp.underlying.loBound)
606606

607-
debug.println(s"$tp exposed to =====> " + exposed)
607+
debug.println(s"$tp exposed to =====> $exposed")
608608
exposed
609-
case tp: RefinedType if tp.refinedInfo.isInstanceOf[TypeBounds] =>
610-
// Ideally, we would expect type inference to do the job
611-
// Check tests/patmat/t9657.scala
612-
expose(tp)
613609
case _ =>
614610
mapOver(t)
615611
}
@@ -762,51 +758,6 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
762758
res
763759
}
764760

765-
766-
/** Eliminate reference to type parameters in refinements
767-
*
768-
* A <: X :> Y B <: U :> V M { type T <: A :> B } ~~> M { type T <: X :> V }
769-
*/
770-
def expose(tp: Type, up: Boolean = true): Type = tp match {
771-
case tp: AppliedType =>
772-
tp.derivedAppliedType(expose(tp.tycon, up), tp.args.map(expose(_, up)))
773-
774-
case tp: TypeAlias =>
775-
val hi = expose(tp.alias, up)
776-
val lo = expose(tp.alias, up)
777-
778-
if (hi =:= lo)
779-
tp.derivedTypeAlias(hi)
780-
else
781-
tp.derivedTypeBounds(lo, hi)
782-
783-
case tp @ TypeBounds(lo, hi) =>
784-
tp.derivedTypeBounds(expose(lo, false), expose(hi, true))
785-
786-
case tp: RefinedType =>
787-
tp.derivedRefinedType(
788-
expose(tp.parent),
789-
tp.refinedName,
790-
expose(tp.refinedInfo, up)
791-
)
792-
case tp: TypeProxy =>
793-
tp.underlying match {
794-
case TypeBounds(lo, hi) =>
795-
expose(if (up) hi else lo, up)
796-
case _ =>
797-
tp
798-
}
799-
800-
case OrType(tp1, tp2) =>
801-
OrType(expose(tp1, up), expose(tp2, up))
802-
803-
case AndType(tp1, tp2) =>
804-
AndType(expose(tp1, up), expose(tp2, up))
805-
806-
case _ => tp
807-
}
808-
809-
810761
def checkExhaustivity(_match: Match): Unit = {
811762
val Match(sel, cases) = _match
812763
val selTyp = sel.tpe.widen.dealias

0 commit comments

Comments
 (0)