Index: pkg/compiler/lib/src/typechecker.dart |
diff --git a/pkg/compiler/lib/src/typechecker.dart b/pkg/compiler/lib/src/typechecker.dart |
index 323c19db73bf53503e3be49d82ec0bf79c3e23b1..cb64d9b989bf2a423348ec1ef0c2cf4df6778326 100644 |
--- a/pkg/compiler/lib/src/typechecker.dart |
+++ b/pkg/compiler/lib/src/typechecker.dart |
@@ -146,6 +146,25 @@ class DynamicAccess implements ElementAccess { |
String toString() => 'DynamicAccess'; |
} |
+/// An access of the `assert` method. |
+class AssertAccess implements ElementAccess { |
+ const AssertAccess(); |
+ |
+ Element get element => null; |
+ |
+ String get name => 'assert'; |
+ |
+ DartType computeType(Compiler compiler) { |
+ return new FunctionType.synthesized( |
+ const VoidType(), |
+ <DartType>[const DynamicType()]); |
+ } |
+ |
+ bool isCallable(Compiler compiler) => true; |
+ |
+ String toString() => 'AssertAccess'; |
+} |
+ |
/** |
* An access of a resolved top-level or static property or function, or an |
* access of a resolved element through [:this:]. |
@@ -595,12 +614,6 @@ class TypeCheckerVisitor extends Visitor<DartType> { |
return type; |
} |
- DartType visitAssert(Assert node) { |
- analyze(node.condition); |
- if (node.hasMessage) analyze(node.message); |
- return const StatementType(); |
- } |
- |
DartType visitBlock(Block node) { |
return analyze(node.statements); |
} |
@@ -1152,6 +1165,10 @@ class TypeCheckerVisitor extends Visitor<DartType> { |
} |
DartType visitSend(Send node) { |
+ if (elements.isAssert(node)) { |
+ return analyzeInvocation(node, const AssertAccess()); |
+ } |
+ |
Element element = elements[node]; |
if (element != null && element.isConstructor) { |