Skip to content

Commit 68b75fc

Browse files
committed
Fix impure by name macro parameters
1 parent eb4d2c8 commit 68b75fc

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object Splicer {
4646
*/
4747
private def getLiftedArgs(call: Tree, bindings: List[Tree])(implicit ctx: Context): List[Any] = {
4848
val bindMap = bindings.map {
49-
case vdef: ValDef => (vdef.rhs, ref(vdef.symbol))
49+
case vdef: ValOrDefDef => (vdef.rhs, ref(vdef.symbol))
5050
}.toMap
5151
def allArgs(call: Tree, acc: List[List[Tree]]): List[List[Tree]] = call match {
5252
case call: Apply => allArgs(call.fun, call.args :: acc)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import scala.quoted._
2+
3+
class Index[K, Keys](val index: Int) extends AnyVal
4+
object Index {
5+
6+
implicit def zero[K, T]: Index[K, (K, T)] = new Index(0)
7+
8+
implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl('[K], '[H], '[T])
9+
10+
def succImpl[K, H, T](implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = {
11+
'(new Index(0))
12+
}
13+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
3+
def main(args: Array[String]): Unit = {
4+
Index.succ["bar", "foo", ("bar", ("baz", Unit))]
5+
}
6+
}

0 commit comments

Comments
 (0)