Skip to content

Commit 815f27e

Browse files
committed
Simplifications
- Use range instead of Range in AsSeenFromMap#apply. We needed Range before because we did an incorrect variance computation for NamedTypes. - Refine derivedSelect
1 parent 97eb221 commit 815f27e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
4040
case pre: SuperType => toPrefix(pre.thistpe, cls, thiscls)
4141
case _ =>
4242
if (thiscls.derivesFrom(cls) && pre.baseTypeRef(thiscls).exists)
43-
if (variance <= 0 && !isLegalPrefix(pre)) Range(pre.bottomType, pre)
43+
if (variance <= 0 && !isLegalPrefix(pre)) range(pre.bottomType, pre)
4444
else pre
4545
else if ((pre.termSymbol is Package) && !(thiscls is Package))
4646
toPrefix(pre.select(nme.PACKAGE), cls, thiscls)

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3917,7 +3917,9 @@ object Types {
39173917
// hence we can replace with U under all variances
39183918
reapply(alias)
39193919
case TypeBounds(lo, hi) =>
3920-
range(atVariance(-1)(reapply(lo)), atVariance(1)(reapply(hi)))
3920+
// If H#T = _ >: S <: U, then for any x in L..H, S <: x.T <: U,
3921+
// hence we can replace with S..U under all variances
3922+
range(atVariance(-variance)(reapply(lo)), reapply(hi))
39213923
case info: SingletonType =>
39223924
// if H#x: y.type, then for any x in L..H, x.type =:= y.type,
39233925
// hence we can replace with y.type under all variances

0 commit comments

Comments
 (0)