Skip to content

Commit 81d4cc6

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Issue 40701. Include 'late' into unlinked API signature.
[email protected], [email protected] Bug: #40701 Change-Id: Ia11ff4e65e779c4a370a6fec539564c0533bffa3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136529 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 6da0090 commit 81d4cc6

File tree

3 files changed

+88
-3
lines changed

3 files changed

+88
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ typedef WorkToWaitAfterComputingResult = Future<void> Function(String path);
9191
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
9292
class AnalysisDriver implements AnalysisDriverGeneric {
9393
/// The version of data format, should be incremented on every format change.
94-
static const int DATA_VERSION = 96;
94+
static const int DATA_VERSION = 97;
9595

9696
/// The length of the list returned by [_computeDeclaredVariablesSignature].
9797
static const int _declaredVariablesSignatureLength = 4;

pkg/analyzer/lib/src/dart/ast/ast.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10482,7 +10482,9 @@ class VariableDeclarationListImpl extends AnnotatedNodeImpl
1048210482

1048310483
@override
1048410484
Token get firstTokenAfterCommentAndMetadata {
10485-
if (keyword != null) {
10485+
if (lateKeyword != null) {
10486+
return lateKeyword;
10487+
} else if (keyword != null) {
1048610488
return keyword;
1048710489
} else if (_type != null) {
1048810490
return _type.beginToken;

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

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'package:analyzer/dart/analysis/features.dart';
56
import 'package:analyzer/src/dart/analysis/unlinked_api_signature.dart';
7+
import 'package:analyzer/src/generated/engine.dart';
68
import 'package:test/test.dart';
79
import 'package:test_reflective_loader/test_reflective_loader.dart';
810

@@ -11,6 +13,7 @@ import '../ast/parse_base.dart';
1113
main() {
1214
defineReflectiveSuite(() {
1315
defineReflectiveTests(UnitApiSignatureTest);
16+
defineReflectiveTests(UnitApiSignatureWithNullSafetyTest);
1417
});
1518
}
1619

@@ -199,6 +202,30 @@ class B extends A {}
199202
''');
200203
}
201204

205+
test_class_field_final_add() {
206+
assertNotSameSignature(r'''
207+
class C {
208+
int a = 0;
209+
}
210+
''', r'''
211+
class C {
212+
final int a = 0;
213+
}
214+
''');
215+
}
216+
217+
test_class_field_static_add() {
218+
assertNotSameSignature(r'''
219+
class C {
220+
int a;
221+
}
222+
''', r'''
223+
class C {
224+
static int a;
225+
}
226+
''');
227+
}
228+
202229
test_class_field_withoutType() {
203230
assertNotSameSignature(r'''
204231
class C {
@@ -790,7 +817,7 @@ class A {}
790817
// @dart = 2.6
791818
class A {}
792819
''', r'''
793-
// @dart = 2.5
820+
// @dart = 2.2
794821
class A {}
795822
''');
796823
}
@@ -1011,6 +1038,14 @@ mixin M on A {}
10111038
''');
10121039
}
10131040

1041+
test_topLevelVariable_final_add() {
1042+
assertNotSameSignature(r'''
1043+
int a = 0;
1044+
''', r'''
1045+
final int a = 0;
1046+
''');
1047+
}
1048+
10141049
test_topLevelVariable_withoutType() {
10151050
assertNotSameSignature(r'''
10161051
var a = 1;
@@ -1075,3 +1110,51 @@ typedef F = void Function(double);
10751110
''');
10761111
}
10771112
}
1113+
1114+
@reflectiveTest
1115+
class UnitApiSignatureWithNullSafetyTest extends UnitApiSignatureTest {
1116+
@override
1117+
AnalysisOptionsImpl get analysisOptions => AnalysisOptionsImpl()
1118+
..contextFeatures = FeatureSet.forTesting(
1119+
sdkVersion: '2.3.0', additionalFeatures: [Feature.non_nullable]);
1120+
1121+
test_class_field_late_add() {
1122+
assertNotSameSignature(r'''
1123+
class C {
1124+
int a;
1125+
}
1126+
''', r'''
1127+
class C {
1128+
late int a;
1129+
}
1130+
''');
1131+
}
1132+
1133+
test_class_field_late_remove() {
1134+
assertNotSameSignature(r'''
1135+
class C {
1136+
late int a;
1137+
}
1138+
''', r'''
1139+
class C {
1140+
int a;
1141+
}
1142+
''');
1143+
}
1144+
1145+
test_topLevelVariable_late_add() {
1146+
assertNotSameSignature(r'''
1147+
int a;
1148+
''', r'''
1149+
late int a;
1150+
''');
1151+
}
1152+
1153+
test_topLevelVariable_late_remove() {
1154+
assertNotSameSignature(r'''
1155+
late int a;
1156+
''', r'''
1157+
int a;
1158+
''');
1159+
}
1160+
}

0 commit comments

Comments
 (0)