@@ -31,7 +31,7 @@ object TypeOps:
3131 /** The type `tp` as seen from prefix `pre` and owner `cls`. See the spec
3232 * for what this means.
3333 */
34- final def asSeenFrom (tp : Type , pre : Type , cls : Symbol )(using Context ): Type = {
34+ final def asSeenFrom (tp : Type , pre : Type , cls : Symbol , approximateUnstablePrefixes : Boolean )(using Context ): Type = {
3535 pre match {
3636 case pre : QualSkolemType =>
3737 // When a selection has an unstable qualifier, the qualifier type gets
@@ -42,7 +42,7 @@ object TypeOps:
4242 // compute the type as seen from the widened prefix, and in the rare
4343 // cases where this leads to an approximated type we recompute it with
4444 // the skolemized prefix. See the i6199* tests for usecases.
45- val widenedAsf = new AsSeenFromMap (pre.info, cls)
45+ val widenedAsf = new AsSeenFromMap (pre.info, cls, approximateUnstablePrefixes )
4646 val ret = widenedAsf.apply(tp)
4747
4848 if widenedAsf.approxCount == 0 then
@@ -52,11 +52,11 @@ object TypeOps:
5252 case _ =>
5353 }
5454
55- new AsSeenFromMap (pre, cls).apply(tp)
55+ new AsSeenFromMap (pre, cls, approximateUnstablePrefixes ).apply(tp)
5656 }
5757
5858 /** The TypeMap handling the asSeenFrom */
59- class AsSeenFromMap (pre : Type , cls : Symbol )(using Context ) extends ApproximatingTypeMap , IdempotentCaptRefMap {
59+ class AsSeenFromMap (pre : Type , cls : Symbol , approximateUnstablePrefixes : Boolean )(using Context ) extends ApproximatingTypeMap , IdempotentCaptRefMap {
6060
6161 /** The number of range approximations in invariant or contravariant positions
6262 * performed by this TypeMap.
@@ -81,7 +81,7 @@ object TypeOps:
8181 case pre : SuperType => toPrefix(pre.thistpe, cls, thiscls)
8282 case _ =>
8383 if (thiscls.derivesFrom(cls) && pre.baseType(thiscls).exists)
84- if (variance <= 0 && ! isLegalPrefix(pre))
84+ if (approximateUnstablePrefixes && variance <= 0 && ! isLegalPrefix(pre))
8585 approxCount += 1
8686 range(defn.NothingType , pre)
8787 else pre
0 commit comments