@@ -31,7 +31,7 @@ object TypeOps:
31
31
/** The type `tp` as seen from prefix `pre` and owner `cls`. See the spec
32
32
* for what this means.
33
33
*/
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 = {
35
35
pre match {
36
36
case pre : QualSkolemType =>
37
37
// When a selection has an unstable qualifier, the qualifier type gets
@@ -42,7 +42,7 @@ object TypeOps:
42
42
// compute the type as seen from the widened prefix, and in the rare
43
43
// cases where this leads to an approximated type we recompute it with
44
44
// 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 )
46
46
val ret = widenedAsf.apply(tp)
47
47
48
48
if widenedAsf.approxCount == 0 then
@@ -52,11 +52,11 @@ object TypeOps:
52
52
case _ =>
53
53
}
54
54
55
- new AsSeenFromMap (pre, cls).apply(tp)
55
+ new AsSeenFromMap (pre, cls, approximateUnstablePrefixes ).apply(tp)
56
56
}
57
57
58
58
/** 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 {
60
60
61
61
/** The number of range approximations in invariant or contravariant positions
62
62
* performed by this TypeMap.
@@ -81,7 +81,7 @@ object TypeOps:
81
81
case pre : SuperType => toPrefix(pre.thistpe, cls, thiscls)
82
82
case _ =>
83
83
if (thiscls.derivesFrom(cls) && pre.baseType(thiscls).exists)
84
- if (variance <= 0 && ! isLegalPrefix(pre))
84
+ if (approximateUnstablePrefixes && variance <= 0 && ! isLegalPrefix(pre))
85
85
approxCount += 1
86
86
range(defn.NothingType , pre)
87
87
else pre
0 commit comments