Skip to content

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

Closed
@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.

Activity

changed the title [-]Probably regression in v3.7.x: false positive warning with `-Wunused:explicit`[/-] [+]Probably regression in v3.7.x: false positive warning with `-Wunused:explicits`[/+] on Jun 10, 2025
SethTisue

SethTisue commented on Jun 10, 2025

@SethTisue
Member

@som-snytt a bit of collateral damage from #20894 perhaps?

som-snytt

som-snytt commented on Jun 10, 2025

@som-snytt
Contributor

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.

self-assigned this
on Jun 10, 2025
added
area:lintingLinting warnings enabled with -W or -Xlint
and removed
stat:needs triageEvery issue needs to have an "area" and "itype" label
on Jun 10, 2025
satorg

satorg commented on Jun 10, 2025

@satorg
Author

Btw, just realized that it's also the case with implict parameters too:

//> using scala 3.7.nightly
//> using options -Wunused:implicits

class Foo(val a: String)

def copyFoo(using foo: Foo)(a: String = foo.a): Foo = Foo(a)

which triggers

-- [E198] Unused Symbol Warning: .../unused-implicit-params.scala:7:18
7 |def copyFoo(using foo: Foo)(a: String = foo.a): Foo = Foo(a)
  |                  ^^^
  |                  unused implicit parameter

in Scala 3.7 only.

added a commit that references this issue on Jun 17, 2025
a110500
added this to the 3.7.2 milestone on Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @SethTisue@som-snytt@satorg@WojciechMazur

    Issue actions

      Probably regression in v3.7.x: false positive warning with `-Wunused:explicits` · Issue #23349 · scala/scala3