Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/js_backend/backend.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart |
| index a2cffcf2f09c84d36757f28e83471cb10a9e35a2..b0b27f5849cd62b1f8e9c5b6b4b3c4f5a77259be 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart |
| @@ -1176,19 +1176,26 @@ class JavaScriptBackend extends Backend { |
| void registerIsCheck(DartType type, Enqueuer world, TreeElements elements) { |
| world.registerInstantiatedClass(compiler.boolClass, elements); |
| bool isTypeVariable = type.kind == TypeKind.TYPE_VARIABLE; |
| + bool isCheckedMode = compiler.enableTypeAssertions; |
| if (!type.isRaw || isTypeVariable) { |
| enqueueInResolution(getSetRuntimeTypeInfo(), elements); |
| enqueueInResolution(getGetRuntimeTypeInfo(), elements); |
| enqueueInResolution(getGetRuntimeTypeArgument(), elements); |
| + if (isCheckedMode) { |
| + enqueueInResolution(getAssertSubtype(), elements); |
| + } |
| enqueueInResolution(getCheckSubtype(), elements); |
| if (isTypeVariable) { |
| - enqueueInResolution(getGetObjectIsSubtype(), elements); |
| + enqueueInResolution(getObjectIsSubtype(), elements); |
| + if (isCheckedMode) { |
| + enqueueInResolution(getAssertObjectIsSubtype(), elements); |
| + } |
| } |
| world.registerInstantiatedClass(compiler.listClass, elements); |
| } |
| // [registerIsCheck] is also called for checked mode checks, so we |
| // need to register checked mode helpers. |
| - if (compiler.enableTypeAssertions) { |
| + if (isCheckedMode) { |
| Element e = getCheckedModeHelper(type, typeCast: false); |
| if (e != null) world.addToWorkList(e); |
| // We also need the native variant of the check (for DOM types). |
| @@ -1274,8 +1281,9 @@ class JavaScriptBackend extends Backend { |
| } |
| bool needsRti(ClassElement cls) { |
| - return rti.classesNeedingRti.contains(cls.declaration) |
| - || compiler.enabledRuntimeType; |
| + return rti.classesNeedingRti.contains(cls.declaration) || |
| + compiler.enabledRuntimeType || |
| + (compiler.enableTypeAssertions && !cls.typeVariables.isEmpty); |
|
ngeoffray
2013/04/15 10:59:14
Is that because we never know if there will be a t
|
| } |
| bool isDefaultNoSuchMethodImplementation(Element element) { |
| @@ -1708,10 +1716,18 @@ class JavaScriptBackend extends Backend { |
| return compiler.findHelper(const SourceString('checkSubtype')); |
| } |
| - Element getGetObjectIsSubtype() { |
| + Element getAssertSubtype() { |
| + return compiler.findHelper(const SourceString('assertSubtype')); |
| + } |
| + |
| + Element getObjectIsSubtype() { |
| return compiler.findHelper(const SourceString('objectIsSubtype')); |
| } |
| + Element getAssertObjectIsSubtype() { |
| + return compiler.findHelper(const SourceString('assertObjectIsSubtype')); |
| + } |
| + |
| Element getThrowNoSuchMethod() { |
| return compiler.findHelper(const SourceString('throwNoSuchMethod')); |
| } |