I find myself more than once writing the following ugly pattern:
class Something[A, B](implicit ev: A =:= B = null) {
...
def doStuff {
if (ev == null) ... // know that A is not the same as B
else ... // safely assume A is equal to B
}
}
Even worse, when ev != null
, I would sometimes write heresies such as someB.asInstanceOf[A]
.