From 4ab18dac68a309c2607952dea8e2406d1ade9bd9 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 20 Sep 2022 20:37:09 +0000 Subject: [PATCH] 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 Commit-Queue: Paul Berry --- .../lib/src/type_inference/type_analyzer.dart | 28 +++++++++---------- pkg/_fe_analyzer_shared/test/mini_ast.dart | 26 ++++++++--------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart b/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart index 5ad4d34f74a..7bfe7c861a3 100644 --- a/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart +++ b/pkg/_fe_analyzer_shared/lib/src/type_inference/type_analyzer.dart @@ -500,7 +500,7 @@ mixin TypeAnalyzer 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); }