OLD | NEW |
---|---|
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:collection' show Queue; | 5 import 'dart:collection' show Queue; |
6 | 6 |
7 import '../common.dart'; | 7 import '../common.dart'; |
8 import '../common/backend_api.dart' show ForeignResolver; | 8 import '../common/backend_api.dart' show ForeignResolver; |
9 import '../common/registry.dart' show Registry; | 9 import '../common/registry.dart' show Registry; |
10 import '../common/resolution.dart' show Resolution; | 10 import '../common/resolution.dart' show Resolution; |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 } else if (type == coreTypes.stringType) { | 513 } else if (type == coreTypes.stringType) { |
514 backend.registerInstantiatedType(type, world, registry); | 514 backend.registerInstantiatedType(type, world, registry); |
515 } else if (type == coreTypes.nullType) { | 515 } else if (type == coreTypes.nullType) { |
516 backend.registerInstantiatedType(type, world, registry); | 516 backend.registerInstantiatedType(type, world, registry); |
517 } else if (type == coreTypes.boolType) { | 517 } else if (type == coreTypes.boolType) { |
518 backend.registerInstantiatedType(type, world, registry); | 518 backend.registerInstantiatedType(type, world, registry); |
519 } else if (compiler.types | 519 } else if (compiler.types |
520 .isSubtype(type, backend.listImplementation.rawType)) { | 520 .isSubtype(type, backend.listImplementation.rawType)) { |
521 backend.registerInstantiatedType(type, world, registry); | 521 backend.registerInstantiatedType(type, world, registry); |
522 } | 522 } |
523 // TODO(johnniwinther): Improve spec string precision to handle type | |
524 // arguments and implements relations that preserve generics. Currently | |
525 // we cannot distinguish between `List`, `List<dynamic>`, and | |
526 // `List<int>` and take all to mean `List<E>`; in effect not including | |
527 // any native subclasses of generic classes. | |
sra1
2016/05/31 20:47:05
Add comment that we should hunt down uses of `List
Johnni Winther
2016/06/02 08:19:20
Done.
| |
528 enqueueUnusedClassesMatching((ClassElement nativeClass) { | |
529 InterfaceType nativeType = nativeClass.thisType; | |
530 InterfaceType specType = type.element.thisType; | |
531 return compiler.types.isSubtype(nativeType, specType); | |
532 }, cause, 'subtypeof($type)'); | |
533 return; | |
523 } | 534 } |
524 assert(type is DartType); | 535 assert(type is VoidType || type is DynamicType); |
525 enqueueUnusedClassesMatching( | |
526 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), | |
527 cause, | |
528 'subtypeof($type)'); | |
529 } | 536 } |
530 | 537 |
531 // Give an info so that library developers can compile with -v to find why | 538 // Give an info so that library developers can compile with -v to find why |
532 // all the native classes are included. | 539 // all the native classes are included. |
533 if (unusedClasses.isEmpty && !allUsedBefore) { | 540 if (unusedClasses.isEmpty && !allUsedBefore) { |
534 reporter.log('All native types marked as used due to $cause.'); | 541 reporter.log('All native types marked as used due to $cause.'); |
535 } | 542 } |
536 } | 543 } |
537 | 544 |
538 enqueueUnusedClassesMatching(bool predicate(classElement), cause, | 545 enqueueUnusedClassesMatching(bool predicate(classElement), cause, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
695 List<Element> directSubtypes = | 702 List<Element> directSubtypes = |
696 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]); | 703 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassElement>[]); |
697 directSubtypes.add(cls); | 704 directSubtypes.add(cls); |
698 } | 705 } |
699 | 706 |
700 void logSummary(log(message)) { | 707 void logSummary(log(message)) { |
701 log('Compiled ${registeredClasses.length} native classes, ' | 708 log('Compiled ${registeredClasses.length} native classes, ' |
702 '${unusedClasses.length} native classes omitted.'); | 709 '${unusedClasses.length} native classes omitted.'); |
703 } | 710 } |
704 } | 711 } |
OLD | NEW |