Fix exception in migration of ?? operator when the right hand side is a generic type

Change-Id: Ie372522f9493e2ccea8284f8583b0f43153adbbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123884
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Brian Wilkerson 2019-11-01 21:52:48 +00:00 committed by commit-bot@chromium.org
parent ed1910006c
commit 9bffff6dfc
2 changed files with 12 additions and 1 deletions

View file

@ -378,7 +378,9 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
rightType = rightOperand.accept(this);
});
var ifNullNode = NullabilityNode.forIfNotNull();
expressionType = DecoratedType(node.staticType, ifNullNode);
expressionType = _decorateUpperOrLowerBound(
node, node.staticType, leftType, rightType, true,
node: ifNullNode);
_connect(
rightType.node, expressionType.node, IfNullOrigin(source, node));
} finally {

View file

@ -1201,6 +1201,15 @@ int f(int i, int j) => i ?? j;
assertEdge(right, expression, guards: [left], hard: false);
}
test_binaryExpression_questionQuestion_genericReturnType() async {
await analyze('''
class C<E> {
C<E> operator +(C<E> c) => this;
}
C<int> f(C<int> i, C<int> j) => i ?? j;
''');
}
test_binaryExpression_right_dynamic() async {
await analyze('''
class C {