Why does the following type equivalence hold
trait Foo { type T }
val fa = new Foo { type T = Int }
implicitly[fa.T =:= Int] // OK
but when type member T is assigned via method parameter A then type equivalence does not hold
def makeFoo[A]: Foo = new Foo { type T = A }
val fb = makeFoo[Int]
implicitly[fb.T =:= Int] // ERROR
Intuitively I would expect if T = A and A = Int then T = Int?
This is because the return type of
makeFoois onlyFooand notFoo { type T = A }. If you don't explicitly declare it or if you refine it, the error will go away.Scastie: