@@ -517,7 +517,7 @@ object CheckUnused:
517
517
def checkPrivate (sym : Symbol , pos : SrcPos ) =
518
518
if ctx.settings.WunusedHas .privates
519
519
&& ! sym.isPrimaryConstructor
520
- && sym.is( Private , butNot = SelfName | Synthetic | CaseAccessor )
520
+ && ! sym.isOneOf( SelfName | Synthetic | CaseAccessor )
521
521
&& ! sym.name.is(BodyRetainerName )
522
522
&& ! sym.isSerializationSupport
523
523
&& ! (sym.is(Mutable ) && sym.isSetter && sym.owner.is(Trait )) // tracks sym.underlyingSymbol sibling getter
@@ -758,7 +758,7 @@ object CheckUnused:
758
758
for (sym, pos) <- infos.defs.iterator if ! sym.hasAnnotation(defn.UnusedAnnot ) do
759
759
if infos.refs(sym) then
760
760
checkUnassigned(sym, pos)
761
- else if sym.is( Private , butNot = ParamAccessor ) then
761
+ else if sym.isEffectivelyPrivate then
762
762
checkPrivate(sym, pos)
763
763
else if sym.is(Param , butNot = Given | Implicit ) then
764
764
checkParam(sym, pos)
@@ -879,6 +879,9 @@ object CheckUnused:
879
879
sym.isClass && sym.info.allMembers.forall: d =>
880
880
val m = d.symbol
881
881
! m.isTerm || m.isSelfSym || m.is(Method ) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass )
882
+ def isEffectivelyPrivate (using Context ): Boolean =
883
+ sym.is(Private , butNot = ParamAccessor )
884
+ || sym.owner.isAnonymousClass && ! sym.nextOverriddenSymbol.exists
882
885
883
886
extension (sel : ImportSelector )
884
887
def boundTpe : Type = sel.bound match
0 commit comments