@@ -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
//
706
706
val approximateParent = new TypeMap {
707
707
val boundTypeParams = util.HashMap [TypeRef , TypeVar ]()
@@ -710,9 +710,6 @@ object TypeOps:
710
710
case _ : MatchType =>
711
711
tp // break cycles
712
712
713
- case ThisType (tref : TypeRef ) if ! tref.symbol.isStaticOwner =>
714
- tref
715
-
716
713
case tp : TypeRef if ! tp.symbol.isClass =>
717
714
def lo = LazyRef .of(apply(tp.underlying.loBound))
718
715
def hi = LazyRef .of(apply(tp.underlying.hiBound))
@@ -789,9 +786,12 @@ object TypeOps:
789
786
}
790
787
}
791
788
792
- val inferThisMap = new InferPrefixMap
793
- val tvars = tp1.typeParams.map { tparam => newTypeVar(tparam.paramInfo.bounds) }
794
- val protoTp1 = inferThisMap.apply(tp1).appliedTo(tvars)
789
+ def inferPrefix (tp : Type ) =
790
+ val inferThisMap = new InferPrefixMap
791
+ val tvars = tp.typeParams.map(tparam => newTypeVar(tparam.paramInfo.bounds))
792
+ inferThisMap(tp).appliedTo(tvars)
793
+
794
+ val protoTp1 = inferPrefix(tp1)
795
795
796
796
// If parent contains a reference to an abstract type, then we should
797
797
// refine subtype checking to eliminate abstract types according to
@@ -809,7 +809,7 @@ object TypeOps:
809
809
810
810
if (protoTp1 <:< tp2) instantiate()
811
811
else {
812
- val approxTp2 = approximateParent(tp2)
812
+ val approxTp2 = inferPrefix( approximateParent(tp2) )
813
813
if (protoTp1 <:< approxTp2 || parentQualify(protoTp1, approxTp2)) instantiate()
814
814
else NoType
815
815
}
0 commit comments