@@ -283,16 +283,14 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
283
283
if tree.isType then
284
284
checkNotPackage(tree)
285
285
else
286
- if tree.symbol.is(Inline ) && ! Inlines .inInlineMethod then
287
- ctx.compilationUnit.needsInlining = true
288
286
checkNoConstructorProxy(tree)
287
+ registerNeedsInlining(tree)
289
288
tree.tpe match {
290
289
case tpe : ThisType => This (tpe.cls).withSpan(tree.span)
291
290
case _ => tree
292
291
}
293
292
case tree @ Select (qual, name) =>
294
- if tree.symbol.is(Inline ) then
295
- ctx.compilationUnit.needsInlining = true
293
+ registerNeedsInlining(tree)
296
294
if name.isTypeName then
297
295
Checking .checkRealizable(qual.tpe, qual.srcPos)
298
296
withMode(Mode .Type )(super .transform(checkNotPackage(tree)))
@@ -344,8 +342,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
344
342
case tree : TypeApply =>
345
343
if tree.symbol == defn.QuotedTypeModule_of then
346
344
ctx.compilationUnit.needsStaging = true
347
- if tree.symbol.is(Inline ) then
348
- ctx.compilationUnit.needsInlining = true
345
+ registerNeedsInlining(tree)
349
346
val tree1 @ TypeApply (fn, args) = normalizeTypeArgs(tree)
350
347
for arg <- args do
351
348
checkInferredWellFormed(arg)
@@ -363,6 +360,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
363
360
case Inlined (call, bindings, expansion) if ! call.isEmpty =>
364
361
val pos = call.sourcePos
365
362
CrossVersionChecks .checkExperimentalRef(call.symbol, pos)
363
+ withMode(Mode .InlinedCall )(transform(call))
366
364
val callTrace = Inlines .inlineCallTrace(call.symbol, pos)(using ctx.withSource(pos.source))
367
365
cpy.Inlined (tree)(callTrace, transformSub(bindings), transform(expansion)(using inlineContext(call)))
368
366
case templ : Template =>
@@ -507,6 +505,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
507
505
private def normalizeErasedRhs (rhs : Tree , sym : Symbol )(using Context ) =
508
506
if (sym.isEffectivelyErased) dropInlines.transform(rhs) else rhs
509
507
508
+ private def registerNeedsInlining (tree : Tree )(using Context ): Unit =
509
+ if tree.symbol.is(Inline ) && ! Inlines .inInlineMethod && ! ctx.mode.is(Mode .InlinedCall ) then
510
+ ctx.compilationUnit.needsInlining = true
511
+
510
512
/** Check if the definition has macro annotation and sets `compilationUnit.hasMacroAnnotations` if needed. */
511
513
private def registerIfHasMacroAnnotations (tree : DefTree )(using Context ) =
512
514
if ! Inlines .inInlineMethod && MacroAnnotations .hasMacroAnnotation(tree.symbol) then
0 commit comments