@@ -283,16 +283,14 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
283283 if tree.isType then
284284 checkNotPackage(tree)
285285 else
286- if tree.symbol.is(Inline ) && ! Inlines .inInlineMethod then
287- ctx.compilationUnit.needsInlining = true
288286 checkNoConstructorProxy(tree)
287+ registerNeedsInlining(tree)
289288 tree.tpe match {
290289 case tpe : ThisType => This (tpe.cls).withSpan(tree.span)
291290 case _ => tree
292291 }
293292 case tree @ Select (qual, name) =>
294- if tree.symbol.is(Inline ) then
295- ctx.compilationUnit.needsInlining = true
293+ registerNeedsInlining(tree)
296294 if name.isTypeName then
297295 Checking .checkRealizable(qual.tpe, qual.srcPos)
298296 withMode(Mode .Type )(super .transform(checkNotPackage(tree)))
@@ -344,8 +342,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
344342 case tree : TypeApply =>
345343 if tree.symbol.isQuote then
346344 ctx.compilationUnit.needsStaging = true
347- if tree.symbol.is(Inline ) then
348- ctx.compilationUnit.needsInlining = true
345+ registerNeedsInlining(tree)
349346 val tree1 @ TypeApply (fn, args) = normalizeTypeArgs(tree)
350347 for arg <- args do
351348 checkInferredWellFormed(arg)
@@ -363,7 +360,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
363360 case Inlined (call, bindings, expansion) if ! call.isEmpty =>
364361 val pos = call.sourcePos
365362 CrossVersionChecks .checkExperimentalRef(call.symbol, pos)
366- super . transform(call)
363+ withMode( Mode . InlinedCall )( transform(call) )
367364 val callTrace = Inlines .inlineCallTrace(call.symbol, pos)(using ctx.withSource(pos.source))
368365 cpy.Inlined (tree)(callTrace, transformSub(bindings), transform(expansion)(using inlineContext(call)))
369366 case templ : Template =>
@@ -505,6 +502,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
505502 private def normalizeErasedRhs (rhs : Tree , sym : Symbol )(using Context ) =
506503 if (sym.isEffectivelyErased) dropInlines.transform(rhs) else rhs
507504
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+
508509 /** Check if the definition has macro annotation and sets `compilationUnit.hasMacroAnnotations` if needed. */
509510 private def registerIfHasMacroAnnotations (tree : DefTree )(using Context ) =
510511 if ! Inlines .inInlineMethod && MacroAnnotations .hasMacroAnnotation(tree.symbol) then
0 commit comments