Migration: stop using "never" for the result type of an "is" check Change-Id: I02b80817e46e0544b38dceb7b8a3f92aebede1d3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125229 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/nnbd_migration/lib/instrumentation.dart b/pkg/nnbd_migration/lib/instrumentation.dart index 31e8186..cdf2a95 100644 --- a/pkg/nnbd_migration/lib/instrumentation.dart +++ b/pkg/nnbd_migration/lib/instrumentation.dart
@@ -142,6 +142,7 @@ instantiateToBounds, isCheckComponentType, isCheckMainType, + isCheckResultType, literal, namedParameterNotSupplied, nonNullAssertion,
diff --git a/pkg/nnbd_migration/lib/src/edge_builder.dart b/pkg/nnbd_migration/lib/src/edge_builder.dart index 055c273..0bd49be 100644 --- a/pkg/nnbd_migration/lib/src/edge_builder.dart +++ b/pkg/nnbd_migration/lib/src/edge_builder.dart
@@ -871,7 +871,10 @@ expression.accept(this); _flowAnalysis.isExpression_end( node, expression, node.notOperator != null, decoratedType); - return DecoratedType(node.staticType, _graph.never); + var nullabilityNode = NullabilityNode.forInferredType(); + _graph.makeNonNullable( + nullabilityNode, IsCheckResultTypeOrigin(source, node)); + return DecoratedType(node.staticType, nullabilityNode); } @override
diff --git a/pkg/nnbd_migration/lib/src/edge_origin.dart b/pkg/nnbd_migration/lib/src/edge_origin.dart index 03cab74..805c7b5 100644 --- a/pkg/nnbd_migration/lib/src/edge_origin.dart +++ b/pkg/nnbd_migration/lib/src/edge_origin.dart
@@ -251,6 +251,14 @@ EdgeOriginKind get kind => EdgeOriginKind.isCheckMainType; } +/// Edge origin for the nullability of the result of an 'is' check. +class IsCheckResultTypeOrigin extends EdgeOrigin { + IsCheckResultTypeOrigin(Source source, AstNode node) : super(source, node); + + @override + EdgeOriginKind get kind => EdgeOriginKind.isCheckResultType; +} + /// An edge origin used for edges that originated because a literal expression /// has a known nullability. class LiteralOrigin extends EdgeOrigin {