@@ -520,7 +520,7 @@ object CheckUnused:
520
520
.filterNot(d => usedInPosition.exists { case (pos, name) => d.span.contains(pos.span) && name == d.symbol.name})
521
521
.filterNot(d => containsSyntheticSuffix(d.symbol))
522
522
.map(d => UnusedSymbol (d.namePos, d.name, WarnTypes .LocalDefs )).toList
523
- val unsetLocalDefs = unsetVarsFromUsedSym( usedLocalDefs).map(d => UnusedSymbol (d.namePos, d.name, WarnTypes .UnsetLocals )).toList
523
+ val unsetLocalDefs = usedLocalDefs.filter(isUnsetVarDef ).map(d => UnusedSymbol (d.namePos, d.name, WarnTypes .UnsetLocals )).toList
524
524
525
525
val sortedExplicitParams =
526
526
if ctx.settings.WunusedHas .explicits then
@@ -546,7 +546,7 @@ object CheckUnused:
546
546
else
547
547
(Nil , Nil )
548
548
val sortedPrivateDefs = unusedPrivates.filterNot(d => containsSyntheticSuffix(d.symbol)).map(d => UnusedSymbol (d.namePos, d.name, WarnTypes .PrivateMembers )).toList
549
- val unsetPrivateDefs = unsetVarsFromUsedSym( usedPrivates).map(d => UnusedSymbol (d.namePos, d.name, WarnTypes .UnsetPrivates )).toList
549
+ val unsetPrivateDefs = usedPrivates.filter(isUnsetVarDef ).map(d => UnusedSymbol (d.namePos, d.name, WarnTypes .UnsetPrivates )).toList
550
550
val sortedPatVars =
551
551
if ctx.settings.WunusedHas .patvars then
552
552
patVarsInScope
@@ -745,10 +745,13 @@ object CheckUnused:
745
745
! isSyntheticMainParam(sym) &&
746
746
! sym.shouldNotReportParamOwner
747
747
748
-
749
748
private def shouldReportPrivateDef (using Context ): Boolean =
750
749
currScopeType.top == ScopeType .Template && ! memDef.symbol.isConstructor && memDef.symbol.is(Private , butNot = SelfName | Synthetic | CaseAccessor )
751
750
751
+ private def isUnsetVarDef (using Context ): Boolean =
752
+ val sym = memDef.symbol
753
+ sym.is(Mutable ) && ! setVars(sym)
754
+
752
755
extension (imp : tpd.Import )
753
756
/** Enum generate an import for its cases (but outside them), which should be ignored */
754
757
def isGeneratedByEnum (using Context ): Boolean =
@@ -758,9 +761,6 @@ object CheckUnused:
758
761
private def isWildcard : Boolean =
759
762
thisName == StdNames .nme.WILDCARD || thisName.is(WildcardParamName )
760
763
761
- def unsetVarsFromUsedSym (usedDefs : Iterable [tpd.MemberDef ])(using Context ): Iterable [tpd.MemberDef ] =
762
- usedDefs.filter(d => d.symbol.is(Mutable ) && ! setVars(d.symbol))
763
-
764
764
end UnusedData
765
765
766
766
private object UnusedData :
0 commit comments