Skip to content

Constraint resolution failing for match type argument #6505

Closed
@nicolasstucki

Description

@nicolasstucki
class Foo {

  type E[X]

  def i: Int = ???
  def e: E[Int] = ???

  // Transforms `(T1, ... Tn)` into `(E[T1], ..., E[Tn])`
  type F[T <: Tuple] <: Tuple = T match {
    case Unit => Unit
    case h *: t => E[h] *: F[t]
  }

  def foo1[Args <: Tuple](args: Args, args2: F[Args]): Unit = ()

  foo1((i, i), (e, e)) // fails
  foo1((i, i), (e, e): F[(Int, Int)]) // fails

}

fails with

-- [E007] Type Mismatch Error: Foo.scala:16:15 ---------------------------------
16 |  foo1((i, i), (e, e)) // fails
   |               ^^^^^^
   |Found:    (Foo.this.E[Int], Foo.this.E[Int])
   |Required: Foo.this.F[Args]
   |
   |where:    Args is a type variable with constraint >: (Int, Int) and <: Tuple
-- [E007] Type Mismatch Error: Foo.scala:17:15 ---------------------------------
17 |  foo1((i, i), (e, e): F[(Int, Int)]) // fails
   |               ^^^^^^^^^^^^^^^^^^^^^
   |Found:    Foo.this.E[Int] *: Foo.this.E[Int] *: Foo.this.F[Unit]
   |Required: Foo.this.F[Args]
   |
   |where:    Args is a type variable with constraint >: (Int, Int) and <: Tuple

where Args should be inferred as (Int, Int).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions