Skip to content

Commit 734ad9c

Browse files
[nnbd_migration] Add an edge origin for type name parameters.
Change-Id: Ifad0a0ae6e641360ac5be5eea5c61e667be33cbc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137432 Reviewed-by: Paul Berry <[email protected]>
1 parent 8e38503 commit 734ad9c

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

pkg/nnbd_migration/lib/instrumentation.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ enum EdgeOriginKind {
157157
thisOrSuper,
158158
throw_,
159159
typedefReference,
160+
typeParameterInstantiation,
160161
uninitializedRead,
161162
}
162163

pkg/nnbd_migration/lib/src/edge_builder.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,8 +1556,11 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
15561556
_unimplemented(typeName,
15571557
'No decorated type for type argument ${typeArguments[i]} ($i)');
15581558
}
1559-
_checkAssignment(null,
1560-
source: argumentType, destination: bound, hard: true);
1559+
_checkAssignment(
1560+
TypeParameterInstantiationOrigin(source, typeArguments[i]),
1561+
source: argumentType,
1562+
destination: bound,
1563+
hard: true);
15611564
}
15621565
}
15631566
}

pkg/nnbd_migration/lib/src/edge_origin.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,19 @@ class TypedefReferenceOrigin extends EdgeOrigin {
421421
EdgeOriginKind get kind => EdgeOriginKind.typedefReference;
422422
}
423423

424+
/// Edge origin resulting from the instantiation of a type parameter, which
425+
/// affects the nullability of that type parameter's bound.
426+
class TypeParameterInstantiationOrigin extends EdgeOrigin {
427+
TypeParameterInstantiationOrigin(Source source, TypeAnnotation node)
428+
: super(source, node);
429+
430+
@override
431+
EdgeOriginKind get kind => EdgeOriginKind.typeParameterInstantiation;
432+
433+
@override
434+
TypeAnnotation get node => super.node as TypeAnnotation;
435+
}
436+
424437
/// Edge origin resulting from the read of a variable that has not been
425438
/// definitely assigned a value.
426439
class UninitializedReadOrigin extends EdgeOrigin {

0 commit comments

Comments
 (0)