diff --git a/library/src/scala/quoted/ExprMap.scala b/library/src/scala/quoted/ExprMap.scala index 86ec1e72bb9f..70af00b16be5 100644 --- a/library/src/scala/quoted/ExprMap.scala +++ b/library/src/scala/quoted/ExprMap.scala @@ -49,7 +49,11 @@ trait ExprMap: tree case tree @ Apply(fun, args) => val MethodType(_, tpes, _) = fun.tpe.widen: @unchecked - Apply.copy(tree)(transformTerm(fun, TypeRepr.of[Any])(owner), transformTerms(args, tpes)(owner)) + val tpes1 = tpes.map { + case ByNameType(tpe) => tpe + case tpe => tpe + } + Apply.copy(tree)(transformTerm(fun, TypeRepr.of[Any])(owner), transformTerms(args, tpes1)(owner)) case TypeApply(fun, args) => TypeApply.copy(tree)(transformTerm(fun, TypeRepr.of[Any])(owner), args) case _: Literal => diff --git a/tests/pos-macros/i15228/Macro_1.scala b/tests/pos-macros/i15228/Macro_1.scala new file mode 100644 index 000000000000..433e374f34d8 --- /dev/null +++ b/tests/pos-macros/i15228/Macro_1.scala @@ -0,0 +1,13 @@ +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) +} diff --git a/tests/pos-macros/i15228/Test_2.scala b/tests/pos-macros/i15228/Test_2.scala new file mode 100644 index 000000000000..6484bba6fc8a --- /dev/null +++ b/tests/pos-macros/i15228/Test_2.scala @@ -0,0 +1 @@ +def test = mac(None.getOrElse(3))