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

Unified Diff: pkg/compiler/lib/src/typechecker.dart

Issue 1346093003: Revert "Add optional message to assert in Dart2js - continued" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 | « pkg/compiler/lib/src/tree/unparser.dart ('k') | pkg/compiler/lib/src/universe/selector.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « pkg/compiler/lib/src/tree/unparser.dart ('k') | pkg/compiler/lib/src/universe/selector.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698