Skip to content

Bad overload resolution with package object extension #13149

@som-snytt

Description

@som-snytt

Reproduction steps

Scala version: 2.13.18

package p {
  object X extends App {
    B.f(0) // ok
    q.f(0) // nope
  }

  trait A {
    def f(x: String): String
  }

  package q {
    object `package` extends A {
      def f(x: Int): String    = ???
      def f(x: String): String = ???
    }
  }

  object B extends A {
    def f(x: Int): String    = ???
    def f(x: String): String = ???
  }
}

Problem

scala-cli compile --server=false -S 2.13.18 test/files/pos/po-overload.scala
/home/amarki/projects/scala/test/files/pos/po-overload.scala:4: error: type mismatch;
 found   : Int(0)
 required: String
    q.f(0) // nope
        ^
1 error
Compilation failed

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions