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
This is a real problem. The corresponding situation with the conditional operator :? is discussed in #25368, and that issue already mentions that ?? is similar.
The core problem is the drastic upcast in the ?? operator: the static type of e1 ?? e2 is the least upper bound of the static type of e1 and of e2. Whenever those two types are unrelated (like here) we get Object, and that allows for a downcast (in this case to int, but we can downcast to anything from Object). The consequence is that the initialization of a is accepted in all cases, as if the type check had been turned off completely.
I'll close this as a duplicate of #25368, adding a reference to this issue to emphasize that the problem affects ?? as well as ?:.
Next code doesn't show warning, it should be type error:
Dart 1.20.1
The text was updated successfully, but these errors were encountered: