Skip to content

Commit c0bcfb7

Browse files
[nnbd_migration] Add a description for type parameter instantiation
Change-Id: Id8e3c4c98f3569b794e90d8a7a74d245f6f89504 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137648 Reviewed-by: Janice Collins <[email protected]> Reviewed-by: Paul Berry <[email protected]>
1 parent 734ad9c commit c0bcfb7

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

pkg/analysis_server/lib/src/edit/nnbd_migration/info_builder.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ class InfoBuilder {
179179
return 'A length is specified in the "List()" constructor and the list '
180180
'items are initialized to null';
181181
}
182+
if (origin.kind == EdgeOriginKind.typeParameterInstantiation) {
183+
return 'This type parameter is instantiated with a nullable type';
184+
}
182185

183186
CompilationUnit unit = node.thisOrAncestorOfType<CompilationUnit>();
184187
int lineNumber = unit.lineInfo.getLocation(node.offset).lineNumber;

pkg/analysis_server/test/src/edit/nnbd_migration/info_builder_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,24 @@ int? f([num? a]) {
280280
details: ['The value of the expression is nullable']);
281281
}
282282

283+
Future<void> test_bound() async {
284+
UnitInfo unit = await buildInfoForSingleTestFile('''
285+
class C<T extends Object> {}
286+
287+
C<int/*?*/> c;
288+
''', migratedContent: '''
289+
class C<T extends Object?> {}
290+
291+
C<int?/*?*/>? c;
292+
''');
293+
List<RegionInfo> regions = unit.regions;
294+
expect(regions, hasLength(3));
295+
assertRegion(
296+
region: regions[0],
297+
offset: 24,
298+
details: ['This type parameter is instantiated with a nullable type']);
299+
}
300+
283301
Future<void> test_discardCondition() async {
284302
UnitInfo unit = await buildInfoForSingleTestFile('''
285303
void g(int i) {

0 commit comments

Comments
 (0)