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

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

Issue 14698026: Revert "Enable full type-checks in checked mode." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 2085dc4a64bc31ed6d1642923ed095801bb39d5f..c6d5727c0044537c9e3251f3c7965cc8fb5db787 100644
--- a/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
+++ b/sdk/lib/_internal/compiler/implementation/lib/js_rti.dart
@@ -119,13 +119,13 @@ substitute(var substitution, var arguments) {
* against.
*/
bool checkSubtype(Object object, String isField, List checks, String asField) {
- if (object == null) return true;
+ if (object == null) return false;
var arguments = getRuntimeTypeInfo(object);
// Interceptor is needed for JSArray and native classes.
// TODO(sra): It could be a more specialized interceptor since [object] is not
// `null` or a primitive.
// TODO(9586): Move type info for static functions onto an interceptor.
- var interceptor = getInterceptor(object);
+ var interceptor = isJsFunction(object) ? object : getInterceptor(object);
bool isSubclass = getField(interceptor, isField);
// When we read the field and it is not there, [isSubclass] will be [:null:].
if (isSubclass == null || !isSubclass) return false;
@@ -134,19 +134,6 @@ 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) {
- if (!checkSubtype(object, isField, checks, asField)) {
- // Shorten the field name to the class name and append the textual
- // representation of the type arguments.
- int prefixLength = JS_OPERATOR_IS_PREFIX().length;
- String typeName = '${isField.substring(prefixLength, isField.length)}'
- '${joinArguments(checks, 0)}';
- throw new TypeErrorImplementation(object, typeName);
- }
- 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]
@@ -187,7 +174,7 @@ getField(var object, var name) => JS('var', r'#[#]', object, name);
* representation [t], which is a type representation as described in the
* comment on [isSubtype].
*/
-bool checkSubtypeOfRuntimeType(Object o, var t) {
+bool objectIsSubtype(Object o, var t) {
if (JS('bool', '# == null', o) || JS('bool', '# == null', t)) return true;
// Get the runtime type information from the object here, because we may
// overwrite o with the interceptor below.
@@ -212,13 +199,6 @@ bool checkSubtypeOfRuntimeType(Object o, var t) {
return isSubtype(type, t);
}
-Object assertSubtypeOfRuntimeType(Object object, var type) {
- if (!checkSubtypeOfRuntimeType(object, type)) {
- throw new TypeErrorImplementation(object, runtimeTypeToString(type));
- }
- return object;
-}
-
/**
* Check whether the type represented by [s] is a subtype of the type
* represented by [t].
@@ -244,10 +224,6 @@ 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): replace this with the real function subtype test.
- if (JS('bool', '#.func', s) == true || JS('bool', '#.func', t) == true ) {
- 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