[cfe] Combine Matchers and Binders into Patterns
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I1400d854d722e8280b9d0d66c9e1630829542aa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266682
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart b/pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart
index 49cf0e9..d0371ff 100644
--- a/pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart
+++ b/pkg/_fe_analyzer_shared/lib/src/parser/stack_listener.dart
@@ -56,14 +56,14 @@
IdentifierList,
Initializers,
Labels,
- Matcher,
Metadata,
MixinApplicationBuilder,
- MatcherList,
Modifiers,
Name,
OperatorList,
ParameterDefaultValue,
+ Pattern,
+ PatternList,
Prefix,
RecordTypeFieldList,
ShowClause,
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index 23f5632..76e97dd 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -668,22 +668,20 @@
return toValue(node);
}
- Matcher toMatcher(Object? node) {
- if (node is Matcher) {
+ Pattern toPattern(Object? node) {
+ if (node is Pattern) {
return node;
- } else if (node is Binder) {
- return new BinderMatcher(node);
} else if (node is Generator) {
- return new ExpressionMatcher(node.buildSimpleRead());
+ return new ExpressionPattern(node.buildSimpleRead());
} else if (node is Expression) {
- return new ExpressionMatcher(node);
+ return new ExpressionPattern(node);
} else if (node is ProblemBuilder) {
// ignore: unused_local_variable
Expression expression =
buildProblem(node.message, node.charOffset, noLength);
- return new ExpressionMatcher(expression);
+ return new ExpressionPattern(expression);
} else {
- return unhandled("${node.runtimeType}", "toMatcher", -1, uri);
+ return unhandled("${node.runtimeType}", "toPattern", -1, uri);
}
}
@@ -2290,8 +2288,7 @@
]),
unionOfKinds([
ValueKinds.Expression,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
unionOfKinds([
ValueKinds.Expression,
@@ -2304,8 +2301,7 @@
assert(checkState(token, [
unionOfKinds([
ValueKinds.Expression,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
unionOfKinds([
ValueKinds.Expression,
@@ -2315,14 +2311,14 @@
]));
reportIfNotEnabled(
libraryFeatures.patterns, case_.charOffset, case_.charCount);
- Matcher matcher = toMatcher(pop());
+ Pattern pattern = toPattern(pop());
Expression expression = popForValue();
- for (VariableDeclaration variable in matcher.declaredVariables) {
+ for (VariableDeclaration variable in pattern.declaredVariables) {
// Skip synthetic variables.
if (variable.name == null) continue;
declareVariable(variable, scope);
}
- push(new Condition(expression, matcher, guard));
+ push(new Condition(expression, pattern, guard));
} else {
assert(checkState(token, [
unionOfKinds([
@@ -2378,16 +2374,15 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
])
]));
- // TODO(johnniwinther): Do we need a ParenthesizedMatcher ?
+ // TODO(johnniwinther): Do we need a ParenthesizedPattern ?
reportIfNotEnabled(
libraryFeatures.patterns, token.charOffset, token.charCount);
Object? value = pop();
- if (value is Matcher || value is Binder) {
+ if (value is Pattern) {
push(value);
} else {
push(toValue(value));
@@ -2548,8 +2543,7 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
ValueKinds.ConstantContext,
]));
@@ -2560,17 +2554,16 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
ValueKinds.ConstantContext,
]));
debugEvent("endCaseExpression");
Object? value = pop();
- if (value is Matcher || value is Binder) {
+ if (value is Pattern) {
constantContext = pop() as ConstantContext;
// TODO(paulberry): handle guard
- super.push(toMatcher(value));
+ super.push(toPattern(value));
} else {
Expression expression = toValue(value);
constantContext = pop() as ConstantContext;
@@ -2580,7 +2573,7 @@
assert(checkState(colon, [
unionOfKinds([
ValueKinds.Expression,
- ValueKinds.Matcher,
+ ValueKinds.Pattern,
])
]));
}
@@ -2654,33 +2647,31 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
unionOfKinds([
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
])
]));
reportIfNotEnabled(
libraryFeatures.patterns, token.charOffset, token.charCount);
// ignore: unused_local_variable
- Matcher left = toMatcher(pop());
+ Pattern left = toPattern(pop());
// ignore: unused_local_variable
- Matcher right = toMatcher(pop());
- // TODO(johnniwinther): Create a binary matcher.
+ Pattern right = toPattern(pop());
+ // TODO(johnniwinther): Create a binary pattern.
String operator = token.lexeme;
- BinaryMatcherKind kind;
+ BinaryPatternKind kind;
switch (operator) {
case '&':
- kind = BinaryMatcherKind.and;
+ kind = BinaryPatternKind.and;
break;
case '|':
- kind = BinaryMatcherKind.or;
+ kind = BinaryPatternKind.or;
break;
default:
internalProblem(
@@ -2689,7 +2680,7 @@
token.charOffset,
uri);
}
- push(new BinaryMatcher(left, kind, right, token.charOffset));
+ push(new BinaryPattern(left, kind, right, token.charOffset));
}
void doBinaryExpression(Token token) {
@@ -3499,13 +3490,13 @@
pop() as AssignedVariablesNodeInfo;
Statement thenPart = popStatement();
Condition condition = pop() as Condition;
- Matcher? matcher = condition.matcher;
+ Pattern? pattern = condition.pattern;
Expression? guard = condition.guard;
Expression expression = condition.expression;
Statement node;
- if (matcher != null) {
+ if (pattern != null) {
node = new IfCaseStatement(
- expression, matcher, guard, thenPart, elsePart, ifToken.charOffset);
+ expression, pattern, guard, thenPart, elsePart, ifToken.charOffset);
} else {
node = forest.createIfStatement(
offsetForToken(ifToken), expression, thenPart, elsePart);
@@ -4157,8 +4148,7 @@
ValueKinds.Generator,
ValueKinds.Expression,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
count),
ValueKinds.TypeArgumentsOrNull,
@@ -4167,10 +4157,10 @@
reportIfNotEnabled(libraryFeatures.patterns, leftBracket.charOffset,
leftBracket.charCount);
- List<Matcher> matchers =
- new List<Matcher>.filled(count, dummyMatcher, growable: true);
+ List<Pattern> patterns =
+ new List<Pattern>.filled(count, dummyPattern, growable: true);
for (int i = count - 1; i >= 0; i--) {
- matchers[i] = toMatcher(pop());
+ patterns[i] = toPattern(pop());
}
List<TypeBuilder>? typeArguments = pop() as List<TypeBuilder>?;
DartType typeArgument;
@@ -4192,7 +4182,7 @@
typeArgument = implicitTypeArgument;
}
- push(new ListMatcher(typeArgument, matchers, leftBracket.charOffset));
+ push(new ListPattern(typeArgument, patterns, leftBracket.charOffset));
}
@override
@@ -4285,19 +4275,18 @@
ValueKinds.Expression,
ValueKinds.ProblemBuilder,
ValueKinds.NamedExpression,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
count)));
reportIfNotEnabled(
libraryFeatures.patterns, token.charOffset, token.charCount);
- List<Matcher> matchers = new List<Matcher>.filled(count, dummyMatcher);
+ List<Pattern> patterns = new List<Pattern>.filled(count, dummyPattern);
for (int i = count - 1; i >= 0; i--) {
- matchers[i] = toMatcher(pop());
+ patterns[i] = toPattern(pop());
}
- push(new RecordMatcher(matchers, token.charOffset));
+ push(new RecordPattern(patterns, token.charOffset));
}
void buildLiteralSet(List<TypeBuilder>? typeArguments, Token? constKeyword,
@@ -4431,36 +4420,34 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
unionOfKinds([
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
])
]));
- Matcher key = toMatcher(pop());
- Matcher value = toMatcher(pop());
- push(new MapMatcherEntry(key, value, colon.charOffset));
+ Pattern key = toPattern(pop());
+ Pattern value = toPattern(pop());
+ push(new MapPatternEntry(key, value, colon.charOffset));
}
@override
void handleMapPattern(int count, Token leftBrace, Token rightBrace) {
debugEvent('MapPattern');
assert(checkState(leftBrace, [
- ...repeatedKinds(ValueKinds.MapMatcherEntry, count),
+ ...repeatedKinds(ValueKinds.MapPatternEntry, count),
ValueKinds.TypeArgumentsOrNull,
]));
reportIfNotEnabled(
libraryFeatures.patterns, leftBrace.charOffset, leftBrace.charCount);
- List<MapMatcherEntry> entries =
- new List<MapMatcherEntry>.filled(count, dummyMapMatcherEntry);
+ List<MapPatternEntry> entries =
+ new List<MapPatternEntry>.filled(count, dummyMapPatternEntry);
for (int i = count - 1; i >= 0; i--) {
- entries[i] = pop() as MapMatcherEntry;
+ entries[i] = pop() as MapPatternEntry;
}
List<TypeBuilder>? typeArguments = pop() as List<TypeBuilder>?;
@@ -4482,7 +4469,7 @@
}
}
- push(new MapMatcher(keyType, valueType, entries, leftBrace.charOffset));
+ push(new MapPattern(keyType, valueType, entries, leftBrace.charOffset));
}
@override
@@ -4872,16 +4859,15 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
]));
reportIfNotEnabled(
libraryFeatures.patterns, operator.charOffset, operator.charCount);
DartType type = buildDartType(pop() as TypeBuilder, TypeUse.asType,
allowPotentiallyConstantType: libraryBuilder.isNonNullableByDefault);
- Matcher operand = toMatcher(pop());
- push(new CastMatcher(operand, type, operator.charOffset));
+ Pattern operand = toPattern(pop());
+ push(new CastPattern(operand, type, operator.charOffset));
}
@override
@@ -6294,8 +6280,8 @@
Object? entry = pop();
Condition condition = pop() as Condition;
- assert(condition.matcher == null,
- "Unexpected matcher in control flow if: ${condition.matcher}.");
+ assert(condition.pattern == null,
+ "Unexpected pattern in control flow if: ${condition.pattern}.");
Token ifToken = pop() as Token;
transformCollections = true;
@@ -6339,8 +6325,8 @@
AssignedVariablesNodeInfo assignedVariablesInfo =
pop() as AssignedVariablesNodeInfo;
Condition condition = pop() as Condition; // parenthesized expression
- assert(condition.matcher == null,
- "Unexpected matcher in control flow if: ${condition.matcher}.");
+ assert(condition.pattern == null,
+ "Unexpected pattern in control flow if: ${condition.pattern}.");
Token ifToken = pop() as Token;
transformCollections = true;
@@ -6747,8 +6733,8 @@
/* break target = */ ValueKinds.BreakTarget,
]));
Condition condition = pop() as Condition;
- assert(condition.matcher == null,
- "Unexpected matcher in do statement: ${condition.matcher}.");
+ assert(condition.pattern == null,
+ "Unexpected pattern in do statement: ${condition.pattern}.");
Expression expression = condition.expression;
Statement body = popStatement();
JumpTarget continueTarget = exitContinueTarget()!;
@@ -7087,8 +7073,8 @@
]));
Statement body = popStatement();
Condition condition = pop() as Condition;
- assert(condition.matcher == null,
- "Unexpected matcher in while statement: ${condition.matcher}.");
+ assert(condition.pattern == null,
+ "Unexpected pattern in while statement: ${condition.pattern}.");
Expression expression = condition.expression;
JumpTarget continueTarget = exitContinueTarget()!;
JumpTarget breakTarget = exitBreakTarget()!;
@@ -7219,7 +7205,7 @@
void beginSwitchCase(int labelCount, int expressionCount, Token firstToken) {
debugEvent("beginSwitchCase");
int count = labelCount + expressionCount;
- List<Object>? labelsExpressionsAndMatchers =
+ List<Object>? labelsExpressionsAndPatterns =
const FixedNullableList<Object>()
.popNonNullable(stack, count, dummyLabel);
List<Label>? labels =
@@ -7229,15 +7215,15 @@
growable: true);
int labelIndex = 0;
int expressionIndex = 0;
- if (labelsExpressionsAndMatchers != null) {
- for (Object labelExpressionOrMatcher in labelsExpressionsAndMatchers) {
- if (labelExpressionOrMatcher is Label) {
- labels![labelIndex++] = labelExpressionOrMatcher;
- } else if (labelExpressionOrMatcher is Matcher) {
- // TODO(johnniwinther): Handle matchers.
+ if (labelsExpressionsAndPatterns != null) {
+ for (Object labelExpressionOrPattern in labelsExpressionsAndPatterns) {
+ if (labelExpressionOrPattern is Label) {
+ labels![labelIndex++] = labelExpressionOrPattern;
+ } else if (labelExpressionOrPattern is Pattern) {
+ // TODO(johnniwinther): Handle patterns.
} else {
expressions[expressionIndex++] =
- labelExpressionOrMatcher as Expression;
+ labelExpressionOrPattern as Expression;
}
}
}
@@ -7308,8 +7294,8 @@
exitSwitchScope();
exitLocalScope();
Condition condition = pop() as Condition;
- assert(condition.matcher == null,
- "Unexpected matcher in switch statement: ${condition.matcher}.");
+ assert(condition.pattern == null,
+ "Unexpected pattern in switch statement: ${condition.pattern}.");
Expression expression = condition.expression;
Statement switchStatement = new SwitchStatement(expression, cases)
..fileOffset = switchKeyword.charOffset;
@@ -8208,8 +8194,7 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
count)));
reportIfNotEnabled(
@@ -8217,8 +8202,8 @@
for (int i = 0; i < count; i++) {
pop();
}
- // TODO(johnniwinther): Push (named) matchers.
- push(count != 0 ? <Matcher>[] : NullValue.MatcherList);
+ // TODO(johnniwinther): Push (named) patterns.
+ push(count != 0 ? <Pattern>[] : NullValue.PatternList);
}
@override
@@ -8226,7 +8211,7 @@
Token firstIdentifier, Token? dot, Token? secondIdentifier) {
debugEvent("ExtractorPattern");
assert(checkState(firstIdentifier, [
- ValueKinds.MatcherListOrNull,
+ ValueKinds.PatternListOrNull,
ValueKinds.TypeArgumentsOrNull,
]));
@@ -8234,12 +8219,12 @@
firstIdentifier.charCount);
// ignore: unused_local_variable
- List<Matcher>? fields = pop() as List<Matcher>?;
+ List<Pattern>? fields = pop() as List<Pattern>?;
// ignore: unused_local_variable
List<TypeBuilder>? typeArguments = pop() as List<TypeBuilder>?;
// TODO(johnniwinther): Create extractor pattern.
- push(new DummyMatcher(firstIdentifier.charOffset));
+ push(new DummyPattern(firstIdentifier.charOffset));
}
@override
@@ -8250,33 +8235,32 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
]));
reportIfNotEnabled(
libraryFeatures.patterns, token.charOffset, token.charCount);
Expression operand = toValue(pop());
- RelationalMatcherKind kind;
+ RelationalPatternKind kind;
String operator = token.lexeme;
switch (operator) {
case '==':
- kind = RelationalMatcherKind.equals;
+ kind = RelationalPatternKind.equals;
break;
case '!=':
- kind = RelationalMatcherKind.notEquals;
+ kind = RelationalPatternKind.notEquals;
break;
case '<':
- kind = RelationalMatcherKind.lessThan;
+ kind = RelationalPatternKind.lessThan;
break;
case '<=':
- kind = RelationalMatcherKind.lessThanEqual;
+ kind = RelationalPatternKind.lessThanEqual;
break;
case '>':
- kind = RelationalMatcherKind.greaterThan;
+ kind = RelationalPatternKind.greaterThan;
break;
case '>=':
- kind = RelationalMatcherKind.greaterThanEqual;
+ kind = RelationalPatternKind.greaterThanEqual;
break;
default:
internalProblem(
@@ -8285,7 +8269,7 @@
token.charOffset,
uri);
}
- push(new RelationalMatcher(kind, operand, token.charOffset));
+ push(new RelationalPattern(kind, operand, token.charOffset));
}
@override
@@ -8296,14 +8280,13 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
]));
reportIfNotEnabled(
libraryFeatures.patterns, bang.charOffset, bang.charCount);
- Matcher operand = toMatcher(pop());
- push(new NullAssertMatcher(operand, bang.charOffset));
+ Pattern operand = toPattern(pop());
+ push(new NullAssertPattern(operand, bang.charOffset));
}
@override
@@ -8314,15 +8297,14 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
]));
reportIfNotEnabled(
libraryFeatures.patterns, question.charOffset, question.charCount);
// ignore: unused_local_variable
- Matcher operand = toMatcher(pop());
- push(new NullCheckMatcher(operand, question.charOffset));
+ Pattern operand = toPattern(pop());
+ push(new NullCheckPattern(operand, question.charOffset));
}
@override
@@ -8337,19 +8319,20 @@
// ignore: unused_local_variable
TypeBuilder? type = pop(NullValue.TypeBuilder) as TypeBuilder?;
DartType? patternType = type?.build(libraryBuilder, TypeUse.variableType);
- Binder binder;
+ Pattern pattern;
if (variable.lexeme == "_") {
- binder = new WildcardBinder(patternType, offset: variable.charOffset);
+ pattern = new WildcardPattern(patternType, variable.charOffset);
} else {
- binder = new VariableBinder(
+ pattern = new VariablePattern(
patternType,
variable.lexeme,
forest.createVariableDeclaration(variable.charOffset, variable.lexeme,
type: patternType,
isFinal: Modifier.validateVarFinalOrConst(keyword?.lexeme) ==
- finalMask));
+ finalMask),
+ variable.charOffset);
}
- push(binder);
+ push(pattern);
}
@override
@@ -8360,44 +8343,26 @@
ValueKinds.Expression,
ValueKinds.Generator,
ValueKinds.ProblemBuilder,
- ValueKinds.Matcher,
- ValueKinds.Binder,
+ ValueKinds.Pattern,
]),
if (colon != null) ValueKinds.IdentifierOrNull,
]));
Object? value = pop();
- if (value is Binder) {
- if (colon != null) {
- Identifier? identifier = pop() as Identifier?;
- String name;
- if (identifier != null) {
- name = identifier.name;
- } else {
- // TODO(johnniwinther): Derive the name from a variable binder in
- // [value].
- name = '';
- }
- push(new NamedBinder(name, value, colon.charOffset));
+ Pattern pattern = toPattern(value);
+ if (colon != null) {
+ Identifier? identifier = pop() as Identifier?;
+ String name;
+ if (identifier != null) {
+ name = identifier.name;
} else {
- push(value);
+ // TODO(johnniwinther): Derive the name from a variable reference in
+ // [pattern].
+ name = '';
}
+ push(new NamedPattern(name, pattern, colon.charOffset));
} else {
- Matcher matcher = toMatcher(value);
- if (colon != null) {
- Identifier? identifier = pop() as Identifier?;
- String name;
- if (identifier != null) {
- name = identifier.name;
- } else {
- // TODO(johnniwinther): Derive the name from a variable reference in
- // [matcher].
- name = '';
- }
- push(new NamedMatcher(name, matcher, colon.charOffset));
- } else {
- push(matcher);
- }
+ push(pattern);
}
}
}
@@ -8839,15 +8804,15 @@
class Condition {
final Expression expression;
- final Matcher? matcher;
+ final Pattern? pattern;
final Expression? guard;
- Condition(this.expression, [this.matcher, this.guard])
- : assert(guard == null || matcher != null,
- "Unexpected guard without matcher.");
+ Condition(this.expression, [this.pattern, this.guard])
+ : assert(guard == null || pattern != null,
+ "Unexpected guard without pattern.");
@override
String toString() => 'Condition($expression'
- '${matcher != null ? ',$matcher' : ''}'
+ '${pattern != null ? ',$pattern' : ''}'
'${guard != null ? ',$guard' : ''})';
}
diff --git a/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart b/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
index c70f2501..d5fd41d 100644
--- a/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/internal_ast.dart
@@ -5050,8 +5050,8 @@
}
}
-abstract class Matcher extends TreeNode with InternalTreeNode {
- Matcher(int fileOffset) {
+abstract class Pattern extends TreeNode with InternalTreeNode {
+ Pattern(int fileOffset) {
this.fileOffset = fileOffset;
}
@@ -5061,7 +5061,7 @@
/// patterns nested in the matcher.
List<VariableDeclaration> get declaredVariables;
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5080,8 +5080,8 @@
InferenceVisitorBase inferenceVisitor);
}
-class DummyMatcher extends Matcher {
- DummyMatcher(int fileOffset) : super(fileOffset);
+class DummyPattern extends Pattern {
+ DummyPattern(int fileOffset) : super(fileOffset);
@override
void toTextInternal(AstPrinter printer) {
@@ -5092,7 +5092,7 @@
List<VariableDeclaration> get declaredVariables => const [];
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5118,12 +5118,12 @@
}
}
-/// A [Matcher] based on an [Expression]. This corresponds to a constant
-/// matcher (pattern) in the specification.
-class ExpressionMatcher extends Matcher {
+/// A [Pattern] based on an [Expression]. This corresponds to a constant
+/// pattern in the specification.
+class ExpressionPattern extends Pattern {
Expression expression;
- ExpressionMatcher(this.expression) : super(expression.fileOffset) {
+ ExpressionPattern(this.expression) : super(expression.fileOffset) {
expression.parent = this;
}
@@ -5131,7 +5131,7 @@
List<VariableDeclaration> get declaredVariables => const [];
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5174,26 +5174,26 @@
}
}
-enum BinaryMatcherKind {
+enum BinaryPatternKind {
and,
or,
}
-/// A [Matcher] for `matcher | matcher` and `matcher & matcher`.
-class BinaryMatcher extends Matcher {
- Matcher left;
- BinaryMatcherKind kind;
- Matcher right;
+/// A [Pattern] for `pattern | pattern` and `pattern & pattern`.
+class BinaryPattern extends Pattern {
+ Pattern left;
+ BinaryPatternKind kind;
+ Pattern right;
@override
final List<VariableDeclaration> declaredVariables = [];
- BinaryMatcher(this.left, this.kind, this.right, int fileOffset)
+ BinaryPattern(this.left, this.kind, this.right, int fileOffset)
: super(fileOffset) {
left.parent = this;
right.parent = this;
- if (kind == BinaryMatcherKind.or) {
+ if (kind == BinaryPatternKind.or) {
// All branches should declare same variables.
declaredVariables.addAll(left.declaredVariables);
} else {
@@ -5205,7 +5205,7 @@
}
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5224,7 +5224,7 @@
void createDeclaredVariableInitializers(
VariableDeclaration matchedExpressionVariable,
InferenceVisitorBase inferenceVisitor) {
- if (kind == BinaryMatcherKind.and) {
+ if (kind == BinaryPatternKind.and) {
// All branches together define the set of declared variables.
left.createDeclaredVariableInitializers(
matchedExpressionVariable, inferenceVisitor);
@@ -5241,10 +5241,10 @@
void toTextInternal(AstPrinter printer) {
left.toTextInternal(printer);
switch (kind) {
- case BinaryMatcherKind.and:
+ case BinaryPatternKind.and:
printer.write(' & ');
break;
- case BinaryMatcherKind.or:
+ case BinaryPatternKind.or:
printer.write(' | ');
break;
}
@@ -5257,20 +5257,20 @@
}
}
-/// A [Matcher] for `matcher as type`.
-class CastMatcher extends Matcher {
- Matcher matcher;
+/// A [Pattern] for `pattern as type`.
+class CastPattern extends Pattern {
+ Pattern pattern;
DartType type;
- CastMatcher(this.matcher, this.type, int fileOffset) : super(fileOffset) {
- matcher.parent = this;
+ CastPattern(this.pattern, this.type, int fileOffset) : super(fileOffset) {
+ pattern.parent = this;
}
@override
- List<VariableDeclaration> get declaredVariables => matcher.declaredVariables;
+ List<VariableDeclaration> get declaredVariables => pattern.declaredVariables;
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5289,13 +5289,13 @@
void createDeclaredVariableInitializers(
VariableDeclaration matchedExpressionVariable,
InferenceVisitorBase inferenceVisitor) {
- matcher.createDeclaredVariableInitializers(
+ pattern.createDeclaredVariableInitializers(
matchedExpressionVariable, inferenceVisitor);
}
@override
void toTextInternal(AstPrinter printer) {
- matcher.toTextInternal(printer);
+ pattern.toTextInternal(printer);
printer.write(' as ');
printer.writeType(type);
}
@@ -5306,19 +5306,19 @@
}
}
-/// A [Matcher] for `matcher!`.
-class NullAssertMatcher extends Matcher {
- Matcher matcher;
+/// A [Pattern] for `pattern!`.
+class NullAssertPattern extends Pattern {
+ Pattern pattern;
- NullAssertMatcher(this.matcher, int fileOffset) : super(fileOffset) {
- matcher.parent = this;
+ NullAssertPattern(this.pattern, int fileOffset) : super(fileOffset) {
+ pattern.parent = this;
}
@override
- List<VariableDeclaration> get declaredVariables => matcher.declaredVariables;
+ List<VariableDeclaration> get declaredVariables => pattern.declaredVariables;
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5338,13 +5338,13 @@
void createDeclaredVariableInitializers(
VariableDeclaration matchedExpressionVariable,
InferenceVisitorBase inferenceVisitor) {
- matcher.createDeclaredVariableInitializers(
+ pattern.createDeclaredVariableInitializers(
matchedExpressionVariable, inferenceVisitor);
}
@override
void toTextInternal(AstPrinter printer) {
- matcher.toTextInternal(printer);
+ pattern.toTextInternal(printer);
printer.write('!');
}
@@ -5354,19 +5354,19 @@
}
}
-/// A [Matcher] for `matcher?`.
-class NullCheckMatcher extends Matcher {
- Matcher matcher;
+/// A [Pattern] for `matcher?`.
+class NullCheckPattern extends Pattern {
+ Pattern pattern;
- NullCheckMatcher(this.matcher, int fileOffset) : super(fileOffset) {
- matcher.parent = this;
+ NullCheckPattern(this.pattern, int fileOffset) : super(fileOffset) {
+ pattern.parent = this;
}
@override
- List<VariableDeclaration> get declaredVariables => matcher.declaredVariables;
+ List<VariableDeclaration> get declaredVariables => pattern.declaredVariables;
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5386,13 +5386,13 @@
void createDeclaredVariableInitializers(
VariableDeclaration matchedExpressionVariable,
InferenceVisitorBase inferenceVisitor) {
- matcher.createDeclaredVariableInitializers(
+ pattern.createDeclaredVariableInitializers(
matchedExpressionVariable, inferenceVisitor);
}
@override
void toTextInternal(AstPrinter printer) {
- matcher.toTextInternal(printer);
+ pattern.toTextInternal(printer);
printer.write('?');
}
@@ -5402,24 +5402,24 @@
}
}
-/// A [Matcher] for `<typeArgument>[matcher0, ... matcherN]`.
-class ListMatcher extends Matcher {
+/// A [Pattern] for `<typeArgument>[pattern0, ... patternN]`.
+class ListPattern extends Pattern {
DartType typeArgument;
- List<Matcher> matchers;
+ List<Pattern> patterns;
@override
final List<VariableDeclaration> declaredVariables = [];
- ListMatcher(this.typeArgument, this.matchers, int fileOffset)
+ ListPattern(this.typeArgument, this.patterns, int fileOffset)
: super(fileOffset) {
- setParents(matchers, this);
- for (Matcher matcher in matchers) {
- declaredVariables.addAll(matcher.declaredVariables);
+ setParents(patterns, this);
+ for (Pattern pattern in patterns) {
+ declaredVariables.addAll(pattern.declaredVariables);
}
}
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5449,7 +5449,7 @@
printer.write('>');
printer.write('[');
String comma = '';
- for (Matcher matcher in matchers) {
+ for (Pattern matcher in patterns) {
printer.write(comma);
matcher.toTextInternal(printer);
comma = ', ';
@@ -5463,7 +5463,7 @@
}
}
-enum RelationalMatcherKind {
+enum RelationalPatternKind {
equals,
notEquals,
lessThan,
@@ -5472,13 +5472,13 @@
greaterThanEqual,
}
-/// A [Matcher] for `operator expression` where `operator is either ==, !=,
+/// A [Pattern] for `operator expression` where `operator is either ==, !=,
/// <, <=, >, or >=.
-class RelationalMatcher extends Matcher {
- final RelationalMatcherKind kind;
+class RelationalPattern extends Pattern {
+ final RelationalPatternKind kind;
Expression expression;
- RelationalMatcher(this.kind, this.expression, int fileOffset)
+ RelationalPattern(this.kind, this.expression, int fileOffset)
: super(fileOffset) {
expression.parent = this;
}
@@ -5487,7 +5487,7 @@
List<VariableDeclaration> get declaredVariables => const [];
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5511,22 +5511,22 @@
@override
void toTextInternal(AstPrinter printer) {
switch (kind) {
- case RelationalMatcherKind.equals:
+ case RelationalPatternKind.equals:
printer.write('== ');
break;
- case RelationalMatcherKind.notEquals:
+ case RelationalPatternKind.notEquals:
printer.write('!= ');
break;
- case RelationalMatcherKind.lessThan:
+ case RelationalPatternKind.lessThan:
printer.write('< ');
break;
- case RelationalMatcherKind.lessThanEqual:
+ case RelationalPatternKind.lessThanEqual:
printer.write('<= ');
break;
- case RelationalMatcherKind.greaterThan:
+ case RelationalPatternKind.greaterThan:
printer.write('> ');
break;
- case RelationalMatcherKind.greaterThanEqual:
+ case RelationalPatternKind.greaterThanEqual:
printer.write('>= ');
break;
}
@@ -5539,180 +5539,16 @@
}
}
-class BinderMatcher extends Matcher {
- final Binder binder;
-
- BinderMatcher(this.binder) : super(binder.fileOffset);
-
- @override
- List<VariableDeclaration> get declaredVariables => binder.declaredVariables;
-
- @override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context}) {
- binder.acceptInference(visitor,
- matchedType: matchedType, typeInfos: typeInfos, context: context);
- return const MatcherInferenceResult();
- }
-
- @override
- Expression? makeCondition(VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor) {
- return binder.makeCondition(matchedExpressionVariable, inferenceVisitor);
- }
-
- @override
- void createDeclaredVariableInitializers(
- VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor) {
- binder.createDeclaredVariableInitializers(
- matchedExpressionVariable, inferenceVisitor);
- }
-
- @override
- void toTextInternal(AstPrinter printer) {
- binder.toTextInternal(printer);
- }
-
- @override
- String toString() {
- return "BinderMatcher(${toStringInternal()})";
- }
-}
-
-abstract class Binder extends TreeNode with InternalTreeNode {
- /// Variable declarations induced by nested variable patterns.
- ///
- /// These variables are initialized to the values captured by the variable
- /// patterns nested in the binder.
- List<VariableDeclaration> get declaredVariables;
-
- BinderInferenceResult acceptInference(InferenceVisitorImpl visitor,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context});
-
- /// Creates the desugared matching condition.
- ///
- /// [matchedExpressionVariable] is the variable initialized to the value of
- /// the expression being matched.
- Expression? makeCondition(VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor);
-
- /// Creates initializing expressions for the variables captured by the pattern
- void createDeclaredVariableInitializers(
- VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor);
-}
-
-class DummyBinder extends Binder {
- @override
- void toTextInternal(AstPrinter printer) {
- printer.write('<dummy-binder>');
- }
-
- @override
- List<VariableDeclaration> get declaredVariables => const [];
-
- @override
- BinderInferenceResult acceptInference(InferenceVisitorImpl visitor,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context}) {
- return visitor.visitDummyBinder(this,
- matchedType: matchedType, typeInfos: typeInfos, context: context);
- }
-
- @override
- Expression? makeCondition(VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor) {
- return null;
- }
-
- @override
- void createDeclaredVariableInitializers(
- VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor) {}
-
- @override
- String toString() {
- return "DummyBinder(${toStringInternal()})";
- }
-}
-
-class ListBinder extends Binder {
- final DartType typeBinderArgument;
- final List<Binder> binders;
-
- @override
- List<VariableDeclaration> declaredVariables = [];
-
- ListBinder(this.typeBinderArgument, this.binders, {required int offset}) {
- fileOffset = offset;
- declaredVariables = [
- for (Binder binder in binders) ...binder.declaredVariables
- ];
- }
-
- @override
- BinderInferenceResult acceptInference(InferenceVisitorImpl visitor,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context}) {
- return visitor.visitListBinder(this,
- matchedType: matchedType, typeInfos: typeInfos, context: context);
- }
-
- @override
- Expression? makeCondition(VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor) {
- throw new UnimplementedError("ListBinder.makeCondition");
- }
-
- @override
- void createDeclaredVariableInitializers(
- VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor) {
- throw new UnimplementedError(
- "ListBinder.createDeclaredVariableInitializers");
- }
-
- @override
- void toTextInternal(AstPrinter printer) {
- printer.write('[');
- String comma = '';
- for (Binder binder in binders) {
- printer.write(comma);
- binder.toTextInternal(printer);
- comma = ', ';
- }
- printer.write(']');
- }
-
- @override
- String toString() {
- return "ListBinder(${toStringInternal()})";
- }
-}
-
-class WildcardBinder extends Binder {
+class WildcardPattern extends Pattern {
final DartType? type;
- WildcardBinder(this.type, {required int offset}) {
- fileOffset = offset;
- }
+ WildcardPattern(this.type, int fileOffset) : super(fileOffset);
@override
List<VariableDeclaration> get declaredVariables => const [];
@override
- BinderInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5757,10 +5593,10 @@
}
class PatternVariableDeclaration extends InternalStatement {
- final Binder binder;
+ final Pattern pattern;
final Expression initializer;
- PatternVariableDeclaration(this.binder, this.initializer,
+ PatternVariableDeclaration(this.pattern, this.initializer,
{required int offset}) {
fileOffset = offset;
}
@@ -5788,7 +5624,7 @@
@override
void toTextInternal(AstPrinter printer) {
- binder.toTextInternal(printer);
+ pattern.toTextInternal(printer);
printer.write(" = ");
printer.writeExpression(initializer);
}
@@ -5816,27 +5652,27 @@
}
}
-final Matcher dummyMatcher = new ExpressionMatcher(dummyExpression);
+final Pattern dummyPattern = new ExpressionPattern(dummyExpression);
/// Internal statement for a if-case statements:
///
-/// if (expression case matcher) then
-/// if (expression case matcher) then else otherwise
-/// if (expression case matcher when guard) then
-/// if (expression case matcher when guard) then else otherwise
+/// if (expression case pattern) then
+/// if (expression case pattern) then else otherwise
+/// if (expression case pattern when guard) then
+/// if (expression case pattern when guard) then else otherwise
///
class IfCaseStatement extends InternalStatement {
Expression expression;
- Matcher matcher;
+ Pattern pattern;
Expression? guard;
Statement then;
Statement? otherwise;
- IfCaseStatement(this.expression, this.matcher, this.guard, this.then,
+ IfCaseStatement(this.expression, this.pattern, this.guard, this.then,
this.otherwise, int fileOffset) {
this.fileOffset = fileOffset;
expression.parent = this;
- matcher.parent = this;
+ pattern.parent = this;
guard?.parent = this;
then.parent = this;
otherwise?.parent = this;
@@ -5852,7 +5688,7 @@
printer.write('if (');
printer.writeExpression(expression);
printer.write(' case ');
- matcher.toTextInternal(printer);
+ pattern.toTextInternal(printer);
if (guard != null) {
printer.write(' when ');
printer.writeExpression(guard!);
@@ -5888,17 +5724,17 @@
}
}
-final MapMatcherEntry dummyMapMatcherEntry =
- new MapMatcherEntry(dummyMatcher, dummyMatcher, TreeNode.noOffset);
+final MapPatternEntry dummyMapPatternEntry =
+ new MapPatternEntry(dummyPattern, dummyPattern, TreeNode.noOffset);
-class MapMatcherEntry extends TreeNode with InternalTreeNode {
- final Matcher key;
- final Matcher value;
+class MapPatternEntry extends TreeNode with InternalTreeNode {
+ final Pattern key;
+ final Pattern value;
@override
final int fileOffset;
- MapMatcherEntry(this.key, this.value, this.fileOffset) {
+ MapPatternEntry(this.key, this.value, this.fileOffset) {
key.parent = this;
value.parent = this;
}
@@ -5916,18 +5752,18 @@
}
}
-class MapMatcher extends Matcher {
+class MapPattern extends Pattern {
final DartType? keyType;
final DartType? valueType;
- final List<MapMatcherEntry> entries;
+ final List<MapPatternEntry> entries;
@override
final List<VariableDeclaration> declaredVariables = [];
- MapMatcher(this.keyType, this.valueType, this.entries, int fileOffset)
+ MapPattern(this.keyType, this.valueType, this.entries, int fileOffset)
: assert((keyType == null) == (valueType == null)),
super(fileOffset) {
- for (MapMatcherEntry entry in entries) {
+ for (MapPatternEntry entry in entries) {
declaredVariables.addAll(entry.key.declaredVariables);
declaredVariables.addAll(entry.value.declaredVariables);
}
@@ -5940,7 +5776,7 @@
}
printer.write('{');
String comma = '';
- for (MapMatcherEntry entry in entries) {
+ for (MapPatternEntry entry in entries) {
printer.write(comma);
entry.toTextInternal(printer);
comma = ', ';
@@ -5954,7 +5790,7 @@
}
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -5967,7 +5803,7 @@
void createDeclaredVariableInitializers(
VariableDeclaration matchedExpressionVariable,
InferenceVisitorBase inferenceVisitor) {
- for (MapMatcherEntry entry in entries) {
+ for (MapPatternEntry entry in entries) {
entry.key.createDeclaredVariableInitializers(
matchedExpressionVariable, inferenceVisitor);
entry.value.createDeclaredVariableInitializers(
@@ -5982,28 +5818,28 @@
}
}
-class NamedMatcher extends Matcher {
+class NamedPattern extends Pattern {
final String name;
- final Matcher matcher;
+ final Pattern pattern;
- NamedMatcher(this.name, this.matcher, int fileOffset) : super(fileOffset) {
- matcher.parent = this;
+ NamedPattern(this.name, this.pattern, int fileOffset) : super(fileOffset) {
+ pattern.parent = this;
}
@override
void toTextInternal(AstPrinter printer) {
printer.write(name);
printer.write(': ');
- matcher.toTextInternal(printer);
+ pattern.toTextInternal(printer);
}
@override
String toString() {
- return 'NamedMatcher(${toStringInternal()})';
+ return 'NamedPattern(${toStringInternal()})';
}
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -6016,12 +5852,12 @@
void createDeclaredVariableInitializers(
VariableDeclaration matchedExpressionVariable,
InferenceVisitorBase inferenceVisitor) {
- matcher.createDeclaredVariableInitializers(
+ pattern.createDeclaredVariableInitializers(
matchedExpressionVariable, inferenceVisitor);
}
@override
- List<VariableDeclaration> get declaredVariables => matcher.declaredVariables;
+ List<VariableDeclaration> get declaredVariables => pattern.declaredVariables;
@override
Expression? makeCondition(VariableDeclaration matchedExpressionVariable,
@@ -6030,67 +5866,16 @@
}
}
-class NamedBinder extends Binder {
- final String name;
- final Binder binder;
-
- @override
- final int fileOffset;
-
- NamedBinder(this.name, this.binder, this.fileOffset) {
- binder.parent = this;
- }
-
- @override
- void toTextInternal(AstPrinter printer) {
- printer.write(name);
- printer.write(': ');
- binder.toTextInternal(printer);
- }
-
- @override
- String toString() {
- return 'NamedBinder(${toStringInternal()})';
- }
-
- @override
- BinderInferenceResult acceptInference(InferenceVisitorImpl visitor,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context}) {
- return visitor.visitNamedBinder(this,
- matchedType: matchedType, typeInfos: typeInfos, context: context);
- }
-
- @override
- void createDeclaredVariableInitializers(
- VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor) {
- throw new UnimplementedError(
- "NamedBinder.createDeclaredVariableInitializers");
- }
-
- @override
- List<VariableDeclaration> get declaredVariables => binder.declaredVariables;
-
- @override
- Expression? makeCondition(VariableDeclaration matchedExpressionVariable,
- InferenceVisitorBase inferenceVisitor) {
- return new InvalidExpression("Unimplemented NamedBinder.makeCondition");
- }
-}
-
-class RecordMatcher extends Matcher {
- final List<Matcher> matchers;
+class RecordPattern extends Pattern {
+ final List<Pattern> patterns;
@override
final List<VariableDeclaration> declaredVariables = [];
- RecordMatcher(this.matchers, int fileOffset) : super(fileOffset) {
- setParents(matchers, this);
- for (Matcher matcher in matchers) {
- declaredVariables.addAll(matcher.declaredVariables);
+ RecordPattern(this.patterns, int fileOffset) : super(fileOffset) {
+ setParents(patterns, this);
+ for (Pattern pattern in patterns) {
+ declaredVariables.addAll(pattern.declaredVariables);
}
}
@@ -6098,9 +5883,9 @@
void toTextInternal(AstPrinter printer) {
printer.write('(');
String comma = '';
- for (Matcher matcher in matchers) {
+ for (Pattern pattern in patterns) {
printer.write(comma);
- matcher.toTextInternal(printer);
+ pattern.toTextInternal(printer);
comma = ', ';
}
printer.write(')');
@@ -6112,7 +5897,7 @@
}
@override
- MatcherInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -6125,7 +5910,7 @@
void createDeclaredVariableInitializers(
VariableDeclaration matchedExpressionVariable,
InferenceVisitorBase inferenceVisitor) {
- for (Matcher matcher in matchers) {
+ for (Pattern matcher in patterns) {
matcher.createDeclaredVariableInitializers(
matchedExpressionVariable, inferenceVisitor);
}
@@ -6138,7 +5923,7 @@
}
}
-class VariableBinder extends Binder {
+class VariablePattern extends Pattern {
final DartType? type;
String name;
VariableDeclaration variable;
@@ -6146,16 +5931,17 @@
@override
final List<VariableDeclaration> declaredVariables;
- VariableBinder(this.type, this.name, this.variable)
- : declaredVariables = [variable];
+ VariablePattern(this.type, this.name, this.variable, int fileOffset)
+ : declaredVariables = [variable],
+ super(fileOffset);
@override
- BinderInferenceResult acceptInference(InferenceVisitorImpl visitor,
+ PatternInferenceResult acceptInference(InferenceVisitorImpl visitor,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
- return visitor.visitVariableBinder(this,
+ return visitor.visitVariableMatcher(this,
matchedType: matchedType, typeInfos: typeInfos, context: context);
}
diff --git a/pkg/front_end/lib/src/fasta/source/value_kinds.dart b/pkg/front_end/lib/src/fasta/source/value_kinds.dart
index ca680ac..660abb0 100644
--- a/pkg/front_end/lib/src/fasta/source/value_kinds.dart
+++ b/pkg/front_end/lib/src/fasta/source/value_kinds.dart
@@ -55,7 +55,6 @@
const SingleValueKind<type.AsyncMarker>();
static const ValueKind AsyncModifier =
const SingleValueKind<type.AsyncMarker>();
- static const ValueKind Binder = const SingleValueKind<type.Binder>();
static const ValueKind BreakTarget =
const SingleValueKind<type.JumpTarget>(NullValue.BreakTarget);
static const ValueKind Bool = const SingleValueKind<bool>();
@@ -85,13 +84,13 @@
static const ValueKind Integer = const SingleValueKind<int>();
static const ValueKind MapLiteralEntry =
const SingleValueKind<type.MapLiteralEntry>();
- static const ValueKind MapMatcherEntry =
- const SingleValueKind<type.MapMatcherEntry>();
- static const ValueKind Matcher = const SingleValueKind<type.Matcher>();
- static const ValueKind MatcherOrNull =
- const SingleValueKind<type.Matcher>(NullValue.Matcher);
- static const ValueKind MatcherListOrNull =
- const SingleValueKind<List<type.Matcher>>(NullValue.MatcherList);
+ static const ValueKind MapPatternEntry =
+ const SingleValueKind<type.MapPatternEntry>();
+ static const ValueKind Pattern = const SingleValueKind<type.Pattern>();
+ static const ValueKind PatternOrNull =
+ const SingleValueKind<type.Pattern>(NullValue.Pattern);
+ static const ValueKind PatternListOrNull =
+ const SingleValueKind<List<type.Pattern>>(NullValue.PatternList);
static const ValueKind MethodBody = const SingleValueKind<type.MethodBody>();
static const ValueKind MixinApplicationBuilder =
const SingleValueKind<type.MixinApplicationBuilder>();
diff --git a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
index 350922c..5847b7d 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/inference_visitor.dart
@@ -1776,14 +1776,14 @@
Map<VariableDeclaration, VariableTypeInfo<Node, DartType>> typeInfos = {};
dispatchPattern(conditionResult.inferredType, typeInfos,
- MatchContext.simpleNonFinal, node.matcher);
+ MatchContext.simpleNonFinal, node.pattern);
VariableDeclaration matchedExpressionVariable = engine.forest
.createVariableDeclarationForValue(condition,
type: conditionResult.inferredType);
Expression? matchCondition =
- node.matcher.makeCondition(matchedExpressionVariable, this);
- node.matcher
+ node.pattern.makeCondition(matchedExpressionVariable, this);
+ node.pattern
.createDeclaredVariableInitializers(matchedExpressionVariable, this);
flowAnalysis.ifStatement_thenBegin(condition, node);
@@ -1810,12 +1810,12 @@
List<Statement> replacementStatements = [matchedExpressionVariable];
if (matchCondition == null) {
- replacementStatements.addAll(node.matcher.declaredVariables);
+ replacementStatements.addAll(node.pattern.declaredVariables);
replacementStatements.add(then);
} else {
- if (node.matcher.declaredVariables.isNotEmpty) {
+ if (node.pattern.declaredVariables.isNotEmpty) {
List<Statement> thenBodyStatements = [];
- thenBodyStatements.addAll(node.matcher.declaredVariables);
+ thenBodyStatements.addAll(node.pattern.declaredVariables);
thenBodyStatements.add(then);
then = engine.forest
.createBlock(then.fileOffset, then.fileOffset, thenBodyStatements);
@@ -7583,10 +7583,7 @@
Map<VariableDeclaration, VariableTypeInfo<Node, DartType>> typeInfos,
MatchContext<Node, Expression> context,
Node node) {
- if (node is Matcher) {
- node.acceptInference(this,
- matchedType: matchedType, typeInfos: typeInfos, context: context);
- } else if (node is Binder) {
+ if (node is Pattern) {
node.acceptInference(this,
matchedType: matchedType, typeInfos: typeInfos, context: context);
} else {
@@ -7761,42 +7758,15 @@
assert(_rewriteStack.isEmpty);
}
- MatcherInferenceResult visitBinderMatcher(BinderMatcher matcher,
+ PatternInferenceResult visitDummyMatcher(DummyPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
- matcher.binder.acceptInference(this,
- matchedType: matchedType, typeInfos: typeInfos, context: context);
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
- BinderInferenceResult visitDummyBinder(DummyBinder binder,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context}) {
- return const BinderInferenceResult();
- }
-
- MatcherInferenceResult visitDummyMatcher(DummyMatcher matcher,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context}) {
- return const MatcherInferenceResult();
- }
-
- BinderInferenceResult visitListBinder(ListBinder binder,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context}) {
- // TODO(cstefantsova): Implement visitListBinder.
- return const BinderInferenceResult();
- }
-
- BinderInferenceResult visitVariableBinder(VariableBinder binder,
+ PatternInferenceResult visitVariableMatcher(VariablePattern binder,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -7808,18 +7778,18 @@
if (binder.type == null) {
binder.variable.type = inferredType;
}
- return const BinderInferenceResult();
+ return const PatternInferenceResult();
}
- BinderInferenceResult visitWildcardBinder(WildcardBinder binder,
+ PatternInferenceResult visitWildcardBinder(WildcardPattern binder,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
- return const BinderInferenceResult();
+ return const PatternInferenceResult();
}
- MatcherInferenceResult visitExpressionMatcher(ExpressionMatcher matcher,
+ PatternInferenceResult visitExpressionMatcher(ExpressionPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -7827,10 +7797,10 @@
ExpressionInferenceResult expressionResult =
inferExpression(matcher.expression, matchedType, false);
matcher.expression = expressionResult.expression;
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
- MatcherInferenceResult visitBinaryMatcher(BinaryMatcher matcher,
+ PatternInferenceResult visitBinaryMatcher(BinaryPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -7839,22 +7809,22 @@
matchedType: matchedType, typeInfos: typeInfos, context: context);
matcher.right.acceptInference(this,
matchedType: matchedType, typeInfos: typeInfos, context: context);
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
- MatcherInferenceResult visitCastMatcher(CastMatcher matcher,
+ PatternInferenceResult visitCastMatcher(CastPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
- matcher.matcher.acceptInference(this,
+ matcher.pattern.acceptInference(this,
matchedType: const DynamicType(),
typeInfos: typeInfos,
context: context);
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
- MatcherInferenceResult visitNullAssertMatcher(NullAssertMatcher matcher,
+ PatternInferenceResult visitNullAssertMatcher(NullAssertPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -7862,11 +7832,11 @@
DartType nestedMatchedType = computeTypeWithoutNullabilityMarker(
matchedType,
isNonNullableByDefault: isNonNullableByDefault);
- return matcher.matcher.acceptInference(this,
+ return matcher.pattern.acceptInference(this,
matchedType: nestedMatchedType, typeInfos: typeInfos, context: context);
}
- MatcherInferenceResult visitNullCheckMatcher(NullCheckMatcher matcher,
+ PatternInferenceResult visitNullCheckMatcher(NullCheckPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
@@ -7874,62 +7844,53 @@
DartType nestedMatchedType = computeTypeWithoutNullabilityMarker(
matchedType,
isNonNullableByDefault: isNonNullableByDefault);
- return matcher.matcher.acceptInference(this,
+ return matcher.pattern.acceptInference(this,
matchedType: nestedMatchedType, typeInfos: typeInfos, context: context);
}
- MatcherInferenceResult visitListMatcher(ListMatcher matcher,
+ PatternInferenceResult visitListMatcher(ListPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
// TODO(cstefantsova): Implement visitListMatcher.
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
- MatcherInferenceResult visitRelationalMatcher(RelationalMatcher matcher,
+ PatternInferenceResult visitRelationalMatcher(RelationalPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
// TODO(cstefantsova): Should the expression be inferred?
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
- MatcherInferenceResult visitMapMatcher(MapMatcher matcher,
+ PatternInferenceResult visitMapMatcher(MapPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
// TODO(cstefantsova): Implement visitMapMatcher.
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
- MatcherInferenceResult visitNamedMatcher(NamedMatcher matcher,
+ PatternInferenceResult visitNamedMatcher(NamedPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
// TODO(cstefantsova): Implement visitNamedMatcher.
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
- BinderInferenceResult visitNamedBinder(NamedBinder matcher,
- {required DartType matchedType,
- required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
- typeInfos,
- required MatchContext<Node, Expression> context}) {
- // TODO(cstefantsova): Implement visitNamedBinder.
- return const BinderInferenceResult();
- }
-
- MatcherInferenceResult visitRecordMatcher(RecordMatcher matcher,
+ PatternInferenceResult visitRecordMatcher(RecordPattern matcher,
{required DartType matchedType,
required Map<VariableDeclaration, VariableTypeInfo<Node, DartType>>
typeInfos,
required MatchContext<Node, Expression> context}) {
// TODO(cstefantsova): Implement visitRecordMatcher.
- return const MatcherInferenceResult();
+ return const PatternInferenceResult();
}
}
@@ -7948,10 +7909,6 @@
DartType? iterableSpreadType;
}
-class MatcherInferenceResult {
- const MatcherInferenceResult();
-}
-
-class BinderInferenceResult {
- const BinderInferenceResult();
+class PatternInferenceResult {
+ const PatternInferenceResult();
}
diff --git a/pkg/front_end/test/patterns/desugaring_test.dart b/pkg/front_end/test/patterns/desugaring_test.dart
deleted file mode 100644
index ec60222..0000000
--- a/pkg/front_end/test/patterns/desugaring_test.dart
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:kernel/ast.dart';
-import 'package:kernel/text/ast_to_text.dart';
-
-import 'package:front_end/src/fasta/kernel/internal_ast.dart';
-
-void runTests() {
- checkExpected(
- makeSimpleComponentWithPatternVariableDeclaration(
- new PatternVariableDeclaration(
- new ListBinder(const DynamicType(),
- [new WildcardBinder(null, offset: TreeNode.noOffset)],
- offset: TreeNode.noOffset),
- new IntLiteral(0),
- offset: TreeNode.noOffset)),
- makeExpectationOfSimpleComponentWithPatternVariableDeclaration(
- "PatternVariableDeclaration"));
-}
-
-Component makeSimpleComponentWithPatternVariableDeclaration(
- PatternVariableDeclaration patternVariableDeclaration) {
- Uri fileUri = Uri.parse("test:///test.dart");
- Uri importUri = Uri.parse("test.dart");
-
- Block body = new Block([patternVariableDeclaration]);
- FunctionNode functionNode = new FunctionNode(body);
- Procedure procedure = new Procedure(
- new Name("test"), ProcedureKind.Method, functionNode,
- fileUri: fileUri);
- Library library =
- new Library(importUri, procedures: [procedure], fileUri: fileUri);
- Component component = new Component(libraries: [library]);
- return component;
-}
-
-String makeExpectationOfSimpleComponentWithPatternVariableDeclaration(
- String patternVariableDeclarationExpectation) {
- return """
-main = <No Member>;
-library from "test.dart" as test {
-
- method test() → dynamic {
- ${patternVariableDeclarationExpectation}
- }
-}
-""";
-}
-
-void checkExpected(Component component, String expected) {
- String actual = componentToString(component);
- if (actual != expected) {
- // This is a very primitive substitute for the diff output of the actual
- // expectation tests.
- List<String> actualLines = actual.split("\n");
- List<String> expectedLines = expected.split("\n");
- StringBuffer output = new StringBuffer();
- if (actualLines.length < expectedLines.length) {
- output.writeln("Actual output is shorter than the expected.");
- } else if (actualLines.length > expectedLines.length) {
- output.writeln("Actual output is longer than the expected.");
- }
- int minLines = actualLines.length < expectedLines.length
- ? actualLines.length
- : expectedLines.length;
- for (int i = 0; i < minLines; i++) {
- // Include one line of the difference.
- if (actualLines[i] != expectedLines[i]) {
- output.writeln(
- "Line $i is different in the actual output and the expected.\n"
- "Actual : ${actualLines[i]}\n"
- "Expected: ${expectedLines[i]}");
- break;
- }
- }
- output.writeln("Full actual output:\n${'=' * 72}\n${actual}\n${'=' * 72}");
- output.writeln(
- "Full expected output:\n${'=' * 72}\n${expected}\n${'=' * 72}");
- throw new StateError("${output}");
- }
-}
-
-void main(List<String> args) {
- runTests();
-}
diff --git a/pkg/front_end/test/text_representation/internal_ast_text_representation_test.dart b/pkg/front_end/test/text_representation/internal_ast_text_representation_test.dart
index f37bc84..f29e612 100644
--- a/pkg/front_end/test/text_representation/internal_ast_text_representation_test.dart
+++ b/pkg/front_end/test/text_representation/internal_ast_text_representation_test.dart
@@ -42,7 +42,7 @@
"Unexpected limited strategy text for ${node.runtimeType}");
}
-void testMatcher(Matcher node, String normal,
+void testMatcher(Pattern node, String normal,
{String? verbose, String? limited}) {
Expect.stringEquals(normal, node.toText(normalStrategy),
"Unexpected normal strategy text for ${node.runtimeType}");
@@ -1058,28 +1058,28 @@
void _testForInMapEntry() {}
void _testExpressionMatcher() {
- testMatcher(new ExpressionMatcher(new IntLiteral(0)), '''
+ testMatcher(new ExpressionPattern(new IntLiteral(0)), '''
0''');
- testMatcher(new ExpressionMatcher(new BoolLiteral(true)), '''
+ testMatcher(new ExpressionPattern(new BoolLiteral(true)), '''
true''');
}
void _testBinaryMatcher() {
testMatcher(
- new BinaryMatcher(
- new ExpressionMatcher(new IntLiteral(0)),
- BinaryMatcherKind.and,
- new ExpressionMatcher(new IntLiteral(1)),
+ new BinaryPattern(
+ new ExpressionPattern(new IntLiteral(0)),
+ BinaryPatternKind.and,
+ new ExpressionPattern(new IntLiteral(1)),
TreeNode.noOffset),
'''
0 & 1''');
testMatcher(
- new BinaryMatcher(
- new ExpressionMatcher(new IntLiteral(0)),
- BinaryMatcherKind.or,
- new ExpressionMatcher(new IntLiteral(1)),
+ new BinaryPattern(
+ new ExpressionPattern(new IntLiteral(0)),
+ BinaryPatternKind.or,
+ new ExpressionPattern(new IntLiteral(1)),
TreeNode.noOffset),
'''
0 | 1''');
@@ -1087,7 +1087,7 @@
void _testCastMatcher() {
testMatcher(
- new CastMatcher(new ExpressionMatcher(new IntLiteral(0)),
+ new CastPattern(new ExpressionPattern(new IntLiteral(0)),
const DynamicType(), TreeNode.noOffset),
'''
0 as dynamic''');
@@ -1095,27 +1095,27 @@
void _testNullAssertMatcher() {
testMatcher(
- new NullAssertMatcher(
- new ExpressionMatcher(new IntLiteral(0)), TreeNode.noOffset),
+ new NullAssertPattern(
+ new ExpressionPattern(new IntLiteral(0)), TreeNode.noOffset),
'''
0!''');
}
void _testNullCheckMatcher() {
testMatcher(
- new NullCheckMatcher(
- new ExpressionMatcher(new IntLiteral(0)), TreeNode.noOffset),
+ new NullCheckPattern(
+ new ExpressionPattern(new IntLiteral(0)), TreeNode.noOffset),
'''
0?''');
}
void _testListMatcher() {
testMatcher(
- new ListMatcher(
+ new ListPattern(
const DynamicType(),
[
- new ExpressionMatcher(new IntLiteral(0)),
- new ExpressionMatcher(new IntLiteral(1)),
+ new ExpressionPattern(new IntLiteral(0)),
+ new ExpressionPattern(new IntLiteral(1)),
],
TreeNode.noOffset),
'''
@@ -1124,50 +1124,50 @@
void _testRelationalMatcher() {
testMatcher(
- new RelationalMatcher(
- RelationalMatcherKind.equals, new IntLiteral(0), TreeNode.noOffset),
+ new RelationalPattern(
+ RelationalPatternKind.equals, new IntLiteral(0), TreeNode.noOffset),
'''
== 0''');
testMatcher(
- new RelationalMatcher(RelationalMatcherKind.notEquals, new IntLiteral(1),
+ new RelationalPattern(RelationalPatternKind.notEquals, new IntLiteral(1),
TreeNode.noOffset),
'''
!= 1''');
testMatcher(
- new RelationalMatcher(
- RelationalMatcherKind.lessThan, new IntLiteral(2), TreeNode.noOffset),
+ new RelationalPattern(
+ RelationalPatternKind.lessThan, new IntLiteral(2), TreeNode.noOffset),
'''
< 2''');
}
void _testMapMatcher() {
- testMatcher(new MapMatcher(null, null, [], TreeNode.noOffset), '''
+ testMatcher(new MapPattern(null, null, [], TreeNode.noOffset), '''
{}''');
testMatcher(
- new MapMatcher(
+ new MapPattern(
const DynamicType(), const DynamicType(), [], TreeNode.noOffset),
'''
<dynamic, dynamic>{}''');
testMatcher(
- new MapMatcher(
+ new MapPattern(
null,
null,
[
- new MapMatcherEntry(new ExpressionMatcher(new IntLiteral(0)),
- new ExpressionMatcher(new IntLiteral(1)), TreeNode.noOffset),
+ new MapPatternEntry(new ExpressionPattern(new IntLiteral(0)),
+ new ExpressionPattern(new IntLiteral(1)), TreeNode.noOffset),
],
TreeNode.noOffset),
'''
{0: 1}''');
testMatcher(
- new MapMatcher(
+ new MapPattern(
null,
null,
[
- new MapMatcherEntry(new ExpressionMatcher(new IntLiteral(0)),
- new ExpressionMatcher(new IntLiteral(1)), TreeNode.noOffset),
- new MapMatcherEntry(new ExpressionMatcher(new IntLiteral(2)),
- new ExpressionMatcher(new IntLiteral(3)), TreeNode.noOffset),
+ new MapPatternEntry(new ExpressionPattern(new IntLiteral(0)),
+ new ExpressionPattern(new IntLiteral(1)), TreeNode.noOffset),
+ new MapPatternEntry(new ExpressionPattern(new IntLiteral(2)),
+ new ExpressionPattern(new IntLiteral(3)), TreeNode.noOffset),
],
TreeNode.noOffset),
'''
@@ -1178,7 +1178,7 @@
testStatement(
new IfCaseStatement(
new IntLiteral(0),
- new ExpressionMatcher(new IntLiteral(1)),
+ new ExpressionPattern(new IntLiteral(1)),
null,
new ReturnStatement(),
null,
@@ -1189,7 +1189,7 @@
testStatement(
new IfCaseStatement(
new IntLiteral(0),
- new ExpressionMatcher(new IntLiteral(1)),
+ new ExpressionPattern(new IntLiteral(1)),
null,
new ReturnStatement(new IntLiteral(2)),
new ReturnStatement(new IntLiteral(3)),
@@ -1200,7 +1200,7 @@
testStatement(
new IfCaseStatement(
new IntLiteral(0),
- new ExpressionMatcher(new IntLiteral(1)),
+ new ExpressionPattern(new IntLiteral(1)),
new IntLiteral(2),
new ReturnStatement(),
null,
@@ -1211,7 +1211,7 @@
testStatement(
new IfCaseStatement(
new IntLiteral(0),
- new ExpressionMatcher(new IntLiteral(1)),
+ new ExpressionPattern(new IntLiteral(1)),
new IntLiteral(2),
new ReturnStatement(new IntLiteral(3)),
new ReturnStatement(new IntLiteral(4)),