Closed
Description
Currently, even under strict equality, we can compare values of abstract types/type params:
import scala.language.strictEquality
def equal[S, T](s: S, t: T) = s == t
PR #5624 prevented such errors for abstract types, but left this case open.
This behavior is due to the use of lift
in the specification of multiversal equality. The stated motivation is to avoid asInstanceOf
in code like this:
def f[T](x: T) =
if (x == null) ...
else if (x == "abc") ...
else ...
However, under strictEquality
it seems reasonable to reject x == "abc"
and require (x: Any) == "abc"
.
This issue is an up-to-date version of #2707.