Skip to content

Commit 1d1f3a5

Browse files
[nnbd_migration] Origin for inferred instance creation bounds
Change-Id: Ice51e241833e4eb70f7b41accc3908717ca8bd72 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137659 Reviewed-by: Paul Berry <[email protected]>
1 parent e9df1ee commit 1d1f3a5

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,31 @@ void main() {
320320
details: ['This type parameter is instantiated with a nullable type']);
321321
}
322322

323+
Future<void> test_bound_instantiation_implicit() async {
324+
UnitInfo unit = await buildInfoForSingleTestFile('''
325+
class C<T extends Object> {
326+
C(T/*!*/ t);
327+
}
328+
329+
void main() {
330+
C(null);
331+
}
332+
''', migratedContent: '''
333+
class C<T extends Object?> {
334+
C(T/*!*/ t);
335+
}
336+
337+
void main() {
338+
C(null);
339+
}
340+
''');
341+
List<RegionInfo> regions = unit.regions;
342+
expect(regions, hasLength(2));
343+
assertRegion(region: regions[0], offset: 24, details: [
344+
'This type parameter is instantiated with an inferred nullable type'
345+
]);
346+
}
347+
323348
Future<void> test_bound_method_explicit() async {
324349
UnitInfo unit = await buildInfoForSingleTestFile('''
325350
f<T extends Object> {}

pkg/nnbd_migration/lib/src/edge_builder.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,8 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
909909
.toList();
910910
instrumentation?.implicitTypeArguments(
911911
source, node, decoratedTypeArguments);
912+
parameterEdgeOrigins = List.filled(typeArgumentTypes.length,
913+
InferredTypeParameterInstantiationOrigin(source, node));
912914
} else {
913915
// Note: this could happen if the code being migrated has errors.
914916
typeArgumentTypes = const [];

0 commit comments

Comments
 (0)