@@ -12,6 +12,7 @@ import collection.mutable
1212import reporting .*
1313import Checking .{checkNoPrivateLeaks , checkNoWildcard }
1414import cc .CaptureSet
15+ import util .Property
1516import transform .Splicer
1617
1718trait TypeAssigner {
@@ -273,33 +274,32 @@ trait TypeAssigner {
273274 /** Substitute argument type `argType` for parameter `pref` in type `tp`,
274275 * skolemizing the argument type if it is not stable and `pref` occurs in `tp`.
275276 */
276- def safeSubstParam (tp : Type , pref : ParamRef , argType : Type )(using Context ): Type = {
277+ def safeSubstParam (tp : Type , pref : ParamRef , argType : Type , arg : Tree | Null = null )(using Context ): Type = {
277278 val tp1 = tp.substParam(pref, argType)
278- if (( tp1 eq tp) || argType.isStable) tp1
279+ if (tp1 eq tp) || argType.isStable then tp1
279280 else tp.substParam(pref, SkolemType (argType.widen))
280281 }
281282
282283 /** Substitute types of all arguments `args` for corresponding `params` in `tp`.
283284 * The number of parameters `params` may exceed the number of arguments.
284285 * In this case, only the common prefix is substituted.
285286 */
286- def safeSubstParams (tp : Type , params : List [ParamRef ], argTypes : List [Type ])(using Context ): Type = argTypes match {
287- case argType :: argTypes1 =>
288- val tp1 = safeSubstParam(tp, params.head, argType )
289- safeSubstParams(tp1, params.tail, argTypes1 )
287+ def safeSubstParams (tp : Type , params : List [ParamRef ], args : List [Tree ])(using Context ): Type = args match
288+ case arg :: args1 =>
289+ val tp1 = safeSubstParam(tp, params.head, arg.tpe, arg )
290+ safeSubstParams(tp1, params.tail, args1 )
290291 case Nil =>
291292 tp
292- }
293293
294- def safeSubstMethodParams (mt : MethodType , argTypes : List [Type ])(using Context ): Type =
295- if mt.isResultDependent then safeSubstParams(mt.resultType, mt.paramRefs, argTypes )
294+ def safeSubstMethodParams (mt : MethodType , args : List [Tree ])(using Context ): Type =
295+ if mt.isResultDependent then safeSubstParams(mt.resultType, mt.paramRefs, args )
296296 else mt.resultType
297297
298298 def assignType (tree : untpd.Apply , fn : Tree , args : List [Tree ])(using Context ): Apply = {
299299 val ownType = fn.tpe.widen match {
300300 case fntpe : MethodType =>
301301 if fntpe.paramInfos.hasSameLengthAs(args) || ctx.phase.prev.relaxedTyping then
302- if fntpe.isResultDependent then safeSubstMethodParams(fntpe, args.tpes )
302+ if fntpe.isResultDependent then safeSubstMethodParams(fntpe, args)
303303 else fntpe.resultType // fast path optimization
304304 else
305305 val erroringPhase =
@@ -570,6 +570,12 @@ trait TypeAssigner {
570570}
571571
572572object TypeAssigner extends TypeAssigner :
573+
574+ /** An attachment on an argument in an application indicating that the argument's
575+ * type was converted to the given skolem type.
576+ */
577+ private [typer] val Skolemized = new Property .StickyKey [SkolemType ]
578+
573579 def seqLitType (tree : untpd.SeqLiteral , elemType : Type )(using Context ) = tree match
574580 case tree : untpd.JavaSeqLiteral => defn.ArrayOf (elemType)
575581 case _ => if ctx.erasedTypes then defn.SeqType else defn.SeqType .appliedTo(elemType)
0 commit comments