@@ -4895,16 +4895,16 @@ object Types {
4895
4895
/** Instantiate variable with given type */
4896
4896
def instantiateWith (tp : Type )(using Context ): Type = {
4897
4897
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" )
4900
4900
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" )
4904
4904
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)
4908
4908
tp
4909
4909
}
4910
4910
@@ -5811,11 +5811,13 @@ object Types {
5811
5811
protected def derivedLambdaType (tp : LambdaType )(formals : List [tp.PInfo ], restpe : Type ): Type =
5812
5812
tp.derivedLambdaType(tp.paramNames, formals, restpe)
5813
5813
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
+
5814
5818
protected def mapArgs (args : List [Type ], tparams : List [ParamInfo ]): List [Type ] = args match
5815
5819
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)
5819
5821
val otherArgs1 = mapArgs(otherArgs, tparams.tail)
5820
5822
if ((arg1 eq arg) && (otherArgs1 eq otherArgs)) args
5821
5823
else arg1 :: otherArgs1
0 commit comments