This is related to
SI-5648, warnings on comparisons.
There is one edge-casey bug: (new Kase() == kaseAlias) causes the "fresh object" warning. It should be either no warning or "unrelated types" warning, depending on the types.
The similar comparison (finalKase == kaseAlias) will emit "always yield false" (if there is no subtype relationship) instead of the weaker "unrelated types" warnings. (Can be true if the types are siblings extending the case class.)
The useful improvement would be to handle comparisons between case classes again, since if the case classes are different they can't satisfy the synthetic equals. (Some(1) == Thing(1))
A couple of related improvements would be to tighten up "fresh object" warnings, of the form (new Some(1) == None).
scala> :paste // Entering paste mode (ctrl-D to finish) // alias trait Thingy // sibling classes that extend a case class case class Thing(i: Int) class ThingOne(x:Int) extends Thing(x) class ThingTwo(y:Int) extends Thing(y) with Thingy final class ThingThree(z:Int) extends Thing(z) val t1 = new ThingOne(11) val t2: Thingy = new ThingTwo(11) val t4 = new ThingThree(11) // Exiting paste mode, now interpreting. defined trait Thingy defined class Thing defined class ThingOne defined class ThingTwo defined class ThingThree t1: ThingOne = Thing(11) t2: Thingy = Thing(11) t4: ThingThree = Thing(11) scala> (new ThingTwo(11) == t2) <console>:13: warning: comparing a fresh object using `==' will always yield false (new ThingTwo(11) == t2) ^ res0: Boolean = true scala> (t4 == t2) // unrelated types <console>:15: warning: comparing values of types ThingThree and Thingy using `==' will always yield false (t4 == t2) ^ res1: Boolean = true scala> (Some(1) == Thing(1)) // could warn res2: Boolean = false
I'll prepare a pull if I can type faster than Paul.