Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/Splicer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object Splicer {
* - Other parameters are lifted to quoted.Types.TreeExpr (may reference a binding)
*/
private def getLiftedArgs(call: Tree, bindings: List[Tree])(implicit ctx: Context): List[Any] = {
val bindMap = bindings.map {
val bindMap = bindings.collect {
case vdef: ValDef => (vdef.rhs, ref(vdef.symbol))
}.toMap
def allArgs(call: Tree, acc: List[List[Tree]]): List[List[Tree]] = call match {
Expand Down
1 change: 1 addition & 0 deletions tests/run/quote-impure-by-name.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1 + {Index.zero[String("bar"), scala.Tuple2[String("baz"), scala.Unit]]}
18 changes: 18 additions & 0 deletions tests/run/quote-impure-by-name/quoted_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import scala.quoted._

import dotty.tools.dotc.quoted.Toolbox._

class Index[K, Keys](val index: String) extends AnyVal {
override def toString: String = index
}
object Index {

implicit def zero[K, T]: Index[K, (K, T)] = new Index("0")

implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl('(prev))('[K], '[H], '[T])

def succImpl[K, H, T](prev: Expr[Index[K, T]])(implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = {
val value = s"1 + {${prev.show}}"
'(new Index(~value.toExpr))
}
}
6 changes: 6 additions & 0 deletions tests/run/quote-impure-by-name/quoted_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test {

def main(args: Array[String]): Unit = {
println(Index.succ["bar", "foo", ("bar", ("baz", Unit))])
}
}
13 changes: 13 additions & 0 deletions tests/run/quote-indexed-map-by-name/quoted_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import scala.quoted._

class Index[K, Keys](val index: Int) extends AnyVal
object Index {

implicit def zero[K, T]: Index[K, (K, T)] = new Index(0)

implicit inline def succ[K, H, T](implicit prev: => Index[K, T]): Index[K, (H, T)] = ~succImpl('[K], '[H], '[T])

def succImpl[K, H, T](implicit k: Type[K], h: Type[H], t: Type[T]): Expr[Index[K, (H, T)]] = {
'(new Index(0))
}
}
6 changes: 6 additions & 0 deletions tests/run/quote-indexed-map-by-name/quoted_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object Test {

def main(args: Array[String]): Unit = {
Index.succ["bar", "foo", ("bar", ("baz", Unit))]
}
}