Skip to content

Commit

Permalink
Wunused: Check if symbol exists before isValidMemberDef check (#17316)
Browse files Browse the repository at this point in the history
closes lampepfl#17309
  • Loading branch information
Kordyjan authored Apr 25, 2023
2 parents 7a6dc76 + 6bf24df commit c9ca7ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ object CheckUnused:
/** A function is overriden. Either has `override flags` or parent has a matching member (type and name) */
private def isOverriden(using Context): Boolean =
sym.is(Flags.Override) ||
(if sym.exists then sym.owner.thisType.parents.exists(p => sym.matchingMember(p).exists) else false)
(sym.exists && sym.owner.thisType.parents.exists(p => sym.matchingMember(p).exists))

end extension

Expand All @@ -709,7 +709,11 @@ object CheckUnused:

extension (memDef: tpd.MemberDef)
private def isValidMemberDef(using Context): Boolean =
!memDef.symbol.isUnusedAnnot && !memDef.symbol.isAllOf(Flags.AccessorCreationFlags) && !memDef.name.isWildcard && !memDef.symbol.owner.is(Extension)
memDef.symbol.exists
&& !memDef.symbol.isUnusedAnnot
&& !memDef.symbol.isAllOf(Flags.AccessorCreationFlags)
&& !memDef.name.isWildcard
&& !memDef.symbol.owner.is(ExtensionMethod)

private def isValidParam(using Context): Boolean =
val sym = memDef.symbol
Expand Down

0 comments on commit c9ca7ce

Please sign in to comment.