Skip to content

Overload resolution with FunctionN as expected type #4831

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
allanrenucci opened this issue Jul 24, 2018 · 1 comment
Closed

Overload resolution with FunctionN as expected type #4831

allanrenucci opened this issue Jul 24, 2018 · 1 comment
Labels
area:typer backlog No work planned on this by the core team for the time being. compat:scala2 itype:bug

Comments

@allanrenucci
Copy link
Contributor

object Test {
  def foo(c: String => Int) = c("Hello")

  def f(x: String): Int = 1
  def f: String => Int = _ => 2

  def main(args: Array[String]): Unit = {
    foo(f) // Dotty: 1, Scala 2: 2
  }
}

Overload resolution differs between Dotty and Scala2. dotc eta-expand the first overload, scalac picks the second overload

@som-snytt
Copy link
Contributor

This is less mystifying now, so it shan't be considered for dotty puzzlers, I'm afraid, despite its glowing recommendation.

➜  snips scala-cli run --server=false -S 2.13.15 i4831.scala
2
➜  snips scala-cli run --server=false -S 3.5.2 i4831.scala
2

Progressed in #19654 for 3.4.1 and backported to 3.3.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typer backlog No work planned on this by the core team for the time being. compat:scala2 itype:bug
Projects
None yet
Development

No branches or pull requests

3 participants