-
Notifications
You must be signed in to change notification settings - Fork 227
Description
Flow analysis currently has the rule that type promotion only occurs when the type being tested is a subtype of the previously promoted type. This can lead to counterintuitive behaviors when the type being tested and the previously promoted type are mutual subtypes (see comment from @eernstg and comment from @lrhn on dart-lang/sdk#60609).
In the discussion on that issue, the three of us agreed that it would be better to change the rule so that type promotion only occurs when the type being tested is a proper subtype of the previously promoted type. For example, this would mean that a type that has been promoted to List<Object?> cannot be further promoted to List<dynamic> or List<void>, because these three types are all mutual subtypes.
I'm filing this as a separate issue to distinguish it from dart-lang/sdk#60609, which is primarily caused by a bug in the handling of switches (dart-lang/sdk#60496).