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

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 9421002: Issue 1714. Report warning if assert argument is not 'bool' or '() -> bool'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 10 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: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index 50b57754640065acf336184be7f882206cb1b31e..1075cef3e5636afd8b2d7cf398c7612dddc6fb54 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -758,14 +758,15 @@ public class TypeAnalyzer implements DartCompilationPhase {
case FUNCTION:
FunctionType ftype = (FunctionType) condition;
Type returnType = ftype.getReturnType();
- if (returnType.getKind().equals(TypeKind.VOID)) {
- typeError(conditionNode, TypeErrorCode.VOID);
+ if (!types.isAssignable(boolType, returnType) || !ftype.getParameterTypes().isEmpty()) {
+ typeError(node, TypeErrorCode.ASSERT_BOOL);
}
- checkAssignable(conditionNode, boolType, returnType);
break;
default:
- checkAssignable(conditionNode, boolType, condition);
+ if (!types.isAssignable(boolType, condition)) {
+ typeError(node, TypeErrorCode.ASSERT_BOOL);
+ }
break;
}
return voidType;

Powered by Google App Engine
This is Rietveld 408576698