Skip to content

Extension method name collision across different source files #13089

Closed
@soronpo

Description

@soronpo

Different extension methods in the same package, with the same name, but in different files collide.
If defined in the same source file no error.

Compiler version

v3.0.1

Minimized code

Minimized project at: https://github.com/soronpo/dottybug/tree/extension_collision

Test/Foo.scala

package Test

trait Foo
extension (foo : Foo)
  def fails : Unit = {}
  def works : Unit = {}

extension (bar : Bar)
  def works : Unit = {}

Test/Bar.scala

package Test

trait Bar
extension (bar : Bar)
  def fails : Unit = {}

Output

[error] -- [E161] Naming Error: C:\IdeaProjects\dottybug\src\main\scala\Test\Foo.scala:5:6 ----------------------------------
[error] 5 |  def fails : Unit = {}
[error]   |  ^^^^^^^^^^^^^^^^^^^^^
[error]   |  fails is already defined as method fails in C:\IdeaProjects\dottybug\src\main\scala\Test\Bar.scala

Expectation

No error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions