@@ -58,9 +58,10 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
58
58
if tree.symbol.exists then
59
59
// if in an inline expansion, resolve at summonInline (synthetic pos) or in an enclosing call site
60
60
val resolving =
61
- refInfos.inlined.isEmpty
62
- || tree.srcPos.isZeroExtentSynthetic
63
- || refInfos.inlined.exists(_.sourcePos.contains(tree.srcPos.sourcePos))
61
+ val inlineds = enclosingInlineds // per current context
62
+ inlineds.isEmpty
63
+ || tree.srcPos.isZeroExtentSynthetic // take as summonInline
64
+ || inlineds.last.srcPos.sourcePos.contains(tree.srcPos.sourcePos)
64
65
if resolving && ! ignoreTree(tree) then
65
66
def loopOverPrefixes (prefix : Type , depth : Int ): Unit =
66
67
if depth < 10 && prefix.exists && ! prefix.classSymbol.isEffectiveRoot then
@@ -160,12 +161,8 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
160
161
case _ =>
161
162
tree
162
163
163
- override def prepareForInlined (tree : Inlined )(using Context ): Context =
164
- refInfos.inlined.push(tree.call.srcPos)
165
- ctx
166
164
override def transformInlined (tree : Inlined )(using Context ): tree.type =
167
165
transformAllDeep(tree.call)
168
- val _ = refInfos.inlined.pop()
169
166
tree
170
167
171
168
override def prepareForBind (tree : Bind )(using Context ): Context =
@@ -500,7 +497,7 @@ object CheckUnused:
500
497
val nowarn = mutable.Set .empty[Symbol ] // marked @nowarn
501
498
val imps = new IdentityHashMap [Import , Unit ] // imports
502
499
val sels = new IdentityHashMap [ImportSelector , Unit ] // matched selectors
503
- def register (tree : Tree )(using Context ): Unit = if inlined .isEmpty then
500
+ def register (tree : Tree )(using Context ): Unit = if enclosingInlineds .isEmpty then
504
501
tree match
505
502
case imp : Import =>
506
503
if inliners == 0
@@ -529,7 +526,6 @@ object CheckUnused:
529
526
if tree.symbol ne NoSymbol then
530
527
defs.addOne((tree.symbol, tree.srcPos)) // TODO is this a code path
531
528
532
- val inlined = Stack .empty[SrcPos ] // enclosing call.srcPos of inlined code (expansions)
533
529
var inliners = 0 // depth of inline def (not inlined yet)
534
530
535
531
// instead of refs.addOne, use addRef to distinguish a read from a write to var
0 commit comments