Skip to content

Commit d27d402

Browse files
wip
1 parent 70c85a6 commit d27d402

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ object Splicer {
321321
protected def interpretNew(fn: Symbol, args: => List[Result])(implicit env: Env): Result
322322
protected def unexpectedTree(tree: Tree)(implicit env: Env): Result
323323

324-
private final def removeEraisedArguments(args: List[Tree], fnTpe: Type): List[Tree] = {
324+
private final def removeErasedArguments(args: List[Tree], fnTpe: Type): List[Tree] = {
325325
var result = args
326326
var index = 0
327327
def loop(tp: Type): Unit = tp match {
@@ -336,11 +336,15 @@ object Splicer {
336336
case tp: MethodType =>
337337
index += tp.paramInfos.size
338338
loop(tp.resType)
339-
case _ => ()
339+
case tp: ExprType =>
340+
index += 1
341+
loop(tp.resType)
342+
case tp => ()
340343
}
341344
loop(fnTpe)
342-
assert(index == args.size)
345+
assert(index == args.size, s"$index != ${args.size}")
343346
result.filterNot(null.eq)
347+
args
344348
}
345349

346350
protected final def interpretTree(tree: Tree)(implicit env: Env): Result = tree match {
@@ -373,11 +377,11 @@ object Splicer {
373377
interpretModuleAccess(fn.symbol)
374378
} else if (fn.symbol.isStatic) {
375379
val module = fn.symbol.owner
376-
def interpretedArgs = removeEraisedArguments(args, fn.tpe).map(arg => interpretTree(arg))
380+
def interpretedArgs = removeErasedArguments(args, fn.tpe).map(arg => interpretTree(arg))
377381
interpretStaticMethodCall(module, fn.symbol, interpretedArgs)
378382
} else if (fn.qualifier.symbol.is(Module) && fn.qualifier.symbol.isStatic) {
379383
val module = fn.qualifier.symbol.moduleClass
380-
def interpretedArgs = removeEraisedArguments(args, fn.tpe).map(arg => interpretTree(arg))
384+
def interpretedArgs = removeErasedArguments(args, fn.tpe).map(arg => interpretTree(arg))
381385
interpretStaticMethodCall(module, fn.symbol, interpretedArgs)
382386
} else if (env.contains(fn.name)) {
383387
env(fn.name)
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
object Test {
2-
assert(Macro.foo1(1) == 0)
3-
assert(Macro.foo2(1) == 0)
4-
assert(Macro.foo3(1) == 0)
5-
assert(Macro.foo4(1) == 0)
6-
assert(Macro.foo5(1) == 0)
7-
assert(Macro.foo6(1) == 0)
8-
assert(Macro.foo7(1) == 0)
9-
assert(Macro.foo8(1) == 0)
2+
def main(args: Array[String]): Unit = {
3+
assert(Macro.foo1(1) == 0)
4+
assert(Macro.foo2(1) == 0)
5+
assert(Macro.foo3(1) == 0)
6+
assert(Macro.foo4(1) == 0)
7+
assert(Macro.foo5(1) == 0)
8+
assert(Macro.foo6(1) == 0)
9+
assert(Macro.foo7(1) == 0)
10+
assert(Macro.foo8(1) == 0)
11+
}
1012
}

0 commit comments

Comments
 (0)