Skip to content

False positive extension method will never be selected #22821

Closed
@abosshard

Description

@abosshard

Compiler version

3.5.0 and later

Minimized code

//> using scala "3.6.4"

class A:
  def f(i: Int) = ()

extension (self: A)
  def f() = println("extension") // [warn]: Extension method f will never be selected from type A

A().f()

Output

[warn] ./Example.sc:7:6
[warn] Extension method f will never be selected from type A
[warn] because A already has a member with the same name and compatible parameter types.
[warn]  def f() = println("extension") // [warn]: Extension method f will never be selected from type A
[warn]      ^
extension

Expectation

No warning, because the extension method is actually selected in this case.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions