Open
Description
Compiler version
3.1.2
Minimized code
case class Foo(a: Int, b: String)
val foo = Foo(1, "Hello")
var x: Tuple2[Int, String] = Tuple.fromProductTyped(foo)
var y: Product2[Int, String] = x
var z: Product2[Int, String] = Tuple.fromProductTyped(foo)
Output
-- [E007] Type Mismatch Error: -------------------------------------------------
5 |var z: Product2[Int, String] = Tuple.fromProductTyped(foo)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
| Found: (Int, String)
| Required: Product2[Int, String]
Explanation
===========
Tree: Tuple.fromProductTyped[Foo](foo)(
Foo.$asInstanceOf[
(
deriving.Mirror.Product{
MirroredType = Foo; MirroredMonoType = Foo; MirroredElemTypes <: Tuple
}
&
scala.deriving.Mirror.Product{
MirroredMonoType = Foo; MirroredType = Foo;
MirroredLabel = ("Foo" : String)
}
){
MirroredElemTypes = (Int, String);
MirroredElemLabels = (("a" : String), ("b" : String))
}
]
)
I tried to show that
(Int, String)
conforms to
Product2[Int, String]
but the comparison trace ended with `false`:
==> (Int, String) <: Product2[Int, String]
<== (Int, String) <: Product2[Int, String] = false
The tests were made under the empty constraint
Expectation
As (A, B) = Tuple2[A, B] is a direct subclass of Product2[Int, String], I would expect that the assignment to z compiles.