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
It is indeed statically detectable that the an instance of type A will not be equal to an instance of type B.
Because both are enum classes, which means nothing else can implement the types, and enums cannot override ==.
It's not something the language tries to prevent you from doing. After all, it works (it returns false as it should) and the == operator has parameter type Object, so it's perfectly fine to ask.
It's a little weird to make this example code not compile, but allow it if you wrote Object x = A.foo;.
The analyzer could choose to tell you that the comparison is useless. And it does, you just have to ask for it by enabling the unrelated_type_equality_checks lint.
I think, the following code should not compile:
... because it makes no sense to compare
x
(an instance ofenum A
) with an instance ofenum B
.Link to the example in DartPad
The text was updated successfully, but these errors were encountered: