@@ -55,7 +55,7 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
5555 if tree.symbol.exists then
5656 // if in an inline expansion, resolve at summonInline (synthetic pos) or in an enclosing call site
5757 val resolving =
58- tree.srcPos.isUserCode
58+ tree.srcPos.isUserCode( using if tree.hasAttachment( InlinedParameter ) then ctx.outer else ctx)
5959 || tree.srcPos.isZeroExtentSynthetic // take as summonInline
6060 if ! ignoreTree(tree) then
6161 def loopOverPrefixes (prefix : Type , depth : Int ): Unit =
@@ -140,6 +140,10 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
140140 case _ =>
141141 tree
142142
143+ override def prepareForInlined (tree : Inlined )(using Context ): Context =
144+ if tree.inlinedFromOuterScope then
145+ tree.expansion.putAttachment(InlinedParameter , ())
146+ ctx
143147 override def transformInlined (tree : Inlined )(using Context ): tree.type =
144148 if ! tree.call.isEmpty then
145149 if ! refInfos.calls.containsKey(tree.call) then
@@ -422,6 +426,9 @@ object CheckUnused:
422426 /** Tree is LHS of Assign. */
423427 val AssignmentTarget = Property .StickyKey [Unit ]
424428
429+ /** Tree is an inlined parameter. */
430+ val InlinedParameter = Property .StickyKey [Unit ]
431+
425432 class PostTyper extends CheckUnused (PhaseMode .Aggregate , " PostTyper" )
426433
427434 class PostInlining extends CheckUnused (PhaseMode .Report , " PostInlining" )
@@ -1010,7 +1017,7 @@ object CheckUnused:
10101017 def isUserCode (using Context ): Boolean =
10111018 val inlineds = enclosingInlineds // per current context
10121019 inlineds.isEmpty
1013- || inlineds.last .srcPos.sourcePos.contains(pos.sourcePos)
1020+ || inlineds.exists(_ .srcPos.sourcePos.contains(pos.sourcePos)) // include intermediate inlinings or quotes
10141021
10151022 extension [A <: AnyRef ](arr : Array [A ])
10161023 // returns `until` if not satisfied
0 commit comments