@@ -4895,16 +4895,16 @@ object Types {
48954895 /** Instantiate variable with given type */
48964896 def instantiateWith (tp : Type )(using Context ): Type = {
48974897 assert(tp ne this , i " self instantiation of $origin, constraint = ${ctx.typerState.constraint}" )
4898- if ! myInst.exists then
4899- typr.println(i " instantiating $this with $tp" )
4898+ assert( ! myInst.exists, i " $origin is already instantiated to $myInst but we attempted to instantiate it to $tp " )
4899+ typr.println(i " instantiating $this with $tp" )
49004900
4901- if Config .checkConstraintsSatisfiable then
4902- assert(currentEntry.bounds.contains(tp),
4903- i " $origin is constrained to be $currentEntry but attempted to instantiate it to $tp" )
4901+ if Config .checkConstraintsSatisfiable then
4902+ assert(currentEntry.bounds.contains(tp),
4903+ i " $origin is constrained to be $currentEntry but attempted to instantiate it to $tp" )
49044904
4905- if ((ctx.typerState eq owningState.nn.get.uncheckedNN) && ! TypeComparer .subtypeCheckInProgress)
4906- setInst(tp)
4907- ctx.typerState.constraint = ctx.typerState.constraint.replace(origin, tp)
4905+ if ((ctx.typerState eq owningState.nn.get.uncheckedNN) && ! TypeComparer .subtypeCheckInProgress)
4906+ setInst(tp)
4907+ ctx.typerState.constraint = ctx.typerState.constraint.replace(origin, tp)
49084908 tp
49094909 }
49104910
@@ -5811,11 +5811,13 @@ object Types {
58115811 protected def derivedLambdaType (tp : LambdaType )(formals : List [tp.PInfo ], restpe : Type ): Type =
58125812 tp.derivedLambdaType(tp.paramNames, formals, restpe)
58135813
5814+ protected def mapArg (arg : Type , tparam : ParamInfo ): Type = arg match
5815+ case arg : TypeBounds => this (arg)
5816+ case arg => atVariance(variance * tparam.paramVarianceSign)(this (arg))
5817+
58145818 protected def mapArgs (args : List [Type ], tparams : List [ParamInfo ]): List [Type ] = args match
58155819 case arg :: otherArgs if tparams.nonEmpty =>
5816- val arg1 = arg match
5817- case arg : TypeBounds => this (arg)
5818- case arg => atVariance(variance * tparams.head.paramVarianceSign)(this (arg))
5820+ val arg1 = mapArg(arg, tparams.head)
58195821 val otherArgs1 = mapArgs(otherArgs, tparams.tail)
58205822 if ((arg1 eq arg) && (otherArgs1 eq otherArgs)) args
58215823 else arg1 :: otherArgs1
0 commit comments