You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, even under strict equality, we can compare values of abstract types/type params:
importscala.language.strictEqualitydefequal[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:
abgruszecki
changed the title
Multiversal equality and type parameters: strictEquality isn't strict enough
Strict equality shouldn't allow comparisons between unrelated type parameters
Feb 1, 2019
Currently, even under strict equality, we can compare values of abstract types/type params:
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 avoidasInstanceOf
in code like this:However, under
strictEquality
it seems reasonable to rejectx == "abc"
and require(x: Any) == "abc"
.This issue is an up-to-date version of #2707.
The text was updated successfully, but these errors were encountered: