@@ -287,11 +287,16 @@ object Checking {
287287 */
288288 def checkInfo (tp : Type ): Type = tp match {
289289 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)
291296 case tp @ MatchAlias (alias) =>
292- tp.derivedAlias(checkUpper(alias, " match" ))
297+ tp.derivedAlias(atVariance( 0 )( checkUpper(alias, " match" ) ))
293298 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" ))
295300 case _ =>
296301 tp
297302 }
@@ -312,12 +317,12 @@ object Checking {
312317 case tp : TermRef =>
313318 this (tp.info)
314319 mapOver(tp)
315- case tp @ AppliedType (tycon, args) =>
316- tp.derivedAppliedType(this (tycon), args.mapConserve(this (_, nestedCycleOK, nestedCycleOK)))
317320 case tp @ RefinedType (parent, name, rinfo) =>
318321 tp.derivedRefinedType(this (parent), name, this (rinfo, nestedCycleOK, nestedCycleOK))
319322 case tp : RecType =>
320323 tp.rebind(this (tp.parent))
324+ case tp : LazyRef =>
325+ tp
321326 case tp @ TypeRef (pre, _) =>
322327 try {
323328 // A prefix is interesting if it might contain (transitively) a reference
@@ -350,14 +355,17 @@ object Checking {
350355
351356 if isInteresting(pre) then
352357 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 ) )
354359 if locked.contains(tp)
355360 || tp.symbol.infoOrCompleter.isInstanceOf [NoCompleter ]
361+ && tp.symbol == sym
356362 then
357363 throw CyclicReference (tp.symbol)
358364 locked += tp
359365 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
361369 checkInfo(TypeAlias (tp.translucentSuperType))
362370 else if ! tp.symbol.isClass then
363371 checkInfo(tp.info)
@@ -375,6 +383,16 @@ object Checking {
375383 }
376384 case _ => mapOver(tp)
377385 }
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)
378396 }
379397
380398 /** Under -Yrequire-targetName, if `sym` has an operator name, check that it has a
0 commit comments