Closed
Description
This issue tracks a known problem with the PR #3913. The problem can be demonstrated with the following code.
- File
macro.scala
import scala.quoted._
class FInterpolatorHelper(val sc: StringContext) extends AnyVal {
inline def ff(arg1: Any): String = ~FInterpolation.fInterpolation(sc, Seq('(arg1)))
inline def ff(arg1: Any, arg2: Any): String = ~FInterpolation.fInterpolation(sc, Seq('(arg1), '(arg2)))
inline def ff(arg1: Any, arg2: Any, arg3: Any): String = ~FInterpolation.fInterpolation(sc, Seq('(arg1), '(arg2), '(arg3)))
// ...
}
object FInterpolation {
private def liftSeq(args: Seq[Expr[Any]]): Expr[Seq[Any]] = args match {
case x :: xs => '{ (~x) +: ~(liftSeq(xs)) }
case Nil => '(Seq(): Seq[Any])
}
def fInterpolation(sc: StringContext, args: Seq[Expr[Any]]): Expr[String] = {
val str: Expr[String] = sc.parts.mkString("")
val args1: Expr[Seq[Any]] = liftSeq(args)
'{ (~str).format(~args1: _*) }
}
}
- File
Test.scala
object Test {
def main(args: Array[String]): Unit = {
println(new FInterpolatorHelper(StringContext("hello%s")).ff(5))
}
}
The compiler crashes while compiling Test.scala
, with the following log: