-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Parameter untupling and automatic eta-expansion don't always mix #11185
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
Looks like they forgot about the tuple adaptation while testing applicability during overload resolution.
I don't know Dotty's pronoun preference. This doesn't work: scala> val f2 = f
val f2: (Int, Int) => Int = Lambda$1686/0x00000008010b2ff8@ff03384
scala> xs.map(f2)
1 |xs.map(f2)
| ^^
| Found: (f2 : (Int, Int) => Int)
| Required: ((Int, Int)) => <?>
1 |xs.map(f2)
|^^^^^^
|None of the overloaded alternatives of method map in trait IterableOps with types
| [B](f: ((Int, Int)) => B): scala.collection.immutable.Iterable[B]
| [K2, V2](f: ((Int, Int)) => (K2, V2)): Map[K2, V2]
|match arguments ((f2 : (Int, Int) => Int))
scala> f(_,_): (((Int,Int)) => Int)
1 |f(_,_): (((Int,Int)) => Int)
| ^
| Missing parameter type
|
| I could not infer the type of the parameter _$1.
1 |f(_,_): (((Int,Int)) => Int)
| ^
| Missing parameter type
|
| I could not infer the type of the parameter _$2. Actually that needs parens: |
Even weirder then that And without overloading, both
Either way I would expect |
The fact that the following program is rejected is expected: def foo(a: Int, b: Int) = a + b
val f = foo
Map(1 -> 2).map(f) // error
Map(1 -> 2).map(foo) // ok after fix in #12171
Map(1 -> 2).map(foo _) // ok The spec says that parameter untupling only works for a function literal but it composes with eta-expansion. |
Fix #11185: cache pretyped argument with adaptation in FunProto
Minimized code
Output
Expectation
Since the compiler can pick the right overload with explicit eta-expansion, I don't see why he can't do that with automatic eta-expansion.
The text was updated successfully, but these errors were encountered: