@@ -389,16 +389,7 @@ abstract class FlowAnalysis<Node, Statement extends Node, Expression, Variable,
389389 void doStatement_end (Expression condition);
390390
391391 /// Call this method just after visiting a binary `==` or `!=` expression.
392- ///
393- /// Return value indicates whether flow analysis believes that a successful
394- /// equality check is reachable. If `false` is returned, the client should
395- /// ensure that the `==` test behaves like `x == y && throw ...` .
396- ///
397- /// Note that if `notEqual` is `true` , then the return value describes the
398- /// behavior of the underlying `==` test. So if `notEqual` is `true` and
399- /// `false` is returned, the client should ensure that the `!=` test behaves
400- /// like `!(x == y && throw ...)` .
401- bool equalityOp_end (Expression wholeExpression, Expression rightOperand,
392+ void equalityOp_end (Expression wholeExpression, Expression rightOperand,
402393 Type rightOperandType,
403394 {bool notEqual = false });
404395
@@ -531,12 +522,7 @@ abstract class FlowAnalysis<Node, Statement extends Node, Expression, Variable,
531522
532523 /// Call this method after visiting the LHS of an if-null expression ("??")
533524 /// or if-null assignment ("??=").
534- ///
535- /// Return value indicates whether flow analysis believes that the right hand
536- /// side is reachable. If `false` is returned, the client should ensure that
537- /// `x ?? y` behaves like `x ?? throw ...` (or, correspondingly, that
538- /// `x ??= y` behaves like `x ??= throw ...` ).
539- bool ifNullExpression_rightBegin (
525+ void ifNullExpression_rightBegin (
540526 Expression leftHandSide, Type leftHandSideType);
541527
542528 /// Call this method before visiting the condition part of an if statement.
@@ -578,16 +564,7 @@ abstract class FlowAnalysis<Node, Statement extends Node, Expression, Variable,
578564 /// be the expression to which the "is" check was applied. [isNot] should be
579565 /// a boolean indicating whether this is an "is" or an "is!" expression.
580566 /// [type] should be the type being checked.
581- ///
582- /// Return value indicates whether flow analysis believes that a failure of
583- /// the `is` test is reachable. If `false` is returned, the client should
584- /// ensure that the `is` test behaves like `x is T || throw ...` .
585- ///
586- /// Note that if `isNot` is `true` , then the return value describes the
587- /// behavior of the underlying `if` test. So if `isNot` is `true` and `false`
588- /// is returned, the client should ensure that the `is!` test behaves like
589- /// `!(x is T || throw ...)` .
590- bool isExpression_end (
567+ void isExpression_end (
591568 Expression isExpression, Expression subExpression, bool isNot, Type type);
592569
593570 /// Return whether the [variable] is definitely unassigned in the current
@@ -653,13 +630,7 @@ abstract class FlowAnalysis<Node, Statement extends Node, Expression, Variable,
653630 /// code being analyzed is `x?.y?.z(x)` , [nullAwareAccess_rightBegin] should
654631 /// be called once upon reaching each `?.` , but [nullAwareAccess_end] should
655632 /// not be called until after processing the method call to `z(x)` .
656- ///
657- /// Return value indicates whether flow analysis believes that a null target
658- /// is reachable. If `false` is returned, the client should ensure that
659- /// `x?.y` behaves like `x!.y` . (Note that this is necessary even if `y`
660- /// exists on `Object` --see
661- /// https://github.com/dart-lang/language/issues/1143#issuecomment-682096575.)
662- bool nullAwareAccess_rightBegin (Expression target, Type targetType);
633+ void nullAwareAccess_rightBegin (Expression target, Type targetType);
663634
664635 /// Call this method when encountering an expression that is a `null` literal.
665636 void nullLiteral (Expression expression);
@@ -923,17 +894,15 @@ class FlowAnalysisDebug<Node, Statement extends Node, Expression, Variable,
923894 }
924895
925896 @override
926- bool equalityOp_end (Expression wholeExpression, Expression rightOperand,
897+ void equalityOp_end (Expression wholeExpression, Expression rightOperand,
927898 Type rightOperandType,
928899 {bool notEqual = false }) {
929- return _wrap (
900+ _wrap (
930901 'equalityOp_end($wholeExpression , $rightOperand , $rightOperandType , '
931902 'notEqual: $notEqual )' ,
932903 () => _wrapped.equalityOp_end (
933904 wholeExpression, rightOperand, rightOperandType,
934- notEqual: notEqual),
935- isQuery: true ,
936- isPure: false );
905+ notEqual: notEqual));
937906 }
938907
939908 @override
@@ -1022,14 +991,12 @@ class FlowAnalysisDebug<Node, Statement extends Node, Expression, Variable,
1022991 }
1023992
1024993 @override
1025- bool ifNullExpression_rightBegin (
994+ void ifNullExpression_rightBegin (
1026995 Expression leftHandSide, Type leftHandSideType) {
1027- return _wrap (
996+ _wrap (
1028997 'ifNullExpression_rightBegin($leftHandSide , $leftHandSideType )' ,
1029998 () => _wrapped.ifNullExpression_rightBegin (
1030- leftHandSide, leftHandSideType),
1031- isQuery: true ,
1032- isPure: false );
999+ leftHandSide, leftHandSideType));
10331000 }
10341001
10351002 @override
@@ -1062,14 +1029,12 @@ class FlowAnalysisDebug<Node, Statement extends Node, Expression, Variable,
10621029 }
10631030
10641031 @override
1065- bool isExpression_end (Expression isExpression, Expression subExpression,
1032+ void isExpression_end (Expression isExpression, Expression subExpression,
10661033 bool isNot, Type type) {
1067- return _wrap (
1034+ _wrap (
10681035 'isExpression_end($isExpression , $subExpression , $isNot , $type )' ,
1069- () =>
1070- _wrapped.isExpression_end (isExpression, subExpression, isNot, type),
1071- isQuery: true ,
1072- isPure: false );
1036+ () => _wrapped.isExpression_end (
1037+ isExpression, subExpression, isNot, type));
10731038 }
10741039
10751040 @override
@@ -1141,10 +1106,9 @@ class FlowAnalysisDebug<Node, Statement extends Node, Expression, Variable,
11411106 }
11421107
11431108 @override
1144- bool nullAwareAccess_rightBegin (Expression target, Type targetType) {
1145- return _wrap ('nullAwareAccess_rightBegin($target , $targetType )' ,
1146- () => _wrapped.nullAwareAccess_rightBegin (target, targetType),
1147- isQuery: true , isPure: false );
1109+ void nullAwareAccess_rightBegin (Expression target, Type targetType) {
1110+ _wrap ('nullAwareAccess_rightBegin($target , $targetType )' ,
1111+ () => _wrapped.nullAwareAccess_rightBegin (target, targetType));
11481112 }
11491113
11501114 @override
@@ -2816,23 +2780,21 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
28162780 }
28172781
28182782 @override
2819- bool equalityOp_end (Expression wholeExpression, Expression rightOperand,
2783+ void equalityOp_end (Expression wholeExpression, Expression rightOperand,
28202784 Type rightOperandType,
28212785 {bool notEqual = false }) {
28222786 _EqualityOpContext <Variable , Type > context =
28232787 _stack.removeLast () as _EqualityOpContext <Variable , Type >;
28242788 ExpressionInfo <Variable , Type > lhsInfo = context._conditionInfo;
28252789 Type leftOperandType = context._leftOperandType;
28262790 ExpressionInfo <Variable , Type > rhsInfo = _getExpressionInfo (rightOperand);
2827- ExpressionInfo <Variable , Type > equalityInfo;
28282791 TypeClassification leftOperandTypeClassification =
28292792 typeOperations.classifyType (leftOperandType);
28302793 TypeClassification rightOperandTypeClassification =
28312794 typeOperations.classifyType (rightOperandType);
28322795 if (leftOperandTypeClassification == TypeClassification .nullOrEquivalent &&
28332796 rightOperandTypeClassification == TypeClassification .nullOrEquivalent) {
28342797 booleanLiteral (wholeExpression, ! notEqual);
2835- return true ;
28362798 } else if ((leftOperandTypeClassification ==
28372799 TypeClassification .nullOrEquivalent &&
28382800 rightOperandTypeClassification == TypeClassification .nonNullable) ||
@@ -2843,23 +2805,21 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
28432805 // but weak mode it might produce an "equal" result. We don't want flow
28442806 // analysis behavior to depend on mode, so we conservatively assume that
28452807 // either result is possible.
2846- return true ;
28472808 } else if (lhsInfo is _NullInfo <Variable , Type > &&
28482809 rhsInfo is _VariableReadInfo <Variable , Type >) {
28492810 assert (
28502811 leftOperandTypeClassification == TypeClassification .nullOrEquivalent);
2851- equalityInfo =
2812+ ExpressionInfo < Variable , Type > equalityInfo =
28522813 _current.tryMarkNonNullable (typeOperations, rhsInfo._variable);
2814+ _storeExpressionInfo (wholeExpression,
2815+ notEqual ? equalityInfo : ExpressionInfo .invert (equalityInfo));
28532816 } else if (rhsInfo is _NullInfo <Variable , Type > &&
28542817 lhsInfo is _VariableReadInfo <Variable , Type >) {
2855- equalityInfo =
2818+ ExpressionInfo < Variable , Type > equalityInfo =
28562819 _current.tryMarkNonNullable (typeOperations, lhsInfo._variable);
2857- } else {
2858- return true ;
2820+ _storeExpressionInfo (wholeExpression,
2821+ notEqual ? equalityInfo : ExpressionInfo . invert (equalityInfo)) ;
28592822 }
2860- _storeExpressionInfo (wholeExpression,
2861- notEqual ? equalityInfo : ExpressionInfo .invert (equalityInfo));
2862- return true ;
28632823 }
28642824
28652825 @override
@@ -2998,7 +2958,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
29982958 }
29992959
30002960 @override
3001- bool ifNullExpression_rightBegin (
2961+ void ifNullExpression_rightBegin (
30022962 Expression leftHandSide, Type leftHandSideType) {
30032963 ExpressionInfo <Variable , Type > lhsInfo = _getExpressionInfo (leftHandSide);
30042964 FlowModel <Variable , Type > promoted;
@@ -3012,7 +2972,6 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
30122972 promoted = _current;
30132973 }
30142974 _stack.add (new _IfNullExpressionContext <Variable , Type >(promoted));
3015- return true ;
30162975 }
30172976
30182977 @override
@@ -3057,21 +3016,17 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
30573016 }
30583017
30593018 @override
3060- bool isExpression_end (Expression isExpression, Expression subExpression,
3019+ void isExpression_end (Expression isExpression, Expression subExpression,
30613020 bool isNot, Type type) {
30623021 ExpressionInfo <Variable , Type > subExpressionInfo =
30633022 _getExpressionInfo (subExpression);
3064- Variable variable;
30653023 if (subExpressionInfo is _VariableReadInfo <Variable , Type >) {
3066- variable = subExpressionInfo._variable;
3067- } else {
3068- return true ;
3024+ ExpressionInfo <Variable , Type > expressionInfo =
3025+ _current.tryPromoteForTypeCheck (
3026+ typeOperations, subExpressionInfo._variable, type);
3027+ _storeExpressionInfo (isExpression,
3028+ isNot ? ExpressionInfo .invert (expressionInfo) : expressionInfo);
30693029 }
3070- ExpressionInfo <Variable , Type > expressionInfo =
3071- _current.tryPromoteForTypeCheck (typeOperations, variable, type);
3072- _storeExpressionInfo (isExpression,
3073- isNot ? ExpressionInfo .invert (expressionInfo) : expressionInfo);
3074- return true ;
30753030 }
30763031
30773032 @override
@@ -3177,7 +3132,7 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
31773132 }
31783133
31793134 @override
3180- bool nullAwareAccess_rightBegin (Expression target, Type targetType) {
3135+ void nullAwareAccess_rightBegin (Expression target, Type targetType) {
31813136 assert (targetType != null );
31823137 _current = _current.split ();
31833138 _stack.add (new _NullAwareAccessContext <Variable , Type >(_current));
@@ -3189,7 +3144,6 @@ class _FlowAnalysisImpl<Node, Statement extends Node, Expression, Variable,
31893144 .ifTrue;
31903145 }
31913146 }
3192- return true ;
31933147 }
31943148
31953149 @override
0 commit comments