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

Unified Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 1342213003: Add optional message to assert in Dart2js - continued (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add --assert-message flag Created 5 years, 3 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 | « pkg/compiler/lib/src/parser/parser.dart ('k') | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/members.dart
diff --git a/pkg/compiler/lib/src/resolution/members.dart b/pkg/compiler/lib/src/resolution/members.dart
index b05dd626b8591e07b7a7a4ed547209e34dfc206a..168013c9884591f33439ee3cc0669d9d2d2befd1 100644
--- a/pkg/compiler/lib/src/resolution/members.dart
+++ b/pkg/compiler/lib/src/resolution/members.dart
@@ -501,6 +501,20 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
}
}
+ ResolutionResult visitAssert(Assert node) {
+ if (!compiler.enableAssertMessage) {
+ if (node.hasMessage) {
+ compiler.reportError(node, MessageKind.EXPERIMENTAL_ASSERT_MESSAGE);
+ }
+ }
+ // TODO(sra): We could completely ignore the assert in production mode if we
+ // didn't need it to be resolved for type checking.
+ registry.registerAssert(node.hasMessage);
+ visit(node.condition);
+ visit(node.message);
+ return const NoneResult();
+ }
+
ResolutionResult visitCascade(Cascade node) {
visit(node.expression);
return const NoneResult();
@@ -1528,34 +1542,6 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
return const NoneResult();
}
- /// Handle a, possibly invalid, assertion, like `assert(cond)` or `assert()`.
- ResolutionResult handleAssert(Send node) {
- assert(invariant(node, node.isCall,
- message: "Unexpected assert: $node"));
- // If this send is of the form "assert(expr);", then
- // this is an assertion.
-
- CallStructure callStructure =
- resolveArguments(node.argumentsNode).callStructure;
- SendStructure sendStructure = const AssertStructure();
- if (callStructure.argumentCount != 1) {
- compiler.reportError(
- node.selector,
- MessageKind.WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT,
- {'argumentCount': callStructure.argumentCount});
- sendStructure = const InvalidAssertStructure();
- } else if (callStructure.namedArgumentCount != 0) {
- compiler.reportError(
- node.selector,
- MessageKind.ASSERT_IS_GIVEN_NAMED_ARGUMENTS,
- {'argumentCount': callStructure.namedArgumentCount});
- sendStructure = const InvalidAssertStructure();
- }
- registry.registerAssert(node);
- registry.registerSendStructure(node, sendStructure);
- return const AssertResult();
- }
-
/// Handle access of a property of [name] on `this`, like `this.name` and
/// `this.name()`, or `name` and `name()` in instance context.
ResolutionResult handleThisPropertyAccess(Send node, Name name) {
@@ -3033,10 +3019,7 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
return handleExpressionInvoke(node);
}
String text = selector.source;
- if (text == 'assert') {
- // `assert()`.
- return handleAssert(node);
- } else if (text == 'this') {
+ if (text == 'this') {
// `this()`.
return handleThisAccess(node);
}
« no previous file with comments | « pkg/compiler/lib/src/parser/parser.dart ('k') | pkg/compiler/lib/src/resolution/registry.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698