[Solved] Type equivalence fails when x.type is used. Why?

I have the following code in Scala3/Dotty that works as expected:

    val tp10: (Int, Int, Int) = (1,2,3)
    summon[tp6.type =:= tp6.type]
    summon[(Int,Int,Int) =:= (Int,Int,Int)]
    summon[(Int,Int,Int) <:< (Int,Int,Int)]
    summon[tp10.type <:< (Int,Int,Int)]

But these cases fail:

    val tp10: (Int, Int, Int) = (1,2,3)
    summon[tp10.type =:= (Int,Int,Int)] // fail
    summon[(Int,Int,Int) =:= tp10.type] // fail
    summon[(Int,Int,Int) <:< tp10.type] // fail

I expect the equivalence testing to succeed. Am I correct? If not, why?

I am trying to get the following to work:

    summon[Tuple.Map[tp6.type, NumericType] =:= tp6.type] // fail

which produces the error:

[error] 608 |    summon[Tuple.Map[tp6.type, NumericType] =:= tp6.type] // fail
[error]     |                                                         ^
[error]     |Cannot prove that Int *: NumericType[Int] *: 
[error]     |  scala.Tuple.Map[Int *: scala.Tuple$package.EmptyTuple.type, NumericType] =:= (tp6 : (Int, Int, Int)).
[error] one error found

Hence the use of .type


1 Like

Possibly related to this question:

As explained here, and I quote:

foo.type is the singleton type of the value foo , so it will be a subtype of the type of foo but it’s not equal to it since the type of foo might contain other members, there is nothing specific to tuples here.


    summon[1 <:< Int]
    summon[2 <:< Int]
    summon[(1,2) <:< (Int,Int)]
    summon[(2,1) <:< (Int,Int)]