Skip to content

Commit f1b9a05

Browse files
committed
restore accidentally removed code
1 parent 2b99679 commit f1b9a05

File tree

1 file changed

+15
-1
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,18 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
409409
Empty
410410
}
411411

412+
/* Erase a type binding according to erasure semantics in pattern matching */
413+
def erase(tp: Type): Type = tp match {
414+
case tp@AppliedType(tycon, args) => erase(tp.superType)
415+
if (tycon.isRef(defn.ArrayClass)) tp.derivedAppliedType(tycon, args.map(erase))
416+
else tp.derivedAppliedType(tycon, args.map(t => WildcardType(TypeBounds.empty)))
417+
case OrType(tp1, tp2) =>
418+
OrType(erase(tp1), erase(tp2))
419+
case AndType(tp1, tp2) =>
420+
AndType(erase(tp1), erase(tp2))
421+
case _ => tp
422+
}
423+
412424
/** Space of the pattern: unapplySeq(a, b, c: _*)
413425
*/
414426
def projectSeq(pats: List[Tree]): Space = {
@@ -555,7 +567,9 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
555567
// precondition: `tp1` should have the shape `path.Child`, thus `ThisType` is always covariant
556568
val thisTypeMap = new TypeMap {
557569
def apply(t: Type): Type = t match {
558-
case t @ ThisType(tref) if !tref.symbol.isStaticOwner && !tref.symbol.is(Module) =>
570+
case tp @ ThisType(tref) if !tref.symbol.isStaticOwner && !tref.symbol.is(Module) =>
571+
// TODO: stackoverflow here
572+
// newTypeVar(TypeBounds.upper(mapOver(tp.underlying)))
559573
newTypeVar(TypeBounds.upper(mapOver(tref & tref.classSymbol.asClass.givenSelfType)))
560574
case _ =>
561575
mapOver(t)

0 commit comments

Comments
 (0)