Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Unified Diff: runtime/vm/ast.cc

Issue 49503009: boolean expressions with null are never potentially const (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.cc
===================================================================
--- runtime/vm/ast.cc (revision 29912)
+++ runtime/vm/ast.cc (working copy)
@@ -255,6 +255,17 @@
bool BinaryOpNode::IsPotentiallyConst() const {
switch (kind_) {
+ case Token::kOR:
+ case Token::kAND:
+ if (this->left()->IsLiteralNode() &&
+ this->left()->AsLiteralNode()->literal().IsNull()) {
+ return false;
+ }
+ if (this->right()->IsLiteralNode() &&
+ this->right()->AsLiteralNode()->literal().IsNull()) {
+ return false;
+ }
+ // Fall-through intentional.
case Token::kADD:
case Token::kSUB:
case Token::kMUL:
@@ -266,8 +277,6 @@
case Token::kBIT_AND:
case Token::kSHL:
case Token::kSHR:
- case Token::kOR:
- case Token::kAND:
return this->left()->IsPotentiallyConst() &&
this->right()->IsPotentiallyConst();
default:
@@ -355,6 +364,10 @@
bool UnaryOpNode::IsPotentiallyConst() const {
+ if (this->operand()->IsLiteralNode() &&
+ this->operand()->AsLiteralNode()->literal().IsNull()) {
+ return false;
+ }
return this->operand()->IsPotentiallyConst();
}
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698