Skip to content

Commit 9cd4cdf

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Fix failing ParameterListTest cases.
These test cases were broken by https://dart-review.googlesource.com/c/sdk/+/252566 and were marked with `@failingTest`. The reason for the breakage was that the aforementioned CL changed the implementation of `AstComparator.visitSimpleFormalParameter` so that it compared the parameter's names using `isEqualTokens` rather than `isEqualNodes`. When this logic is used by `ParameterListTest`, `isEqualTokens` and `isEqualNodes` are being overridden by methods in the derived class `ResultComparator`, and one of the special behaviors of `ResultComparator.isEqualNodes` is to allow the simple identifier `_k_` to be substituted for a keyword token. To fix the test, this special behavior needs to be moved from `ResultComparator.isEqualNodes` to `ResultComparator.isEqualTokens`. This paves the way for a follow-up CL in which I plan to rewrite `ResultComparator` so that it doesn't depend on `AstComparator`; that in turn will allow `AstComparator` to be rmoved. Change-Id: I8434c7c694e1e5c613df62bf34ee69126fb0c2ec Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418900 Reviewed-by: Konstantin Shcheglov <[email protected]> Auto-Submit: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 36faa9a commit 9cd4cdf

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

pkg/analyzer/test/src/fasta/recovery/missing_code_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,6 @@ f(a, _s_, b) {}
565565
''');
566566
}
567567

568-
@failingTest
569568
void test_fieldFormalParameter_noPeriod_last() {
570569
testRecovery('''
571570
class C {
@@ -580,7 +579,6 @@ class C {
580579
''');
581580
}
582581

583-
@failingTest
584582
void test_fieldFormalParameter_noPeriod_notLast() {
585583
testRecovery('''
586584
class C {

pkg/analyzer/test/src/fasta/recovery/recovery_test_support.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,20 @@ class ResultComparator extends AstComparator {
132132
if (first.isSynthetic && second.name == '_s_') {
133133
return true;
134134
}
135-
if (first.token.isKeyword && second.name == '_k_') {
136-
return true;
137-
}
138135
}
139136
return super.isEqualNodes(first, second);
140137
}
141138

142139
/// Overridden to ignore the offsets of tokens because these can legitimately
143140
/// be different.
144141
@override
145-
bool isEqualTokensNotNull(Token first, Token second) =>
146-
(first.isSynthetic && first.type == second.type) ||
147-
(first.length == second.length && first.lexeme == second.lexeme);
142+
bool isEqualTokensNotNull(Token first, Token second) {
143+
if (first.isKeyword && second.lexeme == '_k_') {
144+
return true;
145+
}
146+
return (first.isSynthetic && first.type == second.type) ||
147+
(first.length == second.length && first.lexeme == second.lexeme);
148+
}
148149

149150
void _safelyWriteNodePath(StringBuffer buffer, AstNode? node) {
150151
buffer.write(' path: ');

0 commit comments

Comments
 (0)