| Index: runtime/vm/parser.cc
|
| diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
|
| index e75d86d82291669b6fd6f85271c8a1f9288e38b4..d4544829e36a596bd721f1dcb8e916d829bc9165 100644
|
| --- a/runtime/vm/parser.cc
|
| +++ b/runtime/vm/parser.cc
|
| @@ -9249,13 +9249,24 @@ AstNode* Parser::ParseAssertStatement(bool is_const) {
|
| ExpectToken(Token::kRPAREN);
|
|
|
| if (!is_const) {
|
| - // Check for assertion condition being a function if not const.
|
| - ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos);
|
| - arguments->Add(condition);
|
| - condition = MakeStaticCall(
|
| - Symbols::AssertionError(),
|
| - Library::PrivateCoreLibName(Symbols::EvaluateAssertion()), arguments);
|
| + if (condition->IsClosureNode()) {
|
| + // We always have to invoke a closure node.
|
| + InstanceCallNode* invoke_condition =
|
| + new (Z) InstanceCallNode(condition_pos, condition, Symbols::Call(),
|
| + new (Z) ArgumentListNode(condition_pos));
|
| + condition = invoke_condition;
|
| + } else if (condition->IsComparisonNode() || condition->IsUnaryOpNode()) {
|
| + // Cannot be a function, skip type test and invocation.
|
| + } else {
|
| + // Check for assertion condition being a function if not const.
|
| + ArgumentListNode* arguments = new (Z) ArgumentListNode(condition_pos);
|
| + arguments->Add(condition);
|
| + condition = MakeStaticCall(
|
| + Symbols::AssertionError(),
|
| + Library::PrivateCoreLibName(Symbols::EvaluateAssertion()), arguments);
|
| + }
|
| }
|
| +
|
| AstNode* not_condition =
|
| new (Z) UnaryOpNode(condition_pos, Token::kNOT, condition);
|
|
|
|
|