Skip to content

Top-level methods with the same name in the same package overwrite each other #22721

Closed
@mrdziuban

Description

@mrdziuban

Compiler version

3.3.5, 3.4.3, 3.5.2, 3.6.3

Minimized code

// test1.scala
package example

private def foobar: String = "foo"
object test1 { val x = foobar }

// test2.scala
package example

private def foobar: Int = 1
object test2 { val x = foobar }

Output

In the console:

scala> example.test1.x
val res0: String = foo

scala> example.test2.x
val res1: String = foo

Expectation

Ideally the calls to foobar would be scoped properly in each file but I'm guessing that's hard, so at least a compiler warning or error would be nice.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions