Skip to content
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

Type inference works differently for method types (a : => A)(b : A => B) and (a : => A, b : A => B) #4657

Closed
scabug opened this issue May 29, 2011 · 2 comments

Comments

@scabug
Copy link

scabug commented May 29, 2011

The method m1 and m2 are logically equivalent and the type inference should be able to handle them with the same level of success. However for the second one, the type inference fails and requires type annotation for the argument. I think that it should not. If you are able to handle m1, there should be no problem with handling m2.

class ParamTest {

  def m1[A,B](a : => A)(b : A => B) : B = b(a)

  def m2[A,B](a : => A, b : A => B) : B = m1(a)(b)

  def test1() {
    m1(1+2)(println(_)) // compiles successfully
    m2(1+2, println(_ : Int)) // compiles successfully
    m2(1+2, println(_)) // does not compile
  }
}
@scabug
Copy link
Author

scabug commented May 29, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4657?orig=1
Reporter: Constantine Plotnikov (const)
Affected Versions: 2.9.0

@scabug
Copy link
Author

scabug commented May 29, 2011

@paulp said:
Please ask about type inference on the mailing lists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant