mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 09:22:12 +00:00
b026068313
When analyzing the type test implied by a pattern, flow analysis uses three variables to control promotion behavior: - `matchFailsIfWrongType`, which indicates whether flow analysis needs to account for the possible control flow path resulting from the type test failing. (This is `false` for cast patterns, because in the case where a cast pattern fails, an exception is thrown). - `matchMayFailEvenIfCorrectType`, which indicates whether flow analysis needs to account for the possible control flow path resulting from the type test succeeding, but some other check causing the match to fail. (This is `true` for most list patterns, because the list pattern will fail to match if the list has the wrong length). (Note that `matchMayFailEvenIfCorrectType` doesn't account for the fact that a pattern match might fail due to failure in a subpattern match; this is automatically handled by the fact that flow analysis walks through the complete pattern in the order in which it executes.) - `coversMatchedType`, which indicates whether the type test is guaranteed to succeed due to a subtype relationship between the matched value type and the type being tested (e.g. a `num x` pattern is guaranteed to succeed if the matched value type is `int`). In the case where `matchFailsIfWrongType` is `true`, `matchMayFailEvenIfCorrectType` is `true`, and `coversMatchedType` is `false`, flow analysis must account for the fact that there are two ways that the pattern match might fail: the type test might fail, or the type test might succeed but then the pattern match might fail for some other reason. Before this change, this was done incorrectly, and flow analysis only accounted for the possibility of the type test failing. Fixes #55543. Bug: https://github.com/dart-lang/sdk/issues/55543 Change-Id: I86603ec5f940402313f32177212b7960878db97f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364942 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Paul Berry <paulberry@google.com> |
||
---|---|---|
.. | ||
exhaustiveness | ||
flow_analysis | ||
call_tear_off_error_test.dart | ||
call_tear_off_test.dart | ||
cast_from_dynamic_test.dart | ||
declared_variable_in_pattern_assignment_error_test.dart | ||
empty_switch_expression_test.dart | ||
for_in_nullable_error_test.dart | ||
guard_capture_test.dart | ||
guard_error_test.dart | ||
guard_scope_test.dart | ||
identifier_when_not_test.dart | ||
implicit_instantiation_error_test.dart | ||
implicit_instantiation_test.dart | ||
int_to_double_error_test.dart | ||
int_to_double_test.dart | ||
invalid_const_pattern_binary_test.dart | ||
invalid_const_pattern_test.dart | ||
invalid_inside_unary_pattern_error_test.dart | ||
invalid_inside_unary_pattern_parentheses_test.dart | ||
issue52202_error_test.dart | ||
issue52409_test.dart | ||
issue54559_test.dart | ||
issue_52439.dart | ||
keyword_in_pattern_variable_declaration_error_test.dart | ||
non_interface_object_pattern_test.dart | ||
nullable_object_pattern_error_test.dart | ||
nullable_object_pattern_test.dart | ||
object_pattern_inference_test.dart | ||
pattern_variable_constant_scope_test.dart | ||
primitive_switch_test.dart | ||
record_type_object_pattern_test.dart | ||
relational_pattern_expression_precedence_error_test.dart | ||
relational_pattern_expression_precedence_test.dart | ||
schema_test.dart | ||
shared_case_variable_error_test.dart | ||
shared_case_variable_test.dart | ||
switch_case_scope_error_test.dart | ||
switch_case_scope_test.dart | ||
switch_expression_using_statement_syntax_error_test.dart | ||
switch_trivial_exhaustiveness_error_test.dart | ||
type_question_before_when_test.dart | ||
var_keyword_in_typed_variable_pattern_error_test.dart | ||
var_keyword_in_typed_wildcard_pattern_error_test.dart | ||
version_2_29_changes_error_test.dart | ||
version_2_29_changes_test.dart | ||
version_2_32_changes_error_test.dart | ||
wildcard_in_matching_context_test.dart | ||
wildcard_in_pattern_assignment_error_test.dart | ||
wildcard_in_pattern_assignment_test.dart | ||
wildcard_in_pattern_variable_declaration_error_test.dart | ||
wildcard_in_pattern_variable_declaration_test.dart |