Skip to content

Commit eb387e8

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Include presence of a variable initializer into API signature.
VariableElement.initializer is either null or non-null, depending on the presence of absence of the initializer. R=brianwilkerson@google.com, paulberry@google.com Change-Id: I33defcad4a16d1d6e6896f10e312570099177f89 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107186 Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent c22addb commit eb387e8

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class AnalysisDriver implements AnalysisDriverGeneric {
9595
/**
9696
* The version of data format, should be incremented on every format change.
9797
*/
98-
static const int DATA_VERSION = 84;
98+
static const int DATA_VERSION = 85;
9999

100100
/**
101101
* The number of exception contexts allowed to write. Once this field is

pkg/analyzer/lib/src/dart/analysis/unlinked_api_signature.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class _UnitApiSignatureComputer {
105105
signature.addInt(variableList.variables.length);
106106
for (var variable in variableList.variables) {
107107
addTokens(variable.beginToken, variable.name.endToken);
108+
signature.addBool(variable.initializer != null);
108109
addToken(variable.endToken.next); // `,` or `;`
109110
}
110111
}

pkg/analyzer/test/src/dart/analysis/unlinked_api_signature_test.dart

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,11 @@ class C {
226226
test_class_field_withType() {
227227
assertSameSignature(r'''
228228
class C {
229-
int a = 1, b, c = 3;
229+
int a = 1;
230230
}
231231
''', r'''
232232
class C {
233-
int a = 0, b = 2, c;
233+
int a = 2;
234234
}
235235
''');
236236
}
@@ -744,11 +744,11 @@ mixin M {
744744
test_mixin_field_withType() {
745745
assertSameSignature(r'''
746746
mixin M {
747-
int a = 1, b, c = 3;
747+
int a = 1;
748748
}
749749
''', r'''
750750
mixin M {
751-
int a = 0, b = 2, c;
751+
int a = 2;
752752
}
753753
''');
754754
}
@@ -819,9 +819,9 @@ var a = 1, b, c = 3, d = 4;;
819819

820820
test_topLevelVariable_withType() {
821821
assertSameSignature(r'''
822-
int a = 1, b, c = 3;
822+
int a = 1;
823823
''', r'''
824-
int a = 0, b = 2, c;
824+
int a = 2;
825825
''');
826826
}
827827

@@ -841,6 +841,22 @@ final int a = 2;
841841
''');
842842
}
843843

844+
test_topLevelVariable_withType_initializer_add() {
845+
assertNotSameSignature(r'''
846+
int a;
847+
''', r'''
848+
int a = 1;
849+
''');
850+
}
851+
852+
test_topLevelVariable_withType_initializer_remove() {
853+
assertNotSameSignature(r'''
854+
int a = 1;
855+
''', r'''
856+
int a;
857+
''');
858+
}
859+
844860
test_typedef_generic_parameters_type() {
845861
assertNotSameSignature(r'''
846862
typedef F = void Function(int);

0 commit comments

Comments
 (0)