Skip to content

current package not preferred over imported package #5206

Closed
@olhotak

Description

@olhotak

I have three files:

package foo

object A {
  val x = 5
}
package foo.bar

object A {
  val x = "foo"
}
package foo
import foo.bar._

object B {
  val y: Int = A.x
}

They compile with Scala 2.12. With Dotty, I get:

-- [E007] Type Mismatch Error: /tmp/foo/B.scala:5:17 ---------------------------
5 |  val y: Int = A.x
  |               ^^^
  |               found:    String(foo.bar.A.x)
  |               required: Int
  |               
one error found

In object foo.B, Scala 2.12 prefers foo.A over foo.bar.A because foo.A is in the same package. But Dotty seems to prefer foo.bar.A over foo.A because foo.bar.A is being imported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions