Thanks for the clear article; I certainly learned something new.
Isn’t this quite directly against OO inheritance, though? The whole idea is that if A is a subclass of B, then an instance of A should be able to be used wherever a B is required.
In fact, it seems this is pretty easily defeated by just casting to whatever the common type is. For instance: pair(“foo”.asInstanceOf[Any], 1.asInstanceOf[Any]) will happily return you a (Any, Any) even with the GTC. Of course you should be suspicious of such casting, but what if it’s just a variable with an explicitly declared type? e.g. val x: Any = “foo”
I guess my point is, this can really give you false confidence. At the end of the day, you can’t know for sure at compile time if two objects will always have the same type. Only runtime reflection can do that. You can know, however, if they share a common supertype, which is exactly what the version without GTC does.