@@ -17,6 +17,7 @@ import NameKinds.{InlineAccessorName, UniqueInlineName}
1717import NameOps ._
1818import Annotations ._
1919import transform .{AccessProxies , PCPCheckAndHeal , Splicer }
20+ import transform .SymUtils .*
2021import config .Printers .inlining
2122import util .Property
2223import dotty .tools .dotc .transform .TreeMapWithStages ._
@@ -61,13 +62,17 @@ object PrepareInlineable {
6162 *
6263 * Constant vals don't need accessors since they are inlined in FirstTransform.
6364 * Inline methods don't need accessors since they are inlined in Typer.
65+ *
66+ * When creating accessors for staged/quoted code we only need to create accessors
67+ * for the code that is staged. This excludes code at level 0 (except if it is inlined).
6468 */
6569 def needsAccessor (sym : Symbol )(using Context ): Boolean =
6670 sym.isTerm &&
6771 (sym.isOneOf(AccessFlags ) || sym.privateWithin.exists) &&
6872 ! sym.isContainedIn(inlineSym) &&
6973 ! (sym.isStableMember && sym.info.widenTermRefExpr.isInstanceOf [ConstantType ]) &&
70- ! sym.isInlineMethod
74+ ! sym.isInlineMethod &&
75+ (Inliner .inInlineMethod || StagingContext .level > 0 )
7176
7277 def preTransform (tree : Tree )(using Context ): Tree
7378
@@ -79,7 +84,14 @@ object PrepareInlineable {
7984 }
8085
8186 override def transform (tree : Tree )(using Context ): Tree =
82- postTransform(super .transform(preTransform(tree)))
87+ inContext(stagingContext(tree)) {
88+ postTransform(super .transform(preTransform(tree)))
89+ }
90+
91+ private def stagingContext (tree : Tree )(using Context ): Context = tree match
92+ case tree : Apply if tree.symbol.isQuote => StagingContext .quoteContext
93+ case tree : Apply if tree.symbol.isExprSplice => StagingContext .spliceContext
94+ case _ => ctx
8395 }
8496
8597 /** Direct approach: place the accessor with the accessed symbol. This has the
0 commit comments