Shared analysis: update ifCaseElement API to match ifCase.

This change makes the API for the `ifCaseElement` method similar to
that of `ifCase`, which should make it easier to write flow analysis
unit tests for if-case elements.

Bug: https://github.com/dart-lang/sdk/issues/50419
Change-Id: I64c160f3b6df38b0d337f9b8f9c6c9189e9a13ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274161
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Paul Berry 2022-12-07 22:08:30 +00:00 committed by Commit Queue
parent 759a742c16
commit 3407cdb6ac
2 changed files with 3 additions and 3 deletions

View file

@ -220,9 +220,9 @@ Statement ifCase(Expression expression, PossiblyGuardedPattern pattern,
CollectionElement ifCaseElement(
Expression expression,
PossiblyGuardedPattern pattern,
CollectionElement ifTrue, {
CollectionElement ifTrue, [
CollectionElement? ifFalse,
}) {
]) {
var location = computeLocation();
var guardedPattern = pattern._asGuardedPattern;
return new _IfCaseElement(

View file

@ -78,7 +78,7 @@ main() {
expr('Object'),
intLiteral(0).pattern,
intLiteral(1).checkContext('int').asCollectionElement,
ifFalse: intLiteral(2).checkContext('int').asCollectionElement,
intLiteral(2).checkContext('int').asCollectionElement,
)
.checkIr('if(expression: expr(Object), pattern: '
'const(0, matchedType: Object), guard: true, '