Skip to content

Cannot infer type of tupled arguments #13526

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
giacomocavalieri opened this issue Sep 14, 2021 · 2 comments · Fixed by #13651
Closed

Cannot infer type of tupled arguments #13526

giacomocavalieri opened this issue Sep 14, 2021 · 2 comments · Fixed by #13651
Milestone

Comments

@giacomocavalieri
Copy link

Compiler version

Scala 3.0.2 (Scastie)

Minimized code

type ~>[Args <: Tuple, Return] = Args match {
  case (arg1, arg2) => ((arg1, arg2) => Return)
}

trait Builder[Args <: NonEmptyTuple] {
  def apply(f: Args ~> String): String
}

class BuilderImpl[Args <: NonEmptyTuple] extends Builder[Args] {
  override def apply(f: Args ~> String): String = ???
}

val builder = BuilderImpl[Int *: String *: EmptyTuple]()
// builder { (i: Int, s: String) => "test" } // This line compiles
builder { (i, s) => "test" } // Does not compile

Output

Missing parameter type I could not infer the type of the parameter i.
Missing parameter type I could not infer the type of the parameter s.

Expectation

No compiler error; I would expect the compiler to be able to infer the type of the function's arguments without annotations.

@nicolasstucki
Copy link
Contributor

Side note

@giacomocavalieri it seems that to use this you would also need TupledFunction. How did you implement the BuilderImpl.apply?

@giacomocavalieri
Copy link
Author

Thanks for the answer! I still haven't tried to implement the apply method since I first wanted to understand why the compiler reported that error

odersky added a commit to dotty-staging/dotty that referenced this issue Oct 1, 2021
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
@Kordyjan Kordyjan added this to the 3.1.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