f835846705
Implement the necessary flow analysis bookkeeping so that in a pattern of the form `P1 && P2`, any type checks performed by `P1` will be reflected in the matched value type used by `P2`. To accomplish this, we allocate a promotion key to represent the "cached value" matched by every pattern and subpattern (so that `P1 && P2` promotes properly even when in a subpattern of another pattern). This promotion key is stored (in the form of a `ReferenceWithType<Type>`) in the `_PatternContext` class. Also, move `_scrutineeReference` and `_scrutineeType` into `_FlowAnalysisImpl`; this preserves the existing behaviour of promoting the scrutinee expression, but with less bookkeeping (since we don't need to pass it along from one context to the next). And add `_FlowAnalysisImpl._scrutineeSsaReference` so that if the scrutinee is modified during execution of the switch statement, it won't be erroneously promoted by patterns that follow. Finally, implement some preliminary logic for `||` patterns to avoid breaking existing tests. I will fill this out (and test it thoroughly) in a follow-up CL. Bug: https://github.com/dart-lang/sdk/issues/50419 Change-Id: I0d934e706ad5b19cda46a198afb2fb7a4309829b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275788 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
FE/analyzer shared code
This package contains logic that is shared between the front_end and analyzer packages. It is intended solely to facilitate development of the Dart SDK, and is not intended for use by end users. In particular, this package has no public API, so no guarantee is made of compatibility between one version of the package and the next.
End users should consider using the analyzer package to analyze Dart source code.