Skip to content

Failure to lift a FunctionN to Function1[TupleN[...], ...] #12127

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
mpilquist opened this issue Apr 17, 2021 · 3 comments · Fixed by #12135
Closed

Failure to lift a FunctionN to Function1[TupleN[...], ...] #12127

mpilquist opened this issue Apr 17, 2021 · 3 comments · Fixed by #12135
Milestone

Comments

@mpilquist
Copy link
Contributor

Compiler version

3.0.0-RC2

Minimized code

scala> Option((1, 2, 3)).map(_ + _ + _)
val res0: Option[Int] = Some(6)

scala> def foo[T <: Tuple : Tuple.IsMappedBy[Option]](t: T)(f: Tuple.InverseMap[T, Option] => Int) = null
def foo
  [T <: Tuple]
    (t: T)
      (f: Tuple.InverseMap[T, Option] => Int)
        (implicit evidence$1: Tuple.IsMappedBy[Option][T]): Null

scala> foo(Option(1), Option(2), Option(3))(_ + _ + _)
1 |foo(Option(1), Option(2), Option(3))(_ + _ + _)
  |                                     ^^^^^^^^^
  |                                   Wrong number of parameters, expected: 1

Expectation

_ + _ + _ should be automatically lifted from Function3[Int, Int, Int, Int] to Function1[Tuple3[Int, Int, Int], Int]

@odersky
Copy link
Contributor

odersky commented Apr 17, 2021

Why "should be"? Is it a bug or a language enhancement?

@mpilquist
Copy link
Contributor Author

@odersky Not sure which, though why does it work sometimes, like in the Option(1, 2, 3).map(_ + _ + _) example?

@odersky
Copy link
Contributor

odersky commented Apr 17, 2021

That's because of parameter untupling. Let me see whether we can generalize that.

odersky added a commit to dotty-staging/dotty that referenced this issue Apr 18, 2021
odersky added a commit to dotty-staging/dotty that referenced this issue Apr 19, 2021
odersky added a commit to dotty-staging/dotty that referenced this issue Apr 20, 2021
michelou pushed a commit to michelou/scala3 that referenced this issue Apr 21, 2021
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants