@@ -7,7 +7,7 @@ import dotty.tools.dotc.config.ScalaSettings
7
7
import dotty .tools .dotc .core .Contexts .*
8
8
import dotty .tools .dotc .core .Flags .*
9
9
import dotty .tools .dotc .core .Names .{Name , SimpleName , DerivedName , TermName , termName }
10
- import dotty .tools .dotc .core .NameOps .{isAnonymousFunctionName , isReplWrapperName , isContextFunction }
10
+ import dotty .tools .dotc .core .NameOps .{isAnonymousFunctionName , isReplWrapperName , isContextFunction , setterName }
11
11
import dotty .tools .dotc .core .NameKinds .{
12
12
BodyRetainerName , ContextBoundParamName , ContextFunctionParamName , DefaultGetterName , WildcardParamName }
13
13
import dotty .tools .dotc .core .StdNames .nme
@@ -543,7 +543,13 @@ object CheckUnused:
543
543
if sym.isLocalToBlock then
544
544
if ctx.settings.WunusedHas .locals && sym.is(Mutable ) && ! infos.asss(sym) then
545
545
warnAt(pos)(UnusedSymbol .unsetLocals)
546
- else if ctx.settings.WunusedHas .privates && sym.isAllOf(Private | Mutable ) && ! infos.asss(sym) then
546
+ else if ctx.settings.WunusedHas .privates
547
+ && sym.is(Mutable )
548
+ && (sym.is(Private ) || sym.isEffectivelyPrivate)
549
+ && ! sym.isSetter // tracks sym.underlyingSymbol sibling getter, check setter below
550
+ && ! infos.asss(sym)
551
+ && ! infos.refs(sym.owner.info.member(sym.name.asTermName.setterName).symbol)
552
+ then
547
553
warnAt(pos)(UnusedSymbol .unsetPrivates)
548
554
549
555
def checkPrivate (sym : Symbol , pos : SrcPos ) =
@@ -552,7 +558,10 @@ object CheckUnused:
552
558
&& ! sym.isOneOf(SelfName | Synthetic | CaseAccessor )
553
559
&& ! sym.name.is(BodyRetainerName )
554
560
&& ! sym.isSerializationSupport
555
- && ! (sym.is(Mutable ) && sym.isSetter && sym.owner.is(Trait )) // tracks sym.underlyingSymbol sibling getter
561
+ && ! ( sym.is(Mutable )
562
+ && sym.isSetter // tracks sym.underlyingSymbol sibling getter
563
+ && (sym.owner.is(Trait ) || sym.owner.isAnonymousClass)
564
+ )
556
565
&& ! infos.nowarn(sym)
557
566
then
558
567
warnAt(pos)(UnusedSymbol .privateMembers)
0 commit comments