@@ -274,11 +274,16 @@ object Checking {
274274 */
275275 def checkInfo (tp : Type ): Type = tp match {
276276 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)
278283 case tp @ MatchAlias (alias) =>
279- tp.derivedAlias(checkUpper(alias, " match" ))
284+ tp.derivedAlias(atVariance( 0 )( checkUpper(alias, " match" ) ))
280285 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" ))
282287 case _ =>
283288 tp
284289 }
@@ -299,12 +304,12 @@ object Checking {
299304 case tp : TermRef =>
300305 this (tp.info)
301306 mapOver(tp)
302- case tp @ AppliedType (tycon, args) =>
303- tp.derivedAppliedType(this (tycon), args.mapConserve(this (_, nestedCycleOK, nestedCycleOK)))
304307 case tp @ RefinedType (parent, name, rinfo) =>
305308 tp.derivedRefinedType(this (parent), name, this (rinfo, nestedCycleOK, nestedCycleOK))
306309 case tp : RecType =>
307310 tp.rebind(this (tp.parent))
311+ case tp : LazyRef =>
312+ tp
308313 case tp @ TypeRef (pre, _) =>
309314 try {
310315 // A prefix is interesting if it might contain (transitively) a reference
@@ -337,14 +342,17 @@ object Checking {
337342
338343 if isInteresting(pre) then
339344 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 ) )
341346 if locked.contains(tp)
342347 || tp.symbol.infoOrCompleter.isInstanceOf [NoCompleter ]
348+ && tp.symbol == sym
343349 then
344350 throw CyclicReference (tp.symbol)
345351 locked += tp
346352 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
348356 checkInfo(TypeAlias (tp.translucentSuperType))
349357 else if ! tp.symbol.isClass then
350358 checkInfo(tp.info)
@@ -362,6 +370,16 @@ object Checking {
362370 }
363371 case _ => mapOver(tp)
364372 }
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)
365383 }
366384
367385 /** Under -Yrequire-targetName, if `sym` has an operator name, check that it has a
0 commit comments