Skip to content

False positive warning for extension method (taking Seq) shadowing (varargs) #24198

@eejbyfeldt

Description

@eejbyfeldt

Compiler version

3.7.3, 3.8.0-RC1-bin-20251017-96aff06-NIGHTLY

Minimized code

object test {
  class A {
    def m(p: String*): Unit = println("member")
  }
  extension (a: A) def m(p: Seq[String]): Unit = println("extension")

  def main(args: Array[String]): Unit = {
    (new A).m(Seq[String]())
  }
}

Output

$ scala-cli -S 3.nightly extension.scala 
Compiling project (Scala 3.8.0-RC1-bin-20251017-96aff06-NIGHTLY, JVM (21))
[warn] ./extension.scala:3:24
[warn] Extension method m will never be selected from type A
[warn] because A already has a member with the same name and compatible parameter types.
[warn]   extension (a: A) def m(p: Seq[String]): Unit = println("extension")
[warn]                        ^
Compiled project (Scala 3.8.0-RC1-bin-20251017-96aff06-NIGHTLY, JVM (21))
extension

Expectation

The compiler should not produce a warning. The warning is a false positive because the extension method is selected and called.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions