Skip to content

Probably regression in v3.7.x: false positive warning with -Wunused:explicits #23349

Open
@satorg

Description

@satorg

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.

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintitype:bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions