Closed
Description
Compiler version
3.1.2, Scala 3.2.0-RC1-bin-20220517-e5abec0-NIGHTLY
Minimized code
Boilerplate to just do an empty transform using ExpMap
import scala.quoted.*
inline def mac[T](inline expr: T): T =
${ impl('expr) }
class MyMap() extends ExprMap {
override def transform[T](e: Expr[T])(using Type[T])(using q: Quotes): Expr[T] =
transformChildren(e)
}
def impl[T: Type](expr: Expr[T])(using quotes: Quotes): Expr[T] = {
MyMap().transform(expr)
}
Then call with something that takes a by name parameter, for example mac(None.getOrElse(3))
Output
java.lang.Exception: Expr cast exception: 3
of type: 3
did not conform to type: => scala.Int
at scala.quoted.runtime.impl.QuotesImpl.asExprOf(QuotesImpl.scala:71)
at scala.quoted.runtime.impl.QuotesImpl$reflect$TreeMethods$.asExprOf(QuotesImpl.scala:114)
at scala.quoted.runtime.impl.QuotesImpl$reflect$TreeMethods$.asExprOf(QuotesImpl.scala:113)
at scala.quoted.ExprMap.transformChildren(ExprMap.scala:150)
at scala.quoted.ExprMap.transformChildren$(ExprMap.scala:3)
Expectation
Should return the unmodified expression