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

Unified Diff: pkg/analyzer/lib/src/generated/error_verifier.dart

Issue 2492633002: Create AST structure for asserts in constructor initializers (Closed)
Patch Set: 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 | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/error_verifier.dart
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 2a71ac62d48573331c0f79db9bd36cb9fd2d3459..30a50cc3a9ffbc687a631c0ef2fb0959ad901305 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -347,6 +347,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
@override
+ Object visitAssertInitializer(AssertInitializer node) {
+ _checkForNonBoolExpression(node);
+ _checkAssertMessage(node);
+ return super.visitAssertInitializer(node);
+ }
+
+ @override
Object visitAssertStatement(AssertStatement node) {
_checkForNonBoolExpression(node);
_checkAssertMessage(node);
@@ -1295,11 +1302,11 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
/**
- * If the given assert [statement] specifies a message, verify that support
+ * If the given [assertion] specifies a message, verify that support
* for assertions with messages is enabled.
*/
- void _checkAssertMessage(AssertStatement statement) {
- Expression expression = statement.message;
+ void _checkAssertMessage(Assertion assertion) {
+ Expression expression = assertion.message;
if (expression != null && !enableAssertMessage) {
_errorReporter.reportErrorForNode(
CompileTimeErrorCode.EXTRA_ARGUMENT_TO_ASSERT, expression);
@@ -5163,13 +5170,13 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
/**
- * Verify that the given assert [statement] has either a 'bool' or
- * '() -> bool' input.
+ * Verify that the given [assertion] has either a 'bool' or '() -> bool'
+ * condition.
*
* See [StaticTypeWarningCode.NON_BOOL_EXPRESSION].
*/
- void _checkForNonBoolExpression(AssertStatement statement) {
- Expression expression = statement.condition;
+ void _checkForNonBoolExpression(Assertion assertion) {
+ Expression expression = assertion.condition;
DartType type = getStaticType(expression);
if (type is InterfaceType) {
if (!_typeSystem.isAssignableTo(type, _boolType)) {
« no previous file with comments | « pkg/analyzer/lib/src/dart/ast/utilities.dart ('k') | pkg/analyzer/lib/src/generated/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698