Skip to content

Commit 3459627

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 a26a309 commit 3459627

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
@@ -3915,7 +3915,9 @@ object Types {
39153915
// hence we can replace with U under all variances
39163916
reapply(alias)
39173917
case TypeBounds(lo, hi) =>
3918-
range(atVariance(-1)(reapply(lo)), atVariance(1)(reapply(hi)))
3918+
// If H#T = _ >: S <: U, then for any x in L..H, S <: x.T <: U,
3919+
// hence we can replace with S..U under all variances
3920+
range(atVariance(-variance)(reapply(lo)), reapply(hi))
39193921
case info: SingletonType =>
39203922
// if H#x: y.type, then for any x in L..H, x.type =:= y.type,
39213923
// hence we can replace with y.type under all variances

0 commit comments

Comments
 (0)