@@ -245,12 +245,15 @@ import transform.SymUtils._
245245 extends TypeMismatchMsg (found, expected)(TypeMismatchID ):
246246
247247 // replace constrained TypeParamRefs and their typevars by their bounds where possible
248- // the idea is that if the bounds are also not-subtypes of each other to report
248+ // and the bounds are not f-bounds.
249+ // The idea is that if the bounds are also not-subtypes of each other to report
249250 // the type mismatch on the bounds instead of the original TypeParamRefs, since
250- // these are usually easier to analyze.
251+ // these are usually easier to analyze. We exclude F-bounds since these would
252+ // lead to a recursive infinite expansion.
251253 object reported extends TypeMap :
252254 def setVariance (v : Int ) = variance = v
253255 val constraint = mapCtx.typerState.constraint
256+ var fbounded = false
254257 def apply (tp : Type ): Type = tp match
255258 case tp : TypeParamRef =>
256259 constraint.entry(tp) match
@@ -260,15 +263,21 @@ import transform.SymUtils._
260263 else tp
261264 case NoType => tp
262265 case instType => apply(instType)
263- case tp : TypeVar => apply(tp.stripTypeVar)
264- case _ => mapOver(tp)
266+ case tp : TypeVar =>
267+ apply(tp.stripTypeVar)
268+ case tp : LazyRef =>
269+ fbounded = true
270+ tp
271+ case _ =>
272+ mapOver(tp)
265273
266274 def msg =
267275 val found1 = reported(found)
268276 reported.setVariance(- 1 )
269277 val expected1 = reported(expected)
270278 val (found2, expected2) =
271- if (found1 frozen_<:< expected1) (found, expected) else (found1, expected1)
279+ if (found1 frozen_<:< expected1) || reported.fbounded then (found, expected)
280+ else (found1, expected1)
272281 val postScript = addenda.find(! _.isEmpty) match
273282 case Some (p) => p
274283 case None =>
0 commit comments