@@ -19,6 +19,8 @@ import 'package:nnbd_migration/src/node_builder.dart';
1919import 'package:nnbd_migration/src/nullability_node.dart' ;
2020import 'package:nnbd_migration/src/variables.dart' ;
2121
22+ import 'edge_origin.dart' ;
23+
2224/// Visitor that builds nullability graph edges by examining code to be
2325/// migrated.
2426///
@@ -154,8 +156,9 @@ class GraphBuilder extends GeneralizingAstVisitor<DecoratedType> {
154156 if (identical (_conditionInfo? .condition, node.condition)) {
155157 if (! _inConditionalControlFlow &&
156158 _conditionInfo.trueDemonstratesNonNullIntent != null ) {
157- _conditionInfo.trueDemonstratesNonNullIntent
158- ? .recordNonNullIntent (_guards, _graph);
159+ _graph.connect (_conditionInfo.trueDemonstratesNonNullIntent,
160+ _graph.never, NonNullAssertionOrigin (_source, node.offset),
161+ hard: true );
159162 }
160163 }
161164 node.message? .accept (this );
@@ -271,9 +274,11 @@ class GraphBuilder extends GeneralizingAstVisitor<DecoratedType> {
271274 // Nothing to do; the implicit default value of `null` will never be
272275 // reached.
273276 } else {
274- NullabilityNode .recordAssignment (_graph.always,
275- getOrComputeElementType (node.declaredElement).node, _guards, _graph,
276- hard: false );
277+ _graph.connect (
278+ _graph.always,
279+ getOrComputeElementType (node.declaredElement).node,
280+ OptionalFormalParameterOrigin (_source, node.offset),
281+ guards: _guards);
277282 }
278283 } else {
279284 _handleAssignment (
@@ -607,11 +612,13 @@ $stackTrace''');
607612 throw new StateError ('No type annotation for type name '
608613 '${typeName .toSource ()}, offset=${typeName .offset }' );
609614 }
615+ var origin = InstantiateToBoundsOrigin (_source, typeName.offset);
610616 for (int i = 0 ; i < instantiatedType.typeArguments.length; i++ ) {
611617 _unionDecoratedTypes (
612618 instantiatedType.typeArguments[i],
613619 _variables.decoratedElementType (element.typeParameters[i],
614- create: true ));
620+ create: true ),
621+ origin);
615622 }
616623 } else {
617624 for (int i = 0 ; i < typeArguments.length; i++ ) {
@@ -648,9 +655,8 @@ $stackTrace''');
648655 void _checkAssignment (DecoratedType destinationType, DecoratedType sourceType,
649656 ExpressionChecks expressionChecks,
650657 {@required bool hard}) {
651- NullabilityNode .recordAssignment (
652- sourceType.node, destinationType.node, _guards, _graph,
653- hard: hard);
658+ _graph.connect (sourceType.node, destinationType.node, expressionChecks,
659+ guards: _guards, hard: hard);
654660 // TODO(paulberry): generalize this.
655661 if ((_isSimple (sourceType) || destinationType.type.isObject) &&
656662 _isSimple (destinationType)) {
@@ -732,7 +738,8 @@ $stackTrace''');
732738 // Any parameters not supplied must be optional.
733739 for (var entry in calleeType.namedParameters.entries) {
734740 if (suppliedNamedParameters.contains (entry.key)) continue ;
735- entry.value.node.recordNamedParameterNotSupplied (_guards, _graph);
741+ entry.value.node.recordNamedParameterNotSupplied (_guards, _graph,
742+ NamedParameterNotSuppliedOrigin (_source, argumentList.offset));
736743 }
737744 }
738745
@@ -812,8 +819,9 @@ $stackTrace''');
812819 return false ;
813820 }
814821
815- void _unionDecoratedTypes (DecoratedType x, DecoratedType y) {
816- _graph.union (x.node, y.node);
822+ void _unionDecoratedTypes (
823+ DecoratedType x, DecoratedType y, EdgeOrigin origin) {
824+ _graph.union (x.node, y.node, origin);
817825 if (x.typeArguments.isNotEmpty ||
818826 y.typeArguments.isNotEmpty ||
819827 x.returnType != null ||
0 commit comments