@@ -247,8 +247,9 @@ abstract class UnCurry extends InfoTransform
247
247
}
248
248
}
249
249
250
- def transformArgs (pos : Position , fun : Symbol , args : List [Tree ], formals : List [Type ]): List [Tree ] = {
250
+ def transformArgs (pos : Position , fun : Symbol , args : List [Tree ], params : List [Symbol ]): List [Tree ] = {
251
251
val isJava = fun.isJavaDefined
252
+
252
253
def transformVarargs (varargsElemType : Type ) = {
253
254
def mkArrayValue (ts : List [Tree ], elemtp : Type ) =
254
255
ArrayValue (TypeTree (elemtp), ts) setType arrayType(elemtp)
@@ -314,7 +315,7 @@ abstract class UnCurry extends InfoTransform
314
315
else arrayToSequence(tree, varargsElemType, copy = isNewCollections) // existing array, make a defensive copy
315
316
}
316
317
else {
317
- def mkArray = mkArrayValue(args drop (formals .length - 1 ), varargsElemType)
318
+ def mkArray = mkArrayValue(args drop (params .length - 1 ), varargsElemType)
318
319
if (javaStyleVarArgs) mkArray
319
320
else if (args.isEmpty) gen.mkNil // avoid needlessly double-wrapping an empty argument list
320
321
else arrayToSequence(mkArray, varargsElemType, copy = false ) // fresh array, no need to copy
@@ -328,18 +329,19 @@ abstract class UnCurry extends InfoTransform
328
329
}
329
330
}
330
331
}
331
- args.take(formals .length - 1 ) :+ (suffix setType formals .last)
332
+ args.take(params .length - 1 ) :+ (suffix setType params .last.info )
332
333
}
333
334
334
- val args1 = if (isVarArgTypes(formals)) transformVarargs(formals.last.typeArgs.head.widen) else args
335
+ val isVarargs = isVarArgsList(params)
336
+ val args1 = if (isVarargs) transformVarargs(params.last.info.typeArgs.head.widen) else args
335
337
336
- map2(formals, args1 ) { (formal, arg ) =>
337
- if (! isByNameParamType(formal )) arg
338
+ map2Conserve(args1, params ) { (arg, param ) =>
339
+ if (! isByNameParamType(param.info )) arg
338
340
else if (isByNameRef(arg)) { // thunk does not need to be forced because it's a reference to a by-name arg passed to a by-name param
339
341
byNameArgs += arg
340
342
arg setType functionType(Nil , arg.tpe)
341
343
} else {
342
- log(s " Argument ' $arg' at line ${arg.pos.line} is $formal from ${fun.fullName}" )
344
+ log(s " Argument ' $arg' at line ${arg.pos.line} is ${param.info} from ${fun.fullName}" )
343
345
def canUseDirectly (qual : Tree ) = qual.tpe.typeSymbol.isSubClass(FunctionClass (0 )) && treeInfo.isExprSafeToInline(qual)
344
346
arg match {
345
347
// don't add a thunk for by-name argument if argument already is an application of
@@ -482,16 +484,16 @@ abstract class UnCurry extends InfoTransform
482
484
super .transform(tree)
483
485
484
486
case Apply (fn, args) =>
485
- // Read formals before `transform(fn)`, because UnCurry replaces T* by Seq[T] (see DesugaredParameterType).
487
+ // Read the param symbols before `transform(fn)`, because UnCurry replaces T* by Seq[T] (see DesugaredParameterType).
486
488
// The call to `transformArgs` below needs `formals` that still have varargs.
487
- val formals = fn.tpe.paramTypes
489
+ val fnParams = fn.tpe.params
488
490
val transformedFn = transform(fn)
489
491
// scala/bug#6479: no need to lift in args to label jumps
490
492
// scala/bug#11127: boolean && / || are emitted using jumps, the lhs stack value is consumed by the conditional jump
491
493
val noReceiverOnStack = fn.symbol.isLabel || fn.symbol == currentRun.runDefinitions.Boolean_and || fn.symbol == currentRun.runDefinitions.Boolean_or
492
494
val needLift = needTryLift || ! noReceiverOnStack
493
495
withNeedLift(needLift) {
494
- treeCopy.Apply (tree, transformedFn, transformTrees(transformArgs(tree.pos, fn.symbol, args, formals )))
496
+ treeCopy.Apply (tree, transformedFn, transformTrees(transformArgs(tree.pos, fn.symbol, args, fnParams )))
495
497
}
496
498
497
499
case Assign (_ : RefTree , _) =>
0 commit comments