@@ -274,11 +274,16 @@ object Checking {
274
274
*/
275
275
def checkInfo (tp : Type ): Type = tp match {
276
276
case tp @ TypeAlias (alias) =>
277
- tp.derivedAlias(checkPart(alias, " alias" ))
277
+ val lo1 = atVariance(- 1 )(checkPart(alias, " alias" ))
278
+ val hi1 = checkUpper(alias, " alias" )
279
+ if lo1 eq hi1 then
280
+ tp.derivedAlias(lo1)
281
+ else
282
+ tp.derivedTypeBounds(lo1, hi1)
278
283
case tp @ MatchAlias (alias) =>
279
- tp.derivedAlias(checkUpper(alias, " match" ))
284
+ tp.derivedAlias(atVariance( 0 )( checkUpper(alias, " match" ) ))
280
285
case tp @ TypeBounds (lo, hi) =>
281
- tp.derivedTypeBounds(checkPart(lo, " lower bound" ), checkUpper(hi, " upper bound" ))
286
+ tp.derivedTypeBounds(atVariance( - 1 )( checkPart(lo, " lower bound" ) ), checkUpper(hi, " upper bound" ))
282
287
case _ =>
283
288
tp
284
289
}
@@ -299,12 +304,12 @@ object Checking {
299
304
case tp : TermRef =>
300
305
this (tp.info)
301
306
mapOver(tp)
302
- case tp @ AppliedType (tycon, args) =>
303
- tp.derivedAppliedType(this (tycon), args.mapConserve(this (_, nestedCycleOK, nestedCycleOK)))
304
307
case tp @ RefinedType (parent, name, rinfo) =>
305
308
tp.derivedRefinedType(this (parent), name, this (rinfo, nestedCycleOK, nestedCycleOK))
306
309
case tp : RecType =>
307
310
tp.rebind(this (tp.parent))
311
+ case tp : LazyRef =>
312
+ tp
308
313
case tp @ TypeRef (pre, _) =>
309
314
try {
310
315
// A prefix is interesting if it might contain (transitively) a reference
@@ -337,14 +342,17 @@ object Checking {
337
342
338
343
if isInteresting(pre) then
339
344
CyclicReference .trace(i " explore ${tp.symbol} for cyclic references " ):
340
- val pre1 = this (pre, false , false )
345
+ val pre1 = atVariance(variance max 0 )( this (pre, false , false ) )
341
346
if locked.contains(tp)
342
347
|| tp.symbol.infoOrCompleter.isInstanceOf [NoCompleter ]
348
+ && tp.symbol == sym
343
349
then
344
350
throw CyclicReference (tp.symbol)
345
351
locked += tp
346
352
try
347
- if tp.symbol.isOpaqueAlias then
353
+ if tp.symbol.infoOrCompleter.isInstanceOf [NoCompleter ] then
354
+ ; // skip checking info (and avoid forcing the symbol with .isOpaqueAlias/etc)
355
+ else if tp.symbol.isOpaqueAlias then
348
356
checkInfo(TypeAlias (tp.translucentSuperType))
349
357
else if ! tp.symbol.isClass then
350
358
checkInfo(tp.info)
@@ -362,6 +370,16 @@ object Checking {
362
370
}
363
371
case _ => mapOver(tp)
364
372
}
373
+
374
+ override def mapArg (arg : Type , tparam : ParamInfo ): Type =
375
+ val varianceDiff = variance != tparam.paramVarianceSign
376
+ atVariance(variance * tparam.paramVarianceSign):
377
+ // Using tests/pos/i22257.scala as an example,
378
+ // if we consider FP's lower-bound of Fixed[Node]
379
+ // than `Node` is a type argument in contravariant
380
+ // position, while the type parameter is covariant.
381
+ val nestedCycleOK1 = nestedCycleOK || variance != 0 && varianceDiff
382
+ this (arg, nestedCycleOK, nestedCycleOK1)
365
383
}
366
384
367
385
/** Under -Yrequire-targetName, if `sym` has an operator name, check that it has a
0 commit comments