-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Suppress "extension method will never be selected" for overrides #20164
Conversation
In daeee35, support for tests in the directory `tests/pos-special/fatal-warnings` was dropped in favor of magic `//>` comments in the regular `tests/pos` directory, but a few tests were forgotten in the original directory and were thus not run. This commit moves them to the appropriate directory with the correct magic comment.
When we're overriding an existing extension method, we don't have the liberty of renaming the method, so we shouldn't get warnings we can't do anything about.
@@ -1,4 +1,4 @@ | |||
//> using options -Wvalue-discard | |||
//> using options -Xfatal-warnings -Wvalue-discard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i.e. -Werror
if !target.typeSymbol.denot.isAliasType && !target.typeSymbol.denot.isOpaqueAlias && hidden | ||
then report.warning(ExtensionNullifiedByMember(sym, target.typeSymbol), sym.srcPos) | ||
def checkExtensionMethods(sym: Symbol)(using Context): Unit = | ||
if sym.is(Extension) && !sym.nextOverriddenSymbol.exists then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the actual diff
This is like the mitigation for "unused param" which says that if my method signature is constrained by an override, don't warn. Here, I must supply the given (for some purpose), and I'm not interested in this extension. I could signal that with a LHS that is But probably this case has an odor of niche. Overriders of extensions probably know what they're doing. From the Doors song, |
When we're overriding an existing extension method, we don't have the liberty
of renaming the method, so we shouldn't get warnings we can't do anything
about.