OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library dart2js.world; | 5 library dart2js.world; |
6 | 6 |
7 import 'closure.dart' show | 7 import 'closure.dart' show |
8 SynthesizedCallMethodElementX; | 8 SynthesizedCallMethodElementX; |
9 import 'common.dart'; | 9 import 'common.dart'; |
10 import 'common/backend_api.dart' show | 10 import 'common/backend_api.dart' show |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 /// Returns `true` if any directly instantiated class other than [cls] | 304 /// Returns `true` if any directly instantiated class other than [cls] |
305 /// implements [cls]. | 305 /// implements [cls]. |
306 bool hasAnyStrictSubtype(ClassElement cls) { | 306 bool hasAnyStrictSubtype(ClassElement cls) { |
307 return !strictSubtypesOf(cls).isEmpty; | 307 return !strictSubtypesOf(cls).isEmpty; |
308 } | 308 } |
309 | 309 |
310 /// Returns `true` if all directly instantiated classes that implement [cls] | 310 /// Returns `true` if all directly instantiated classes that implement [cls] |
311 /// extend it. | 311 /// extend it. |
312 bool hasOnlySubclasses(ClassElement cls) { | 312 bool hasOnlySubclasses(ClassElement cls) { |
| 313 // TODO(johnniwinther): move this to ClassSet? |
| 314 if (cls == objectClass) return true; |
313 Iterable<ClassElement> subtypes = strictSubtypesOf(cls); | 315 Iterable<ClassElement> subtypes = strictSubtypesOf(cls); |
314 if (subtypes == null) return true; | 316 if (subtypes == null) return true; |
315 Iterable<ClassElement> subclasses = strictSubclassesOf(cls); | 317 Iterable<ClassElement> subclasses = strictSubclassesOf(cls); |
316 return subclasses != null && (subclasses.length == subtypes.length); | 318 return subclasses != null && (subclasses.length == subtypes.length); |
317 } | 319 } |
318 | 320 |
319 @override | 321 @override |
320 ClassElement getLubOfInstantiatedSubclasses(ClassElement cls) { | 322 ClassElement getLubOfInstantiatedSubclasses(ClassElement cls) { |
321 ClassHierarchyNode hierarchy = _classHierarchyNodes[cls.declaration]; | 323 ClassHierarchyNode hierarchy = _classHierarchyNodes[cls.declaration]; |
322 return hierarchy != null | 324 return hierarchy != null |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 // function expressions's element. | 755 // function expressions's element. |
754 // TODO(herhut): Generate classes for function expressions earlier. | 756 // TODO(herhut): Generate classes for function expressions earlier. |
755 if (element is SynthesizedCallMethodElementX) { | 757 if (element is SynthesizedCallMethodElementX) { |
756 return getMightBePassedToApply(element.expression); | 758 return getMightBePassedToApply(element.expression); |
757 } | 759 } |
758 return functionsThatMightBePassedToApply.contains(element); | 760 return functionsThatMightBePassedToApply.contains(element); |
759 } | 761 } |
760 | 762 |
761 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; | 763 bool get hasClosedWorldAssumption => !compiler.hasIncrementalSupport; |
762 } | 764 } |
OLD | NEW |