@@ -287,11 +287,16 @@ object Checking {
287
287
*/
288
288
def checkInfo (tp : Type ): Type = tp match {
289
289
case tp @ TypeAlias (alias) =>
290
- tp.derivedAlias(checkPart(alias, " alias" ))
290
+ val lo1 = atVariance(- 1 )(checkPart(alias, " alias" ))
291
+ val hi1 = checkUpper(alias, " alias" )
292
+ if lo1 eq hi1 then
293
+ tp.derivedAlias(lo1)
294
+ else
295
+ tp.derivedTypeBounds(lo1, hi1)
291
296
case tp @ MatchAlias (alias) =>
292
- tp.derivedAlias(checkUpper(alias, " match" ))
297
+ tp.derivedAlias(atVariance( 0 )( checkUpper(alias, " match" ) ))
293
298
case tp @ TypeBounds (lo, hi) =>
294
- tp.derivedTypeBounds(checkPart(lo, " lower bound" ), checkUpper(hi, " upper bound" ))
299
+ tp.derivedTypeBounds(atVariance( - 1 )( checkPart(lo, " lower bound" ) ), checkUpper(hi, " upper bound" ))
295
300
case _ =>
296
301
tp
297
302
}
@@ -312,12 +317,12 @@ object Checking {
312
317
case tp : TermRef =>
313
318
this (tp.info)
314
319
mapOver(tp)
315
- case tp @ AppliedType (tycon, args) =>
316
- tp.derivedAppliedType(this (tycon), args.mapConserve(this (_, nestedCycleOK, nestedCycleOK)))
317
320
case tp @ RefinedType (parent, name, rinfo) =>
318
321
tp.derivedRefinedType(this (parent), name, this (rinfo, nestedCycleOK, nestedCycleOK))
319
322
case tp : RecType =>
320
323
tp.rebind(this (tp.parent))
324
+ case tp : LazyRef =>
325
+ tp
321
326
case tp @ TypeRef (pre, _) =>
322
327
try {
323
328
// A prefix is interesting if it might contain (transitively) a reference
@@ -350,14 +355,17 @@ object Checking {
350
355
351
356
if isInteresting(pre) then
352
357
CyclicReference .trace(i " explore ${tp.symbol} for cyclic references " ):
353
- val pre1 = this (pre, false , false )
358
+ val pre1 = atVariance(variance max 0 )( this (pre, false , false ) )
354
359
if locked.contains(tp)
355
360
|| tp.symbol.infoOrCompleter.isInstanceOf [NoCompleter ]
361
+ && tp.symbol == sym
356
362
then
357
363
throw CyclicReference (tp.symbol)
358
364
locked += tp
359
365
try
360
- if tp.symbol.isOpaqueAlias then
366
+ if tp.symbol.infoOrCompleter.isInstanceOf [NoCompleter ] then
367
+ ; // skip checking info (and avoid forcing the symbol with .isOpaqueAlias/etc)
368
+ else if tp.symbol.isOpaqueAlias then
361
369
checkInfo(TypeAlias (tp.translucentSuperType))
362
370
else if ! tp.symbol.isClass then
363
371
checkInfo(tp.info)
@@ -375,6 +383,16 @@ object Checking {
375
383
}
376
384
case _ => mapOver(tp)
377
385
}
386
+
387
+ override def mapArg (arg : Type , tparam : ParamInfo ): Type =
388
+ val varianceDiff = variance != tparam.paramVarianceSign
389
+ atVariance(variance * tparam.paramVarianceSign):
390
+ // Using tests/pos/i22257.scala as an example,
391
+ // if we consider FP's lower-bound of Fixed[Node]
392
+ // than `Node` is a type argument in contravariant
393
+ // position, while the type parameter is covariant.
394
+ val nestedCycleOK1 = nestedCycleOK || variance != 0 && varianceDiff
395
+ this (arg, nestedCycleOK, nestedCycleOK1)
378
396
}
379
397
380
398
/** Under -Yrequire-targetName, if `sym` has an operator name, check that it has a
0 commit comments