Skip to content

Commit 48c9eab

Browse files
committed
Prevent cyclic instantiations
A cyclic instantiation was observed for neg/byname-implicits-11 when doing an implicit search for a hidden implicits addendum. It arose from a subtype check Foo[Foo[T]] <: Foo[T] where `Foo` is nonvariant and T is an instantiatable TypeParamRef.
1 parent c707fe2 commit 48c9eab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ trait ConstraintHandling[AbstractContext] {
8585

8686
val oldBounds @ TypeBounds(lo, hi) = constraint.nonParamBounds(param)
8787
val equalBounds = isUpper && (lo eq bound) || !isUpper && (bound eq hi)
88-
if (equalBounds && !bound.existsPart(_.isInstanceOf[WildcardType])) {
88+
if (equalBounds &&
89+
!bound.existsPart(bp => bp.isInstanceOf[WildcardType] || (bp eq param))) {
8990
// The narrowed bounds are equal and do not contain wildcards,
9091
// so we can remove `param` from the constraint.
9192
// (Handling wildcards requires choosing a bound, but we don't know which

0 commit comments

Comments
 (0)