@@ -341,19 +341,22 @@ trait ConstraintHandling {
341341 * and propagate all bounds.
342342 * @param tvars See Constraint#add
343343 */
344- def addToConstraint (tl : TypeLambda , tvars : List [TypeVar ]): Unit =
345- assert {
346- checkPropagated(i " initialized $tl" ) {
347- constraint = constraint.add(tl, tvars)
348- tl.paramNames.indices.forall { i =>
349- val param = tl.paramRefs(i)
350- val bounds = constraint.nonParamBounds(param)
351- val lower = constraint.lower(param)
352- val upper = constraint.upper(param)
353- if (lower.nonEmpty && ! bounds.lo.isRef(defn.NothingClass ) ||
354- upper.nonEmpty && ! bounds.hi.isRef(defn.AnyClass )) constr.println(i " INIT*** $tl" )
355- lower.forall(addOneBound(_, bounds.hi, isUpper = true )) &&
356- upper.forall(addOneBound(_, bounds.lo, isUpper = false ))
344+ def addToConstraint (tl : TypeLambda , tvars : List [TypeVar ]): Boolean =
345+ checkPropagated(i " initialized $tl" ) {
346+ constraint = constraint.add(tl, tvars)
347+ tl.paramRefs.forall { param =>
348+ constraint.entry(param) match {
349+ case bounds : TypeBounds =>
350+ val lower = constraint.lower(param)
351+ val upper = constraint.upper(param)
352+ if (lower.nonEmpty && ! bounds.lo.isRef(defn.NothingClass ) ||
353+ upper.nonEmpty && ! bounds.hi.isRef(defn.AnyClass )) constr.println(i " INIT*** $tl" )
354+ lower.forall(addOneBound(_, bounds.hi, isUpper = true )) &&
355+ upper.forall(addOneBound(_, bounds.lo, isUpper = false ))
356+ case _ =>
357+ // Happens if param was already solved while processing earlier params of the same TypeLambda.
358+ // See #4720.
359+ true
357360 }
358361 }
359362 }
0 commit comments