Skip to content

Commit f011262

Browse files
chloestefantsovaCommit Queue
authored and
Commit Queue
committed
[cfe] Implement the desugaring for NullCheckPattern
Additionally, fix the revealed variable declaration issues of VariablePattern and change more remnant mentions of Matchers and Binders. Part of #49749 Change-Id: I8f31bb1038f29768c82e0cfa4b55bfee3e0e16c3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267581 Commit-Queue: Chloe Stefantsova <[email protected]> Reviewed-by: Johnni Winther <[email protected]>
1 parent 340896c commit f011262

File tree

62 files changed

+324
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+324
-149
lines changed

pkg/front_end/lib/src/fasta/kernel/body_builder.dart

+10-5
Original file line numberDiff line numberDiff line change
@@ -2313,11 +2313,6 @@ class BodyBuilder extends StackListenerImpl
23132313
libraryFeatures.patterns, case_.charOffset, case_.charCount);
23142314
Pattern pattern = toPattern(pop());
23152315
Expression expression = popForValue();
2316-
for (VariableDeclaration variable in pattern.declaredVariables) {
2317-
// Skip synthetic variables.
2318-
if (variable.name == null) continue;
2319-
declareVariable(variable, scope);
2320-
}
23212316
push(new Condition(expression, pattern, guard));
23222317
} else {
23232318
assert(checkState(token, [
@@ -3459,10 +3454,20 @@ class BodyBuilder extends StackListenerImpl
34593454
@override
34603455
void beginThenStatement(Token token) {
34613456
debugEvent("beginThenStatement");
3457+
assert(checkState(token, [ValueKinds.Condition]));
34623458
// This is matched by the call to [deferNode] in
34633459
// [endThenStatement].
34643460
typeInferrer.assignedVariables.beginNode();
3461+
Condition condition = peek() as Condition;
34653462
enterLocalScope("then");
3463+
Pattern? pattern = condition.pattern;
3464+
if (pattern != null) {
3465+
for (VariableDeclaration variable in pattern.declaredVariables) {
3466+
// Skip synthetic variables.
3467+
if (variable.name == null) continue;
3468+
declareVariable(variable, scope);
3469+
}
3470+
}
34663471
}
34673472

34683473
@override

0 commit comments

Comments
 (0)