@@ -409,6 +409,18 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
409
409
Empty
410
410
}
411
411
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
+
412
424
/** Space of the pattern: unapplySeq(a, b, c: _*)
413
425
*/
414
426
def projectSeq (pats : List [Tree ]): Space = {
@@ -555,7 +567,9 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
555
567
// precondition: `tp1` should have the shape `path.Child`, thus `ThisType` is always covariant
556
568
val thisTypeMap = new TypeMap {
557
569
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)))
559
573
newTypeVar(TypeBounds .upper(mapOver(tref & tref.classSymbol.asClass.givenSelfType)))
560
574
case _ =>
561
575
mapOver(t)
0 commit comments