@@ -58,10 +58,8 @@ 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
- val inlineds = enclosingInlineds // per current context
62
- inlineds.isEmpty
61
+ tree.srcPos.isUserCode
63
62
|| tree.srcPos.isZeroExtentSynthetic // take as summonInline
64
- || inlineds.last.srcPos.sourcePos.contains(tree.srcPos.sourcePos)
65
63
if resolving && ! ignoreTree(tree) then
66
64
def loopOverPrefixes (prefix : Type , depth : Int ): Unit =
67
65
if depth < 10 && prefix.exists && ! prefix.classSymbol.isEffectiveRoot then
@@ -497,7 +495,7 @@ object CheckUnused:
497
495
val nowarn = mutable.Set .empty[Symbol ] // marked @nowarn
498
496
val imps = new IdentityHashMap [Import , Unit ] // imports
499
497
val sels = new IdentityHashMap [ImportSelector , Unit ] // matched selectors
500
- def register (tree : Tree )(using Context ): Unit = if enclosingInlineds.isEmpty then
498
+ def register (tree : Tree )(using Context ): Unit = if tree.srcPos.isUserCode then
501
499
tree match
502
500
case imp : Import =>
503
501
if inliners == 0
@@ -1036,6 +1034,10 @@ object CheckUnused:
1036
1034
extension (pos : SrcPos )
1037
1035
def isZeroExtentSynthetic : Boolean = pos.span.isSynthetic && pos.span.isZeroExtent
1038
1036
def isSynthetic : Boolean = pos.span.isSynthetic && pos.span.exists
1037
+ def isUserCode (using Context ): Boolean =
1038
+ val inlineds = enclosingInlineds // per current context
1039
+ inlineds.isEmpty
1040
+ || inlineds.last.srcPos.sourcePos.contains(pos.sourcePos)
1039
1041
1040
1042
extension [A <: AnyRef ](arr : Array [A ])
1041
1043
// returns `until` if not satisfied
0 commit comments