Skip to content

Commit 9d1257e

Browse files
committed
Trial 2: use WildcardType for LazyRef in type avoidance
1 parent 6fa9a4c commit 9d1257e

File tree

1 file changed

+2
-28
lines changed

1 file changed

+2
-28
lines changed

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

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,8 @@ object TypeOps:
438438
tp.origin, fromBelow = variance > 0 || variance == 0 && tp.hasLowerBound)(using mapCtx)
439439
val lo1 = apply(lo)
440440
if (lo1 ne lo) lo1 else tp
441+
case tp: LazyRef =>
442+
TypeBounds.empty
441443
case _ =>
442444
mapOver(tp)
443445
}
@@ -462,34 +464,6 @@ object TypeOps:
462464
else
463465
range(defn.NothingType, defn.AnyType)
464466
}
465-
466-
/** Deviation from standard tryWiden:
467-
* - Don't widen F-bounds
468-
*/
469-
override def tryWiden(tp: NamedType, pre: Type): Type = pre.member(tp.name) match {
470-
case d: SingleDenotation =>
471-
val tp1 = d.info.dealiasKeepAnnots
472-
tp1.stripAnnots match {
473-
case TypeAlias(alias) =>
474-
// if H#T = U, then for any x in L..H, x.T =:= U,
475-
// hence we can replace with U under all variances
476-
reapply(alias.rewrapAnnots(tp1))
477-
478-
case tb: TypeBounds =>
479-
// Don't widen F-bounds
480-
val isFBounds = tb.existsPart(p => p.isInstanceOf[LazyRef], forceLazy = false)
481-
if isFBounds then NoType
482-
else expandBounds(tb)
483-
case info: SingletonType =>
484-
// if H#x: y.type, then for any x in L..H, x.type =:= y.type,
485-
// hence we can replace with y.type under all variances
486-
reapply(info)
487-
case _ =>
488-
NoType
489-
}
490-
case _ => NoType
491-
}
492-
493467
}
494468

495469
widenMap(tp)

0 commit comments

Comments
 (0)