-
Notifications
You must be signed in to change notification settings - Fork 1.1k
-Wunused:explicits
false negative for a method parameter in some cases
#17742
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
Comments
I believe some of the compiler's behavior here is correct @ruurtjan -- def foo1(bar: Int) = {
val baz = 1 match
case bar => "hello"
baz
}
foo1(2)
// "hello"
// Now using backticks
def foo2(bar: Int) = {
val baz = 1 match
case `bar` => "hello"
baz
}
foo2(2)
// scala.MatchError... However this still doesn't explain why removing |
-Wunused:explicits
incorrectly flags function parameter in some cases-Wunused:explicits
false negative for a method parameter in some cases
Scala 2.13.12 will lint the pattern var shadowing the definition in scope; it caught a test that wasn't testing anything, so it happens. Hopefully Scala 3 will also get the lint. |
Ah, you're right @mrdziuban! In that case, upgrading to 3.3.0 and enabling I'll leave this issue open for the false negative issue. |
It's the expected behaviour. Removing |
Edit: see @mrdziuban's comment for clarification
The following reproducer flags a used parameter as unused. Changing any of the following will cause the compilation to succeed:
private
keywordval baz =
andbaz
Compiler version
Tested on 3.3.0 and 3.3.1-RC1
Minimized code
Output
Expectation
Compile without warning.
The text was updated successfully, but these errors were encountered: