@@ -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.isQuote 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,7 +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)
366
- super . transform(call)
363
+ withMode( Mode . InlinedCall )( transform(call) )
367
364
val callTrace = Inlines .inlineCallTrace(call.symbol, pos)(using ctx.withSource(pos.source))
368
365
cpy.Inlined (tree)(callTrace, transformSub(bindings), transform(expansion)(using inlineContext(call)))
369
366
case templ : Template =>
@@ -505,6 +502,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
505
502
private def normalizeErasedRhs (rhs : Tree , sym : Symbol )(using Context ) =
506
503
if (sym.isEffectivelyErased) dropInlines.transform(rhs) else rhs
507
504
505
+ private def registerNeedsInlining (tree : Tree )(using Context ): Unit =
506
+ if tree.symbol.is(Inline ) && ! Inlines .inInlineMethod && ! ctx.mode.is(Mode .InlinedCall ) then
507
+ ctx.compilationUnit.needsInlining = true
508
+
508
509
/** Check if the definition has macro annotation and sets `compilationUnit.hasMacroAnnotations` if needed. */
509
510
private def registerIfHasMacroAnnotations (tree : DefTree )(using Context ) =
510
511
if ! Inlines .inInlineMethod && MacroAnnotations .hasMacroAnnotation(tree.symbol) then
0 commit comments