In the following ADT, why is Foo incorrectly inferred for it's type parameter S?
sealed trait Sum[-S, +A]
case class Foo[S]() extends Sum[S, S]
def execute[S, A](mqtt: Sum[S, A], s: S): A =
mqtt match {
// S and A should be the same for Foo
case Foo() => s // should compile but returns an error.
}
Link on scastie https://scastie.scala-lang.org/xD4RqwKYRW20dy4K0GHEDg
