-
Notifications
You must be signed in to change notification settings - Fork 1.1k
No warning for parameter of overriding method #22757
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
Conversation
@som-snytt what's the reasoning behind the option being I'd rather have smth like |
@Gedochao I think a "fix" or workaround (for the expectation that it doesn't warn when overriding) is useful for 3.7. (I like that this is a small delta in LOC.) Experience suggests that a "false positive" or noise makes a warning unusable. OTOH, altering settings (names or behaviors) makes cross-compilation harder. Maybe that is less of a concern in LTS world? Currently, we're stuck with If a I didn't do that because I wanted to make progress on "strict" mode; this is a gray area because offering too many "knobs" is counterproductive: it's awkward to configure the build, and only the typelevel plugin handles the "matrix" of options. I just talked myself into "default to fewest warnings." Am I permitted to offer |
Edit: I will push without |
e3005f0
to
f25adb9
Compare
Of course I must update other check files, because the "no warning" is unconditional now. |
Example where I would say this rule is suboptimal.
I think it must be written The "trivial RHS" check tries to cover "obvious that parameters are not used", such that it's not likely to be human error. However, if start coding with a "default" RHS (that does not warn), what if I "forget" to improve it. (Presumably, a test is also lacking.) "Dev" mode could be lax, "Integration/C.I." mode could be strict. Similarly |
f25adb9
to
825baf9
Compare
Fixes #22895 Fixes #22896 Follow-up to #22729 Follow-up to #22757 Since Scala 2, the check for unused parameters does not warn for an overriding method, since the signature is dictated by the overridden method. That behavior was intentionally omitted in 3.7 because it was introduced in Scala 2 before `@nowarn` and `@unused` were available. (The warning would be too noisy without mitigation.) A compiler option for these heuristics was tried in a previous commit, but reverted. (Compiler options are difficult to evolve once added.) So these commits restore this heuristic without further ado. An option for "strict mode" without allowances is future work. The other issue was that detecting an override in a Java parent did not work. The commit always checks `is(Override)` before searching for an overridden member, since it is not necessary to verify the modifier (which happens in RefChecks). Incorrect overriding would result in false negatives, which is acceptable since it will error later. Further asymmetry between checking implicit params and explicit class param accessors may or may not be dubious.
Quiet the unused parameter warning when the method is an override.
Fixes #22742