File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
src/compiler/scala/tools/nsc/transform Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -347,8 +347,15 @@ abstract class UnCurry extends InfoTransform
347
347
val isVarargs = isVarArgsList(params)
348
348
val args1 = if (isVarargs) transformVarargs(params.last.info.typeArgs.head.widen) else args
349
349
350
+ val params0 = fun.info.paramss.last.iterator
351
+
350
352
map2Conserve(args1, params) { (arg, param) =>
351
- if (! isByNameParamType(param.info)) arg
353
+ val param0 = if (params0.hasNext) params0.next() else NoSymbol
354
+ if (! isByNameParamType(param.info)) {
355
+ if (param0 != NoSymbol && isByNameParamType(param0.info)) // pass 2, sig is uncurried in expansion
356
+ byNameArgs += arg
357
+ arg
358
+ }
352
359
else if (isByNameRef(arg)) {
353
360
// thunk does not need to be forced because it's a reference to a by-name arg passed to a by-name param
354
361
byNameArgs += arg
Original file line number Diff line number Diff line change
1
+
2
+ trait Semigroup [F ] { self =>
3
+ def append (f1 : F , f2 : => F ): F
4
+ val z = 10
5
+ }
6
+
7
+ case class Box (i : Int )
8
+
9
+ class R extends Runnable {
10
+ def run () = {
11
+ val boxSemigroup : Semigroup [Box ] = (x1, x2) => Box (x1.i + x2.i)
12
+ // disallowed, by-name must be inferred
13
+ // val boxSemigroup: Semigroup[Box] = (x1: Box, x2: Box) => Box(Math.max(x1.i, x2.i))
14
+ assert(boxSemigroup.append(Box (1 ), Box (2 )) == Box (3 ))
15
+ }
16
+ }
17
+
18
+ object Test extends App {
19
+ new R ().run()
20
+ }
You can’t perform that action at this time.
0 commit comments