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

Unified Diff: sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart

Issue 182373002: Fix bad type-inferrence for logical expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use lhs of &&. Created 6 years, 10 months 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/compiler/dart2js/simple_inferrer_and_or_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart
diff --git a/sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart b/sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart
index 86662f7dcb798a5ba86b62cd839375bd13f04499..94d80bbefb40412dff112ce33b0d676bdeb285f7 100644
--- a/sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart
+++ b/sdk/lib/_internal/compiler/implementation/inferrer/inferrer_visitor.dart
@@ -842,14 +842,19 @@ abstract class InferrerVisitor
} else if ("&&" == op.source) {
conditionIsSimple = false;
bool oldAccumulateIsChecks = accumulateIsChecks;
- accumulateIsChecks = true;
- if (isChecks == null) isChecks = <Send>[];
+ List<Send> oldIsChecks = isChecks;
+ if (!accumulateIsChecks) {
+ accumulateIsChecks = true;
+ isChecks = <Send>[];
+ }
visit(node.receiver);
- accumulateIsChecks = oldAccumulateIsChecks;
- if (!accumulateIsChecks) isChecks = null;
LocalsHandler<T> saved = locals;
locals = new LocalsHandler<T>.from(locals, node);
updateIsChecks(isChecks, usePositive: true);
+ if (!oldAccumulateIsChecks) {
+ accumulateIsChecks = false;
+ isChecks = oldIsChecks;
+ }
visit(node.arguments.head);
saved.mergeDiamondFlow(locals, null);
locals = saved;
@@ -857,10 +862,10 @@ abstract class InferrerVisitor
} else if ("||" == op.source) {
conditionIsSimple = false;
List<Send> tests = <Send>[];
- handleCondition(node.receiver, tests);
+ bool isSimple = handleCondition(node.receiver, tests);
LocalsHandler<T> saved = locals;
locals = new LocalsHandler<T>.from(locals, node);
- updateIsChecks(tests, usePositive: false);
+ if (isSimple) updateIsChecks(tests, usePositive: false);
bool oldAccumulateIsChecks = accumulateIsChecks;
accumulateIsChecks = false;
visit(node.arguments.head);
« no previous file with comments | « no previous file | tests/compiler/dart2js/simple_inferrer_and_or_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698