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

Unified Diff: sdk/lib/_internal/compiler/implementation/lib/js_rti.dart

Issue 13019003: Enable full type-checks in checked mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a bug. Created 7 years, 8 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: sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart b/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
index d84a6a297a21a424a57928f1db1e114a736f2786..f07019859e5e2785ba589b79d40ed1f4feb691d1 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
@@ -129,6 +129,23 @@ bool checkSubtype(Object object, String isField, List checks, String asField,
return checkArguments(substitution, arguments, checks);
}
+Object assertSubtype(Object object, String isField, List checks, String asField,
+ bool native) {
+ if (object == null) return;
ngeoffray 2013/04/15 10:59:14 return null;
karlklose 2013/05/02 15:04:54 Done.
+ var target = isJsArray(object) ? getInterceptor(object) : object;
ngeoffray 2013/04/15 10:59:14 You should not need to do this anymore but just: v
karlklose 2013/05/02 15:04:54 Done.
+ bool isSubclass = native ? call(target, isField) : getField(target, isField);
+ // When we read the field and it is not there, [isSubclass] will be [:null:].
+ if (isSubclass == null || !isSubclass) {
+ propertyTypeError(object, isField);
+ }
+ var substitution = native ? call(target, asField) : getField(target, asField);
+ var arguments = getRuntimeTypeInfo(object);
+ if (!checkArguments(substitution, arguments, checks)) {
+ propertyTypeError(object, isField);
+ }
+ return object;
+}
+
/**
* Check that the types in the list [arguments] are subtypes of the types in
* list [checks] (at the respective positions), possibly applying [substitution]
@@ -194,6 +211,13 @@ bool objectIsSubtype(Object o, var t) {
return isSubtype(type, t);
}
+Object assertObjectIsSubtype(Object o, var t) {
+ if (!objectIsSubtype(o, t)) {
+ throw new TypeErrorImplementation(o, runtimeTypeToString(t));
+ }
+ return o;
+}
+
/**
* Check whether the type represented by [s] is a subtype of the type
* represented by [t].
@@ -219,6 +243,10 @@ bool isSubtype(var s, var t) {
// constructed from the type of [t].
var typeOfS = isJsArray(s) ? s[0] : s;
var typeOfT = isJsArray(t) ? t[0] : t;
+ // TODO(johnniwinther): remove this.
ngeoffray 2013/04/15 10:59:14 What is this for? Please explain why we should rem
karlklose 2013/05/02 15:04:54 This will be replaced with the dynamic function su
+ if (JS('bool', '#.func', s) == true || JS('bool', '#.func', s) == true ) {
Johnni Winther 2013/04/17 08:04:20 t -> s in one of the cases.
karlklose 2013/05/02 15:04:54 Done.
+ return true;
+ }
// Check for a subtyping flag.
var test = '${JS_OPERATOR_IS_PREFIX()}${runtimeTypeToString(typeOfT)}';
if (getField(typeOfS, test) == null) return false;

Powered by Google App Engine
This is Rietveld 408576698