@@ -245,12 +245,15 @@ import transform.SymUtils._
245
245
extends TypeMismatchMsg (found, expected)(TypeMismatchID ):
246
246
247
247
// 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
249
250
// 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.
251
253
object reported extends TypeMap :
252
254
def setVariance (v : Int ) = variance = v
253
255
val constraint = mapCtx.typerState.constraint
256
+ var fbounded = false
254
257
def apply (tp : Type ): Type = tp match
255
258
case tp : TypeParamRef =>
256
259
constraint.entry(tp) match
@@ -260,15 +263,21 @@ import transform.SymUtils._
260
263
else tp
261
264
case NoType => tp
262
265
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)
265
273
266
274
def msg =
267
275
val found1 = reported(found)
268
276
reported.setVariance(- 1 )
269
277
val expected1 = reported(expected)
270
278
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)
272
281
val postScript = addenda.find(! _.isEmpty) match
273
282
case Some (p) => p
274
283
case None =>
0 commit comments