@@ -581,7 +581,7 @@ object CheckUnused:
581
581
end checkExplicit
582
582
// begin
583
583
if ! infos.skip(m)
584
- && ! m.nextOverriddenSymbol.exists
584
+ && ! m.isEffectivelyOverride
585
585
&& ! allowed
586
586
then
587
587
checkExplicit()
@@ -883,20 +883,20 @@ object CheckUnused:
883
883
inline def exists (p : Name => Boolean ): Boolean = nm.ne(nme.NO_NAME ) && p(nm)
884
884
inline def isWildcard : Boolean = nm == nme.WILDCARD || nm.is(WildcardParamName )
885
885
886
- extension (tp : Type )
887
- def importPrefix ( using Context ) : Type = tp match
886
+ extension (tp : Type )( using Context )
887
+ def importPrefix : Type = tp match
888
888
case tp : NamedType => tp.prefix
889
889
case tp : ClassInfo => tp.prefix
890
890
case tp : TypeProxy => tp.superType.normalizedPrefix
891
891
case _ => NoType
892
- def underlyingPrefix ( using Context ) : Type = tp match
892
+ def underlyingPrefix : Type = tp match
893
893
case tp : NamedType => tp.prefix
894
894
case tp : ClassInfo => tp.prefix
895
895
case tp : TypeProxy => tp.underlying.underlyingPrefix
896
896
case _ => NoType
897
- def skipPackageObject ( using Context ) : Type =
897
+ def skipPackageObject : Type =
898
898
if tp.typeSymbol.isPackageObject then tp.underlyingPrefix else tp
899
- def underlying ( using Context ) : Type = tp match
899
+ def underlying : Type = tp match
900
900
case tp : TypeProxy => tp.underlying
901
901
case _ => tp
902
902
@@ -913,6 +913,9 @@ object CheckUnused:
913
913
sym.isClass && sym.info.allMembers.forall: d =>
914
914
val m = d.symbol
915
915
! m.isTerm || m.isSelfSym || m.is(Method ) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass )
916
+ def isEffectivelyPrivate : Boolean =
917
+ sym.is(Private , butNot = ParamAccessor )
918
+ || sym.owner.isAnonymousClass && ! sym.isEffectivelyOverride
916
919
def isEffectivelyOverride : Boolean =
917
920
sym.is(Override )
918
921
||
@@ -921,9 +924,6 @@ object CheckUnused:
921
924
val base = if owner.classInfo.selfInfo != NoType then owner.thisType else owner.info
922
925
base.baseClasses.drop(1 ).iterator.exists(sym.overriddenSymbol(_).exists)
923
926
}
924
- def isEffectivelyPrivate : Boolean =
925
- sym.is(Private , butNot = ParamAccessor )
926
- || sym.owner.isAnonymousClass && ! sym.nextOverriddenSymbol.exists
927
927
// pick the symbol the user wrote for purposes of tracking
928
928
inline def userSymbol : Symbol =
929
929
if sym.denot.is(ModuleClass ) then sym.denot.companionModule else sym
@@ -939,21 +939,21 @@ object CheckUnused:
939
939
case untpd.Ident (nme.WILDCARD ) => true
940
940
case _ => false
941
941
942
- extension (imp : Import )
942
+ extension (imp : Import )( using Context )
943
943
/** Is it the first import clause in a statement? `a.x` in `import a.x, b.{y, z}` */
944
- def isPrimaryClause ( using Context ) : Boolean =
944
+ def isPrimaryClause : Boolean =
945
945
imp.srcPos.span.pointDelta > 0 // primary clause starts at `import` keyword with point at clause proper
946
946
947
947
/** Generated import of cases from enum companion. */
948
- def isGeneratedByEnum ( using Context ) : Boolean =
948
+ def isGeneratedByEnum : Boolean =
949
949
imp.symbol.exists && imp.symbol.owner.is(Enum , butNot = Case )
950
950
951
951
/** Under -Wunused:strict-no-implicit-warn, avoid false positives
952
952
* if this selector is a wildcard that might import implicits or
953
953
* specifically does import an implicit.
954
954
* Similarly, import of CanEqual must not warn, as it is always witness.
955
955
*/
956
- def isLoose (sel : ImportSelector )( using Context ) : Boolean =
956
+ def isLoose (sel : ImportSelector ): Boolean =
957
957
if ctx.settings.WunusedHas .strictNoImplicitWarn then
958
958
if sel.isWildcard
959
959
|| imp.expr.tpe.member(sel.name.toTermName).hasAltWith(_.symbol.isOneOf(GivenOrImplicit ))
0 commit comments