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

implicit conversion fails for partially applied functions #438

Closed
scabug opened this issue Feb 4, 2008 · 3 comments
Closed

implicit conversion fails for partially applied functions #438

scabug opened this issue Feb 4, 2008 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Feb 4, 2008

An implicit conversion from a function type to another fails with a funny error message when the argument is a partially-applied function. Here some code:

class Foo {
  implicit def pair2fun2[A, B, C](f: (A, B) => C) = 
     {p: (A, B) => f(p._1, p._2) }

  def foo(f: ((Int, Int)) => Int) = f
  def bar(x: Int, y: Int) = x + y 

  foo({ (x: Int, y: Int) => x + y }) // works
  foo(pair2fun2(bar)) // works
  foo(bar _) // error
  foo(bar)   // same error
}

The errors are:

/home/iuliandragos/sandbox/views.scala:10: error: missing arguments for method bar in class Foo;
follow this method with `_' if you want to treat it as a partially applied function
  foo(bar _) // error
      ^
/home/iuliandragos/sandbox/views.scala:11: error: missing arguments for method bar in class Foo;
follow this method with `_' if you want to treat it as a partially applied function
  foo(bar)   // same error
      ^
two errors found

The first error message is clearly confusing, as the '_' is there... This kind of conversions are very useful when writing (or using) parsing combinators. ;-)

@scabug
Copy link
Author

scabug commented Feb 4, 2008

Imported From: https://issues.scala-lang.org/browse/SI-438?orig=1
Reporter: @dragos

@scabug
Copy link
Author

scabug commented Feb 6, 2008

@odersky said:
fixed in r13905

@scabug
Copy link
Author

scabug commented Jan 14, 2009

@odersky said:
Milestone 2.7.0 deleted

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

No branches or pull requests

2 participants