Skip to content

Commit c8a8e28

Browse files
Merge pull request #12248 from dotty-staging/commit-avoid-creaation-of-pickles-for-captures
Avoid pickled tasty for some captured quote reference
2 parents 853aa87 + e32c8b9 commit c8a8e28

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/transform/PickleQuotes.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,16 @@ class PickleQuotes extends MacroTransform {
481481
transform(tree)(using ctx.withSource(tree.source))
482482
else reporting.trace(i"Reifier.transform $tree at $level", show = true) {
483483
tree match {
484-
case Apply(TypeApply(fn, (body: RefTree) :: Nil), _) if fn.symbol == defn.QuotedTypeModule_of && isCaptured(body.symbol, level + 1) =>
484+
case Apply(TypeApply(fn, (body: RefTree) :: Nil), _)
485+
if fn.symbol == defn.QuotedTypeModule_of && isCaptured(body.symbol, level + 1) =>
485486
// Optimization: avoid the full conversion when capturing `X` with `x$1: Type[X$1]`
486487
// in `Type.of[X]` to `Type.of[x$1.Underlying]` and go directly to `X$1`
487488
capturers(body.symbol)(body)
489+
case Apply(Select(Apply(TypeApply(fn,_), List(ref: RefTree)),nme.apply),List(quotes))
490+
if fn.symbol == defn.QuotedRuntime_exprQuote && isCaptured(ref.symbol, level + 1) =>
491+
// Optimization: avoid the full conversion when capturing `x` with `x$1: Expr[X]`
492+
// in `'{x}` to `'{ ${x$1} }'` and go directly to `x$1`
493+
capturers(ref.symbol)(ref).select(nme.apply).appliedTo(quotes)
488494
case tree: RefTree if isCaptured(tree.symbol, level) =>
489495
val body = capturers(tree.symbol).apply(tree)
490496
if (tree.isType)

0 commit comments

Comments
 (0)