-
Notifications
You must be signed in to change notification settings - Fork 21
Type inference doesn't work for implicitly converted functions #6221
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6221?orig=1
|
@heathermiller said: The following seems to happen. In the case of In the case of -Ydebug -Ylog:typer output for the [log typer] inferring view from scala.this.Function1[<error>,<error>] to <empty>.this.MyFunc[scala.this.Int,?]
[log typer] infer view from scala.this.Function1[<error>,<error>] to <empty>.this.MyFunc[scala.this.Int,?] In both cases, implicit search does not have an influence on inferring the type of the argument of |
@hubertp said: |
@heathermiller said: |
Matei Zaharia (matei) said: |
@hubertp said: |
@paulp said: |
The Scala compiler does not infer the argument types for function expressions (e.g. x => x+1) when the function is passed to a method that requires it to be implicitly converted to another type, even though it does infer the types of other objects in a similar situation. (Thanks to Heather Miller for pointing out the second case.) For example, take a look at the attached test2.scala:
This is a problem for cases where you want to represent functions through some richer class, or to apply a macro to function expressions passed to a set of methods. For example, in Spark, I would like to apply a macro to all closure expressions passed to map(), filter(), groupBy(), and other operations in order to properly bind variables, and I would've liked to do this through an implicit conversion macro from Function1[A, B] to ShippableFunction[A, B]. Because of this bug, this can't be done without losing type inference. It would be nice to add it in this case since it seems that the types for other objects can be inferred anyway.
The text was updated successfully, but these errors were encountered: