File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -330,7 +330,10 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
330330 _flowAnalysis.ifNullExpression_rightBegin ();
331331 try {
332332 _guards.add (leftType.node);
333- var rightType = node.rightOperand.accept (this );
333+ DecoratedType rightType;
334+ _postDominatedLocals.doScoped (action: () {
335+ rightType = node.rightOperand.accept (this );
336+ });
334337 var ifNullNode = NullabilityNode .forIfNotNull ();
335338 expressionType = DecoratedType (node.staticType, ifNullNode);
336339 _connect (rightType.node, expressionType.node,
Original file line number Diff line number Diff line change @@ -2982,6 +2982,22 @@ void test() {
29822982 assertEdge (always, decoratedTypeAnnotation ('int i' ).node, hard: false );
29832983 }
29842984
2985+ test_postDominators_questionQuestionOperator () async {
2986+ await analyze ('''
2987+ class C {
2988+ Object m() => null;
2989+ }
2990+ Object test(C x, C y) => x.m() ?? y.m();
2991+ ''' );
2992+ // There is a hard edge from x to `never` because `x.m()` is unconditionally
2993+ // reachable from the top of `test`.
2994+ assertEdge (decoratedTypeAnnotation ('C x' ).node, never, hard: true );
2995+ // However, the edge from y to `never` is soft because `y.m()` is only
2996+ // executed if `x.m()` returned `null`.
2997+ assertEdge (decoratedTypeAnnotation ('C y' ).node, never,
2998+ hard: false , guards: [decoratedTypeAnnotation ('Object m' ).node]);
2999+ }
3000+
29853001 test_postDominators_reassign () async {
29863002 await analyze ('''
29873003void test(bool b, int i1, int i2) {
You can’t perform that action at this time.
0 commit comments