@@ -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 == defn.QuotedTypeModule_of 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,6 +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)
363+ withMode(Mode .InlinedCall )(transform(call))
366364 val callTrace = Inlines .inlineCallTrace(call.symbol, pos)(using ctx.withSource(pos.source))
367365 cpy.Inlined (tree)(callTrace, transformSub(bindings), transform(expansion)(using inlineContext(call)))
368366 case templ : Template =>
@@ -507,6 +505,10 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
507505 private def normalizeErasedRhs (rhs : Tree , sym : Symbol )(using Context ) =
508506 if (sym.isEffectivelyErased) dropInlines.transform(rhs) else rhs
509507
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+
510512 /** Check if the definition has macro annotation and sets `compilationUnit.hasMacroAnnotations` if needed. */
511513 private def registerIfHasMacroAnnotations (tree : DefTree )(using Context ) =
512514 if ! Inlines .inInlineMethod && MacroAnnotations .hasMacroAnnotation(tree.symbol) then
0 commit comments