Skip to content

eta expansion may not be working correctly with multiple parameter lists #7297

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
aappddeevv opened this issue Sep 23, 2019 · 2 comments
Closed

Comments

@aappddeevv
Copy link

aappddeevv commented Sep 23, 2019

I was expecting that eta expansion (if that's the right term) would pick-up the expansion of the first parameter list but it did not seem to:

scala> def foo(i: Int) = i.toString
def foo(i: Int): String
  | => root / scalaInstance 0s
scala>                                                                                                                        
scala> foo(10)
val res0: String = 10

scala> def processItem(f: Int => String)(v: String): Int = v.toInt
def processItem(f: Int => String)(v: String): Int

scala> processItem(foo)                                                                                                       
val res1: String => Int = Lambda$16681/862216843@14f0c2b6

scala> processItem(foo)("20")
val res2: Int = 20

scala> def lastFunc(f: String => Int): Int = f("20") 
def lastFunc(f: String => Int): Int

scala> lastFunc(processItem(foo))                                                                                             
val res3: Int = 20

scala> import scala.language.implicitConversions

scala> foo pipe processItem pipe lastFunc
1 |foo pipe processItem pipe lastFunc
  |         ^^^^^^^^^^^
  |         The syntax `<function> _` is no longer supported;
  |         you can simply leave out the trailing ` _`

It felt like this was a bug, but I do not know enough about it to determine that. It works if we do processItem(foo) pipe lastFunc.

May be related to #5288.

@OlivierBlanvillain
Copy link
Contributor

Works on master (with import util.chaining.scalaUtilChainingOps)

@aappddeevv
Copy link
Author

Thanks!

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

2 participants