@@ -701,7 +701,7 @@ object TypeOps:
701
701
// `this`. We perform the following operations to approximate the parameters:
702
702
//
703
703
// 1. Replace type parameters in T with tvars
704
- // 2. Replace `A.this.C` with `A#C` (see tests/patmat/i12681.scala)
704
+ // 2. Replace non-class applied types with a tvar, bounded by its type constructor's underlying type
705
705
// 3. Replace non-reducing MatchType with its bound
706
706
//
707
707
val approximateParent = new TypeMap {
@@ -715,9 +715,6 @@ object TypeOps:
715
715
// then to avoid it failing the <:<
716
716
// we'll approximate by widening to its bounds
717
717
718
- case ThisType (tref : TypeRef ) if ! tref.symbol.isStaticOwner =>
719
- tref
720
-
721
718
case tp : TypeRef if ! tp.symbol.isClass =>
722
719
def lo = LazyRef .of(apply(tp.underlying.loBound))
723
720
def hi = LazyRef .of(apply(tp.underlying.hiBound))
@@ -794,9 +791,12 @@ object TypeOps:
794
791
}
795
792
}
796
793
797
- val inferThisMap = new InferPrefixMap
798
- val tvars = tp1.typeParams.map { tparam => newTypeVar(tparam.paramInfo.bounds) }
799
- val protoTp1 = inferThisMap.apply(tp1).appliedTo(tvars)
794
+ def inferPrefix (tp : Type ) =
795
+ val inferThisMap = new InferPrefixMap
796
+ val tvars = tp.typeParams.map(tparam => newTypeVar(tparam.paramInfo.bounds))
797
+ inferThisMap(tp).appliedTo(tvars)
798
+
799
+ val protoTp1 = inferPrefix(tp1)
800
800
801
801
// If parent contains a reference to an abstract type, then we should
802
802
// refine subtype checking to eliminate abstract types according to
@@ -814,7 +814,7 @@ object TypeOps:
814
814
815
815
if (protoTp1 <:< tp2) instantiate()
816
816
else {
817
- val approxTp2 = approximateParent(tp2)
817
+ val approxTp2 = inferPrefix( approximateParent(tp2) )
818
818
if (protoTp1 <:< approxTp2 || parentQualify(protoTp1, approxTp2)) instantiate()
819
819
else NoType
820
820
}
0 commit comments