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

Unified Diff: frog/gen.dart

Issue 8457007: Better runtime type checks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged, and fix typo in member name Created 9 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
Index: frog/gen.dart
diff --git a/frog/gen.dart b/frog/gen.dart
index 53f512405cf37366733c28d5f6d1ddaad31ac6f8..807e2f13cda25cf2894022dd097c5aa9f664c2e0 100644
--- a/frog/gen.dart
+++ b/frog/gen.dart
@@ -107,6 +107,10 @@ class WorldGenerator {
}
}
}
+ // Type check functions for builtin JS types
+ if (type.typeCheckCode != null) {
+ writer.writeln(type.typeCheckCode);
+ }
}
}
@@ -185,8 +189,8 @@ class WorldGenerator {
}
}
- // Concrete types (like List<String>) will this already defined on their
- // prototype from the generic type (like List)
+ // Concrete types (like List<String>) will have this already defined on
+ // their prototype from the generic type (like List)
if (type is! ConcreteType) {
_maybeIsTest(type, type);
}
@@ -948,7 +952,12 @@ class MethodGenerator implements TreeVisitor {
}
visitBool(Expression node) {
- return visitTypedValue(node, world.boolType);
+ // Boolean conversions in if/while/do/for/conditions require non-null bool.
+
+ // TODO(jmesserly): why do we have this rule? It seems inconsistent with
+ // the rest of the type system, and just causes bogus asserts unless all
+ // bools are initialized to false.
+ return visitValue(node).convertToNonNullBool(this, node);
}
visitValue(Expression node) {

Powered by Google App Engine
This is Rietveld 408576698