mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:50:11 +00:00
Add support for &&, || and ?? operators
Change-Id: Ibb6269b349b3d0ffcf1068442c70ef46a6f521eb Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106948 Reviewed-by: Dan Rubel <danrubel@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
77668f4e58
commit
735eb21529
|
@ -214,6 +214,12 @@ class GraphBuilder extends GeneralizingAstVisitor<DecoratedType> {
|
|||
: conditionInfo.not(node);
|
||||
}
|
||||
return _nonNullableBoolType;
|
||||
} else if (operatorType == TokenType.AMPERSAND_AMPERSAND ||
|
||||
operatorType == TokenType.BAR_BAR ||
|
||||
operatorType == TokenType.QUESTION_QUESTION) {
|
||||
_handleAssignment(_notNullType, node.leftOperand);
|
||||
node.rightOperand.accept(this);
|
||||
return _nonNullableBoolType;
|
||||
} else if (operatorType.isUserDefinableOperator) {
|
||||
_handleAssignment(_notNullType, node.leftOperand);
|
||||
var callee = node.staticElement;
|
||||
|
@ -228,6 +234,8 @@ class GraphBuilder extends GeneralizingAstVisitor<DecoratedType> {
|
|||
return calleeType.returnType;
|
||||
} else {
|
||||
// TODO(paulberry)
|
||||
node.leftOperand.accept(this);
|
||||
node.rightOperand.accept(this);
|
||||
_unimplemented(
|
||||
node, 'Binary expression with operator ${node.operator.lexeme}');
|
||||
}
|
||||
|
|
|
@ -294,6 +294,14 @@ int f(int i, int j) => i & j;
|
|||
assertNoUpstreamNullability(decoratedTypeAnnotation('int f').node);
|
||||
}
|
||||
|
||||
test_binaryExpression_ampersandAmpersand() async {
|
||||
await analyze('''
|
||||
bool f(bool i, bool j) => i && j;
|
||||
''');
|
||||
|
||||
assertNoUpstreamNullability(decoratedTypeAnnotation('bool i').node);
|
||||
}
|
||||
|
||||
test_binaryExpression_bar_result_not_null() async {
|
||||
await analyze('''
|
||||
int f(int i, int j) => i | j;
|
||||
|
@ -302,6 +310,14 @@ int f(int i, int j) => i | j;
|
|||
assertNoUpstreamNullability(decoratedTypeAnnotation('int f').node);
|
||||
}
|
||||
|
||||
test_binaryExpression_barBar() async {
|
||||
await analyze('''
|
||||
bool f(bool i, bool j) => i || j;
|
||||
''');
|
||||
|
||||
assertNoUpstreamNullability(decoratedTypeAnnotation('bool i').node);
|
||||
}
|
||||
|
||||
test_binaryExpression_caret_result_not_null() async {
|
||||
await analyze('''
|
||||
int f(int i, int j) => i ^ j;
|
||||
|
@ -458,6 +474,14 @@ Int f(Int i, Int j) => i + j/*check*/;
|
|||
hard: true));
|
||||
}
|
||||
|
||||
test_binaryExpression_questionQuestion() async {
|
||||
await analyze('''
|
||||
int f(int i, int j) => i ?? j;
|
||||
''');
|
||||
|
||||
assertNoUpstreamNullability(decoratedTypeAnnotation('int i').node);
|
||||
}
|
||||
|
||||
test_binaryExpression_slash_result_not_null() async {
|
||||
await analyze('''
|
||||
double f(int i, int j) => i / j;
|
||||
|
|
Loading…
Reference in a new issue