diff --git a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala index 626455da63d1..47e5ae96f5da 100644 --- a/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala +++ b/compiler/src/dotty/tools/dotc/transform/PCPCheckAndHeal.scala @@ -124,6 +124,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( val targs2 = targs.map(targ => TypeTree(healTypeOfTerm(quote.fun.srcPos)(targ.tpe))) cpy.Apply(quote)(cpy.TypeApply(quote.fun)(fun, targs2), body2 :: Nil) else + val quotes = quote.args.mapConserve(transform) body.tpe match case tp @ TypeRef(x: TermRef, _) if tp.symbol == defn.QuotedType_splice => // Optimization: `quoted.Type.of[x.Underlying](quotes)` --> `x` @@ -131,7 +132,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages( case _ => // `quoted.Type.of[](quotes)` --> `quoted.Type.of[](quotes)` val TypeApply(fun, _) = quote.fun - cpy.Apply(quote)(cpy.TypeApply(quote.fun)(fun, body2 :: Nil), quote.args) + cpy.Apply(quote)(cpy.TypeApply(quote.fun)(fun, body2 :: Nil), quotes) } /** Transform splice diff --git a/tests/neg-macros/i12471.scala b/tests/neg-macros/i12471.scala new file mode 100644 index 000000000000..d09e51c5a10a --- /dev/null +++ b/tests/neg-macros/i12471.scala @@ -0,0 +1,7 @@ +import scala.quoted.* + +def impl1[A](using t: Type[A])(using q: Quotes) = + '{ Type.of[A] ; ??? } // error + +def impl2[A](using t: Type[A])(using q: Quotes) = + '{ Type.of[A](using q) ; ??? } // error