Closed
Description
Implementing scala.quoted.ExprOps.toExprOfList
with
/** Lifts this list of expressions into an expression of a list
*
* Transforms a list of expression
* `e1 :: e2 :: ... :: Nil` where `ei: Expr[T]`
* to an expression equivalent to
* `'{ $e1 :: $e2 :: ... :: Nil }` typed as an `Expr[List[T]]`
*/
def (list: List[Expr[T]]) toExprOfList[T] given Type[T], QuoteContext: Expr[List[T]] = '{
val buff = List.newBuilder[T]
${ Expr.block(list.map(v => '{ buff += $v }), '{ buff.result() }) }
}
fails with
35 | ${ Expr.block(list.map(v => '{ buff `+=` $v }), '{ buff.result() }) }
| ^^^^^^^^^^^^
| undefined: buff.+= # 189467: TermRef(TermRef(NoPrefix,val buff),+=) at frontend
| This location is in code that was inlined at quoted_2.scala:6