Pattern Matching with Type Parameter variable

You can do the same trick with regular tuples:

  def test1(param: (_, _)): Unit = {
    param match {
      case t: Tuple2[b, c] =>
        val bF: String => Either[String, b] = ???
        val cF: String => Either[String, c] = ???
    }
  }

although you can do it differently:

  def test2(param: (_, _)): Unit = {
    param match {
      case (b: AnyRef, c: AnyRef) => // AnyRefs to silence compiler errors
        val bF: String => Either[String, b.type] = ???
        val cF: String => Either[String, c.type] = ???
    }
  }

I suspect the types b and c in test1 and b.type and c.type in test2 are called path dependent types, but I’m not sure.