Skip to content

Commit 1da6599

Browse files
committed
Always trust override modifier
1 parent 8253ee2 commit 1da6599

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ object CheckUnused:
590590
end checkExplicit
591591
// begin
592592
if !infos.skip(m)
593-
&& !m.nextOverriddenSymbol.exists
593+
&& !m.isEffectivelyOverride
594594
&& !allowed
595595
then
596596
checkExplicit()
@@ -614,7 +614,7 @@ object CheckUnused:
614614
|| sym.info.isInstanceOf[RefinedType] // can't be expressed as a context bound
615615
if ctx.settings.WunusedHas.implicits
616616
&& !infos.skip(m)
617-
&& !m.nextOverriddenSymbol.exists
617+
&& !m.isEffectivelyOverride
618618
&& !allowed
619619
then
620620
if m.isPrimaryConstructor then
@@ -924,7 +924,9 @@ object CheckUnused:
924924
!m.isTerm || m.isSelfSym || m.is(Method) && (m.owner == defn.AnyClass || m.owner == defn.ObjectClass)
925925
def isEffectivelyPrivate(using Context): Boolean =
926926
sym.is(Private, butNot = ParamAccessor)
927-
|| sym.owner.isAnonymousClass && !sym.is(Override) && !sym.nextOverriddenSymbol.exists
927+
|| sym.owner.isAnonymousClass && !sym.isEffectivelyOverride
928+
def isEffectivelyOverride(using Context): Boolean =
929+
sym.is(Override) || sym.nextOverriddenSymbol.exists
928930
// pick the symbol the user wrote for purposes of tracking
929931
inline def userSymbol(using Context): Symbol=
930932
if sym.denot.is(ModuleClass) then sym.denot.companionModule else sym

0 commit comments

Comments
 (0)