mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:29:48 +00:00
Shared type analysis for patterns: rename finishStatementCase
The new name, `handleMergedStatementCase`, is more consistent with the rest of the type analyzer's `handle` methods, and more accurately describes when the method is called (after a switch body that's potentially shared by multiple case heads and possibly a `default` clause). Change-Id: I4f3166d5f58432f9f1cc0edffb3c0a317539ea23 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260064 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
eb00d038c7
commit
4ab18dac68
|
@ -500,7 +500,7 @@ mixin TypeAnalyzer<Node extends Object, Statement extends Node,
|
|||
errors?.switchCaseCompletesNormally(node, firstCaseInThisExecutionPath,
|
||||
i - firstCaseInThisExecutionPath);
|
||||
}
|
||||
finishStatementCase(node,
|
||||
handleMergedStatementCase(node,
|
||||
caseIndex: i - 1,
|
||||
executionPathIndex: numExecutionPaths,
|
||||
numStatements: body.length);
|
||||
|
@ -588,19 +588,6 @@ mixin TypeAnalyzer<Node extends Object, Statement extends Node,
|
|||
/// Stack effect: pops (CaseHead, Expression) and pushes (ExpressionCase).
|
||||
void finishExpressionCase(Expression node, int caseIndex);
|
||||
|
||||
/// Called after visiting a merged statement case.
|
||||
///
|
||||
/// [node] is enclosing switch statement, [caseIndex] is the index of the last
|
||||
/// `case` or `default` clause in the merged statement case, and
|
||||
/// [numStatements] is the number of statements in the case body.
|
||||
///
|
||||
/// Stack effect: pops (CaseHeads, numStatements * Statement) and pushes
|
||||
/// (StatementCase).
|
||||
void finishStatementCase(Statement node,
|
||||
{required int caseIndex,
|
||||
required int executionPathIndex,
|
||||
required int numStatements});
|
||||
|
||||
/// Returns an [ExpressionCaseInfo] object describing the [index]th `case` or
|
||||
/// `default` clause in the switch expression [node].
|
||||
///
|
||||
|
@ -687,6 +674,19 @@ mixin TypeAnalyzer<Node extends Object, Statement extends Node,
|
|||
void handleLogicalPattern(Node node,
|
||||
{required bool isAnd, required Type matchedType});
|
||||
|
||||
/// Called after visiting a merged statement case.
|
||||
///
|
||||
/// [node] is enclosing switch statement, [caseIndex] is the index of the last
|
||||
/// `case` or `default` clause in the merged statement case, and
|
||||
/// [numStatements] is the number of statements in the case body.
|
||||
///
|
||||
/// Stack effect: pops (CaseHeads, numStatements * Statement) and pushes
|
||||
/// (StatementCase).
|
||||
void handleMergedStatementCase(Statement node,
|
||||
{required int caseIndex,
|
||||
required int executionPathIndex,
|
||||
required int numStatements});
|
||||
|
||||
/// Called when visiting a `case` that lacks a guard clause. Since the lack
|
||||
/// of a guard clause is semantically equivalent to `when true`, this method
|
||||
/// should behave similarly to visiting the boolean literal `true`.
|
||||
|
|
|
@ -2605,19 +2605,6 @@ class _MiniAstTypeAnalyzer
|
|||
location: node.location);
|
||||
}
|
||||
|
||||
@override
|
||||
void finishStatementCase(Statement node,
|
||||
{required int caseIndex,
|
||||
required int executionPathIndex,
|
||||
required int numStatements}) {
|
||||
_irBuilder.apply(
|
||||
'block', List.filled(numStatements, Kind.statement), Kind.statement,
|
||||
location: node.location);
|
||||
_irBuilder.apply(
|
||||
'case', [Kind.caseHeads, Kind.statement], Kind.statementCase,
|
||||
location: node.location);
|
||||
}
|
||||
|
||||
@override
|
||||
SwitchExpressionMemberInfo<Node, Expression> getSwitchExpressionMemberInfo(
|
||||
covariant _SwitchExpression node, int index) =>
|
||||
|
@ -2698,6 +2685,19 @@ class _MiniAstTypeAnalyzer
|
|||
names: ['matchedType'], location: node.location);
|
||||
}
|
||||
|
||||
@override
|
||||
void handleMergedStatementCase(Statement node,
|
||||
{required int caseIndex,
|
||||
required int executionPathIndex,
|
||||
required int numStatements}) {
|
||||
_irBuilder.apply(
|
||||
'block', List.filled(numStatements, Kind.statement), Kind.statement,
|
||||
location: node.location);
|
||||
_irBuilder.apply(
|
||||
'case', [Kind.caseHeads, Kind.statement], Kind.statementCase,
|
||||
location: node.location);
|
||||
}
|
||||
|
||||
void handleNoCondition(Node node) {
|
||||
_irBuilder.atom('true', Kind.expression, location: node.location);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue