Promote types within record fields in pattern matches #3160
Labels
feature
Proposed language feature that solves one or more problems
type-inference
Type inference, issues or improvements
Consider the following code:
To a human, it's clear that
first
andsecond
will never be null because of the preceding(null, null)
pattern. However, Dart currently doesn't promote their types. I would like it to do so.The lack of this feature particularly makes it harder to what @munificent describes as "a really common, important use case for patterns [of] doing "parallel" matching where you switch over an immediately-created record" in the presence of nullable types.
(Relatedly, it would also be nice if
arg1
andarg2
were promoted to non-nullable after theswitch
statement.)The text was updated successfully, but these errors were encountered: