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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java

Issue 280873002: Fix for issue 16423 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Missed issue number Created 6 years, 7 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
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
index 0e259ec21a116001a22f369d75d2f289314cf104..a978b4c0fbeb1871d64ea39d5a3632ab20e19259 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
@@ -476,7 +476,23 @@ public class ErrorVerifier extends RecursiveAstVisitor<Void> {
@Override
public Void visitBinaryExpression(BinaryExpression node) {
- checkForArgumentTypeNotAssignableForArgument(node.getRightOperand());
+ Token operator = node.getOperator();
+ TokenType type = operator.getType();
+ if (type == TokenType.AMPERSAND_AMPERSAND || type == TokenType.BAR_BAR) {
+ String lexeme = operator.getLexeme();
+ checkForAssignability(
+ node.getLeftOperand(),
+ boolType,
+ StaticTypeWarningCode.NON_BOOL_OPERAND,
+ lexeme);
+ checkForAssignability(
+ node.getRightOperand(),
+ boolType,
+ StaticTypeWarningCode.NON_BOOL_OPERAND,
+ lexeme);
+ } else {
+ checkForArgumentTypeNotAssignableForArgument(node.getRightOperand());
+ }
return super.visitBinaryExpression(node);
}
@@ -2055,6 +2071,32 @@ public class ErrorVerifier extends RecursiveAstVisitor<Void> {
}
/**
+ * Check that the static type of the given expression is assignable to the given type. If it
+ * isn't, report an error with the given error code.
+ *
+ * @param expression the expression being tested
+ * @param type the type that the expression must be assignable to
+ * @param errorCode the error code to be reported
+ * @param arguments the arguments to pass in when creating the error
+ * @return {@code true} if an error was reported
+ */
+ private boolean checkForAssignability(Expression expression, InterfaceType type,
+ ErrorCode errorCode, Object... arguments) {
+ if (expression == null) {
+ return false;
+ }
+ Type expressionType = expression.getStaticType();
+ if (expressionType == null) {
+ return false;
+ }
+ if (expressionType.isAssignableTo(type)) {
+ return false;
+ }
+ errorReporter.reportErrorForNode(errorCode, expression, arguments);
+ return true;
+ }
+
+ /**
* This verifies that the passed expression is not final.
*
* @param node the expression to evaluate

Powered by Google App Engine
This is Rietveld 408576698