Skip to content

Cannot infer type of tupled arguments #13526

Closed
@giacomocavalieri

Description

@giacomocavalieri

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions