@@ -598,18 +598,14 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
598
598
def apply (t : Type ): Type = t match {
599
599
600
600
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
602
602
val exposed =
603
603
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 )
606
606
607
- debug.println(s " $tp exposed to =====> " + exposed)
607
+ debug.println(s " $tp exposed to =====> $ exposed" )
608
608
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)
613
609
case _ =>
614
610
mapOver(t)
615
611
}
@@ -762,51 +758,6 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
762
758
res
763
759
}
764
760
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
-
810
761
def checkExhaustivity (_match : Match ): Unit = {
811
762
val Match (sel, cases) = _match
812
763
val selTyp = sel.tpe.widen.dealias
0 commit comments