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

Unified Diff: pkg/compiler/lib/src/inferrer/inferrer_visitor.dart

Issue 2528043003: Handle assert with message in type inference (Closed)
Patch Set: Add more testing. Created 4 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/compiler/dart2js/assert_message_throw_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
diff --git a/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart b/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
index d011dc0d1977cf619e93499e794b3dd9fa01cbf7..7b913b0d2590c9217c66ff6ef6951a4367393d8a 100644
--- a/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
+++ b/pkg/compiler/lib/src/inferrer/inferrer_visitor.dart
@@ -763,9 +763,22 @@ abstract class InferrerVisitor<T, E extends MinimalInferrerEngine<T>>
T visitAssert(Assert node) {
// Avoid pollution from assert statement unless enabled.
- if (compiler.options.enableUserAssertions) {
- super.visitAssert(node);
+ if (!compiler.options.enableUserAssertions) {
+ return null;
}
+ List<Send> tests = <Send>[];
+ bool simpleCondition = handleCondition(node.condition, tests);
+ LocalsHandler<T> saved = locals;
+ locals = new LocalsHandler<T>.from(locals, node);
+ updateIsChecks(tests, usePositive: true);
+
+ LocalsHandler<T> thenLocals = locals;
+ locals = new LocalsHandler<T>.from(saved, node);
+ if (simpleCondition) updateIsChecks(tests, usePositive: false);
+ visit(node.message);
+ locals.seenReturnOrThrow = true;
+ saved.mergeDiamondFlow(thenLocals, locals);
+ locals = saved;
return null;
}
« no previous file with comments | « no previous file | tests/compiler/dart2js/assert_message_throw_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698