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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 11113009: Land Alexander's change that turns assert into a keyword. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 | « lib/compiler/implementation/lib/js_helper.dart ('k') | lib/compiler/implementation/scanner/keyword.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index 17c9d561d62cf4452581fcef3a09ded474d7932c..f9ca5f636c8b5d25ef1532ce148f4abd3d36cb69 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -1412,33 +1412,22 @@ class ResolverVisitor extends CommonResolverVisitor<Element> {
return (str === '&&' || str == '||' || str == '!');
}
- /**
- * Check the lexical scope chain for a declaration with the name "assert".
- *
- * This is used to detect whether "assert(x)" is actually an assertion or
- * just a call expression.
- * It does not check fields inherited from a superclass.
- */
- bool isAssertInLexicalScope() {
- return scope.lexicalLookup(const SourceString("assert")) !== null;
- }
-
- /** Check if [node] is the expression of the current expression statement. */
- bool isExpressionStatementExpression(Node node) {
- return currentExpressionStatement !== null &&
- currentExpressionStatement.expression === node;
- }
-
Element resolveSend(Send node) {
Selector selector = resolveSelector(node);
if (node.receiver === null) {
- // If this send is the expression of an expression statement, and is on
- // the form "assert(expr);", and there is no declaration with name
- // "assert" in the lexical scope, then this is actually an assertion.
- if (isExpressionStatementExpression(node) &&
- selector.isAssertSyntax() &&
- !isAssertInLexicalScope()) {
+ // If this send is of the form "assert(expr);", then
+ // this is an assertion.
+ if (selector.isAssert()) {
+ if (selector.argumentCount != 1) {
+ error(node.selector,
+ MessageKind.WRONG_NUMBER_OF_ARGUMENTS_FOR_ASSERT,
+ [selector.argumentCount]);
+ } else if (selector.namedArgumentCount != 0) {
+ error(node.selector,
+ MessageKind.ASSERT_IS_GIVEN_NAMED_ARGUMENTS,
+ [selector.namedArgumentCount]);
+ }
return compiler.assertMethod;
}
return node.selector.accept(this);
« no previous file with comments | « lib/compiler/implementation/lib/js_helper.dart ('k') | lib/compiler/implementation/scanner/keyword.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698