@@ -68,7 +68,7 @@ object Splicer {
68
68
def checkValidStat (tree : Tree ): Unit = tree match {
69
69
case tree : ValDef if tree.symbol.is(Synthetic ) =>
70
70
// Check val from `foo(j = x, i = y)` which it is expanded to
71
- // `val j$1 = x; val i$1 = y; foo(i = y , j = x )`
71
+ // `val j$1 = x; val i$1 = y; foo(i = i$1 , j = j$1 )`
72
72
checkIfValidArgument(tree.rhs)
73
73
case _ =>
74
74
ctx.error(" Macro should not have statements" , tree.sourcePos)
@@ -119,12 +119,15 @@ object Splicer {
119
119
stats.foreach(checkValidStat)
120
120
checkIfValidStaticCall(expr)
121
121
122
- case Typed (expr, _) => checkIfValidStaticCall(expr)
122
+ case Typed (expr, _) =>
123
+ checkIfValidStaticCall(expr)
124
+
123
125
case Call (fn, args)
124
126
if (fn.symbol.isConstructor && fn.symbol.owner.owner.is(Package )) ||
125
127
fn.symbol.is(Module ) || fn.symbol.isStatic ||
126
128
(fn.qualifier.symbol.is(Module ) && fn.qualifier.symbol.isStatic) =>
127
129
args.flatten.foreach(checkIfValidArgument)
130
+
128
131
case _ =>
129
132
ctx.error(
130
133
""" Malformed macro.
@@ -201,7 +204,7 @@ object Splicer {
201
204
}
202
205
203
206
// Interpret `foo(j = x, i = y)` which it is expanded to
204
- // `val j$1 = x; val i$1 = y; foo(i = y , j = x )`
207
+ // `val j$1 = x; val i$1 = y; foo(i = i$1 , j = j$1 )`
205
208
case Block (stats, expr) => interpretBlock(stats, expr)
206
209
case NamedArg (_, arg) => interpretTree(arg)
207
210
@@ -404,6 +407,9 @@ object Splicer {
404
407
}
405
408
406
409
object Call {
410
+ /** Matches an expression that is either a field access or an application
411
+ * It retruns a TermRef containing field accessed or a method reference and the arguments passed to it.
412
+ */
407
413
def unapply (arg : Tree )(implicit ctx : Context ): Option [(RefTree , List [List [Tree ]])] =
408
414
Call0 .unapply(arg).map((fn, args) => (fn, args.reverse))
409
415
0 commit comments