@@ -58,10 +58,8 @@ class CheckUnused private (phaseMode: PhaseMode, suffix: String) extends MiniPha
5858 if tree.symbol.exists then
5959 // if in an inline expansion, resolve at summonInline (synthetic pos) or in an enclosing call site
6060 val resolving =
61- val inlineds = enclosingInlineds // per current context
62- inlineds.isEmpty
61+ tree.srcPos.isUserCode
6362 || tree.srcPos.isZeroExtentSynthetic // take as summonInline
64- || inlineds.last.srcPos.sourcePos.contains(tree.srcPos.sourcePos)
6563 if resolving && ! ignoreTree(tree) then
6664 def loopOverPrefixes (prefix : Type , depth : Int ): Unit =
6765 if depth < 10 && prefix.exists && ! prefix.classSymbol.isEffectiveRoot then
@@ -465,7 +463,7 @@ object CheckUnused:
465463 val nowarn = mutable.Set .empty[Symbol ] // marked @nowarn
466464 val imps = new IdentityHashMap [Import , Unit ] // imports
467465 val sels = new IdentityHashMap [ImportSelector , Unit ] // matched selectors
468- def register (tree : Tree )(using Context ): Unit = if enclosingInlineds.isEmpty then
466+ def register (tree : Tree )(using Context ): Unit = if tree.srcPos.isUserCode then
469467 tree match
470468 case imp : Import =>
471469 if inliners == 0
@@ -1004,6 +1002,10 @@ object CheckUnused:
10041002 extension (pos : SrcPos )
10051003 def isZeroExtentSynthetic : Boolean = pos.span.isSynthetic && pos.span.isZeroExtent
10061004 def isSynthetic : Boolean = pos.span.isSynthetic && pos.span.exists
1005+ def isUserCode (using Context ): Boolean =
1006+ val inlineds = enclosingInlineds // per current context
1007+ inlineds.isEmpty
1008+ || inlineds.last.srcPos.sourcePos.contains(pos.sourcePos)
10071009
10081010 extension [A <: AnyRef ](arr : Array [A ])
10091011 // returns `until` if not satisfied
0 commit comments