Closed
Description
Compiler version
The issue is reproducible starting with Scala v3.7.x: 3.7.0, 3.7.1 as well as 3.7.2-RC1-bin-20250609-41cf6eb-NIGHTLY.
It does not appear in Scala v3.3.x and v3.6.x.
Minimized code
//> using scala 3.7.nightly
//> using options -Wunused:explicits
// An external class that doesn't get its own `copy` method.
class Foo(val a: String, val b: Int)
//
// Example 1: add `copy` method via an extension method.
//
extension (self: Foo)
def copy(a: String = self.a, b: Int = self.b): Foo = Foo(a, b)
//
// Example 2: implement `copyFoo` with parameter groups.
//
def copyFoo(foo: Foo)(a: String = foo.a, b: Int = foo.b): Foo = Foo(a, b)
Output
Starting with Scala v3.7.x only:
-- [E198] Unused Symbol Warning: .../unused-explicit-param.scala:10:11
10 |extension (self: Foo)
| ^^^^
| unused explicit parameter in extension method copy
-- [E198] Unused Symbol Warning: .../unused-explicit-param.scala:16:12
16 |def copyFoo(foo: Foo)(a: String = foo.a, b: Int = foo.b): Foo = Foo(a, b)
| ^^^
| unused explicit parameter
2 warnings found
No warnings in Scala v3.6.4 and v3.3.6.
Expectation
No warning whatsoever.
Activity
[-]Probably regression in v3.7.x: false positive warning with `-Wunused:explicit`[/-][+]Probably regression in v3.7.x: false positive warning with `-Wunused:explicits`[/+]SethTisue commentedon Jun 10, 2025
@som-snytt a bit of collateral damage from #20894 perhaps?
som-snytt commentedon Jun 10, 2025
It's not designed to detect usages only in default args, but I also thought it doesn't warn for receivers of extensions.
Previous versions were false negatives anyway.
Edit: forgot to say, thanks for the report!
Also, thanks for the using directives, and for spelling "its" correctly. It's the little things!
Also thanks @SethTisue you are the whitelighter.
satorg commentedon Jun 10, 2025
Btw, just realized that it's also the case with implict parameters too:
which triggers
in Scala 3.7 only.
Nowarn receiver of extension taking params (#23351)