Chromium Code Reviews| Index: pkg/compiler/lib/src/js_emitter/type_test_generator.dart |
| diff --git a/pkg/compiler/lib/src/js_emitter/type_test_generator.dart b/pkg/compiler/lib/src/js_emitter/type_test_generator.dart |
| index 2c9ce0d9ee1c64dc6a725bbea143105464044714..a2db59dc22e2321da233987df97e6c8fe4639124 100644 |
| --- a/pkg/compiler/lib/src/js_emitter/type_test_generator.dart |
| +++ b/pkg/compiler/lib/src/js_emitter/type_test_generator.dart |
| @@ -57,12 +57,16 @@ class TypeTestGenerator { |
| TypeTestProperties result = new TypeTestProperties(); |
| + /// Generates an is-test if the test is not inherited from a superclass |
| + /// anyway. This assumes that for every class an is-tests is generated |
|
floitsch
2015/01/26 16:19:29
-anyway-.
herhut
2015/01/27 11:37:20
Done.
|
| + /// dyanically at runtime anyway. We also always generate tests against |
|
floitsch
2015/01/26 16:19:29
dynamically.
herhut
2015/01/27 11:37:19
Done.
|
| + /// native classes. |
| + /// TODO(herhut): Generate tests for native classes dynamically, as well. |
| void generateIsTest(Element other) { |
| - if (other == compiler.objectClass && other != classElement) { |
| - // Avoid emitting `$isObject` on all classes but [Object]. |
| - return; |
| + if (classElement.isNative || |
| + !compiler.world.isSubclassOf(classElement, other)) { |
| + result.properties[namer.operatorIs(other)] = js('1'); |
|
floitsch
2015/01/26 16:19:29
probably ok to have the 1 here instead of a functi
herhut
2015/01/27 11:37:20
Acknowledged.
|
| } |
| - result.properties[namer.operatorIs(other)] = js('true'); |
| } |
| void generateFunctionTypeSignature(FunctionElement method, |
| @@ -108,8 +112,7 @@ class TypeTestGenerator { |
| void generateTypeCheck(TypeCheck check) { |
| ClassElement checkedClass = check.cls; |
| - // We must not call [generateIsTest] since we also want is$Object. |
| - result.properties[namer.operatorIs(checkedClass)] = js('true'); |
| + generateIsTest(checkedClass); |
| Substitution substitution = check.substitution; |
| if (substitution != null) { |
| jsAst.Expression body = substitution.getCode(backend.rti); |