Skip to content

Commit ebbfb48

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Change-Id: I38cdf22aff3bb89f2f05001f878da334793c18f9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108270 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
1 parent 68124e9 commit ebbfb48

File tree

4 files changed

+33
-27
lines changed

4 files changed

+33
-27
lines changed

pkg/analyzer/lib/src/util/ast_data_extractor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ abstract class AstDataExtractor<T> extends GeneralizingAstVisitor<dynamic>
107107
}
108108

109109
class _Failure implements Exception {
110-
final message;
110+
final String message;
111111

112112
_Failure([this.message]);
113113

pkg/analyzer/test/src/dart/resolution/flow_analysis_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class FlowTestBase extends DriverResolutionTest {
2828
/// Resolve the given [code] and track nullability in the unit.
2929
Future<void> trackCode(String code) async {
3030
if (await checkTests(
31-
code, _resultComputer, const _FlowAnalysisDataComputer())) {
31+
code, _computeResult, const _FlowAnalysisDataComputer())) {
3232
fail('Failure(s)');
3333
}
3434
}
3535

36-
Future<ResolvedUnitResult> _resultComputer(String code) async {
36+
Future<ResolvedUnitResult> _computeResult(String code) async {
3737
addTestFile(code);
3838
await resolveTestFile();
3939
var unit = result.unit;

pkg/analyzer/test/src/dart/resolution/type_promotion_test.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class TypePromotionTest extends DriverResolutionTest {
3030

3131
Future<void> resolveCode(String code) async {
3232
if (await checkTests(
33-
code, _resultComputer, const _TypePromotionDataComputer())) {
33+
code, _computeResult, const _TypePromotionDataComputer())) {
3434
fail('Failure(s)');
3535
}
3636
}
@@ -695,7 +695,7 @@ void f(bool b, Object x) {
695695
''');
696696
}
697697

698-
Future<ResolvedUnitResult> _resultComputer(String code) async {
698+
Future<ResolvedUnitResult> _computeResult(String code) async {
699699
addTestFile(code);
700700
await resolveTestFile();
701701
return result;
@@ -725,10 +725,9 @@ class _TypePromotionDataExtractor extends AstDataExtractor<DartType> {
725725
DartType computeNodeValue(Id id, AstNode node) {
726726
if (node is SimpleIdentifier && node.inGetterContext()) {
727727
var element = node.staticElement;
728-
if (element is VariableElement &&
729-
(element is LocalVariableElement || element is ParameterElement)) {
728+
if (element is LocalVariableElement || element is ParameterElement) {
730729
var promotedType = node.staticType;
731-
if (promotedType != element.type) {
730+
if (promotedType != (element as VariableElement).type) {
732731
return promotedType;
733732
}
734733
}

pkg/analyzer/test/util/id_equivalence_helper.dart

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,26 @@ void _expectFalse(bool b, String message) {
259259

260260
class CompiledData<T> {
261261
final Uri mainUri;
262+
263+
/// For each Uri, a map associating an element id with the instrumentation
264+
/// data we've collected for it.
262265
final Map<Uri, Map<Id, ActualData<T>>> actualMaps;
266+
267+
/// Collected instrumentation data that doesn't refer to any of the user
268+
/// files. (E.g. information the test has collected about files in
269+
/// `dart:core`).
263270
final Map<Id, ActualData<T>> globalData;
264271

265272
CompiledData(this.mainUri, this.actualMaps, this.globalData);
266273

267274
Map<int, List<String>> computeAnnotations(Uri uri) {
268-
Map<Id, ActualData<T>> thisMap = actualMaps[uri];
275+
Map<Id, ActualData<T>> actualMap = actualMaps[uri];
269276
Map<int, List<String>> annotations = <int, List<String>>{};
270-
thisMap.forEach((Id id, ActualData<T> data1) {
271-
String value1 = '${data1.value}';
277+
actualMap.forEach((Id id, ActualData<T> actualData) {
278+
String actualValue = '${actualData.value}';
272279
annotations
273-
.putIfAbsent(data1.offset, () => [])
274-
.add(colorizeActual(value1));
280+
.putIfAbsent(actualData.offset, () => [])
281+
.add(colorizeActual(actualValue));
275282
});
276283
return annotations;
277284
}
@@ -280,27 +287,27 @@ class CompiledData<T> {
280287
Map<Id, ActualData<T>> thisMap, Map<Id, ActualData<T>> otherMap, Uri uri,
281288
{bool includeMatches: false}) {
282289
Map<int, List<String>> annotations = <int, List<String>>{};
283-
thisMap.forEach((Id id, ActualData<T> data1) {
284-
ActualData<T> data2 = otherMap[id];
285-
String value1 = '${data1.value}';
286-
if (data1.value != data2?.value) {
287-
String value2 = '${data2?.value ?? '---'}';
290+
thisMap.forEach((Id id, ActualData<T> thisData) {
291+
ActualData<T> otherData = otherMap[id];
292+
String thisValue = '${thisData.value}';
293+
if (thisData.value != otherData?.value) {
294+
String otherValue = '${otherData?.value ?? '---'}';
288295
annotations
289-
.putIfAbsent(data1.offset, () => [])
290-
.add(colorizeDiff(value1, ' | ', value2));
296+
.putIfAbsent(thisData.offset, () => [])
297+
.add(colorizeDiff(thisValue, ' | ', otherValue));
291298
} else if (includeMatches) {
292299
annotations
293-
.putIfAbsent(data1.offset, () => [])
294-
.add(colorizeMatch(value1));
300+
.putIfAbsent(thisData.offset, () => [])
301+
.add(colorizeMatch(thisValue));
295302
}
296303
});
297-
otherMap.forEach((Id id, ActualData<T> data2) {
304+
otherMap.forEach((Id id, ActualData<T> otherData) {
298305
if (!thisMap.containsKey(id)) {
299-
String value1 = '---';
300-
String value2 = '${data2.value}';
306+
String thisValue = '---';
307+
String otherValue = '${otherData.value}';
301308
annotations
302-
.putIfAbsent(data2.offset, () => [])
303-
.add(colorizeDiff(value1, ' | ', value2));
309+
.putIfAbsent(otherData.offset, () => [])
310+
.add(colorizeDiff(thisValue, ' | ', otherValue));
304311
}
305312
});
306313
return annotations;

0 commit comments

Comments
 (0)