Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wunused: Check if symbol exists before isValidMemberDef check #17316

Merged
merged 1 commit into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -681,7 +681,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 @@ -708,7 +708,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)
KacperFKorban marked this conversation as resolved.
Show resolved Hide resolved

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