e403e6ae77
The new logic classifies the LHS and RHS of the equality check as either null, non-nullable, or potentially nullable, and then either promotes, treats the expression as equivalent to a boolean, or does nothing, as appropriate. This means, for example, that a comparison between a non-nullable value and `null` is now known to evaluate to `true` for reachability analysis. Note: as part of this change, it was tempting to trigger promotion whenever a varialbe is equality compared to an expression of type `Null`, but this would be unsound (consider `(int? x) => x == (x = null) ? true : x.isEven`). So we still only promote when the variable is compared to a literal `null`. Fixes #41985. There's a corresponding spec change out for review: https://github.com/dart-lang/language/pull/1134 Change-Id: Id7f1d4eaa3b0fa57124445bb8352eef32c304feb Bug: https://github.com/dart-lang/sdk/issues/41985 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155926 Reviewed-by: Konstantin Shcheglov <scheglov@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.