OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Mixins that implement convenience methods on [Element] subclasses. | 5 /// Mixins that implement convenience methods on [Element] subclasses. |
6 | 6 |
7 library elements.common; | 7 library elements.common; |
8 | 8 |
9 import '../common/names.dart' show | 9 import '../common/names.dart' show |
10 Names, | 10 Names, |
11 Uris; | 11 Uris; |
| 12 import '../core_types.dart' show |
| 13 CoreClasses; |
12 import '../dart_types.dart' show | 14 import '../dart_types.dart' show |
13 DartType, | 15 DartType, |
14 InterfaceType, | 16 InterfaceType, |
15 FunctionType; | 17 FunctionType; |
16 import '../util/util.dart' show | 18 import '../util/util.dart' show |
17 Link; | 19 Link; |
18 | 20 |
19 import 'elements.dart'; | 21 import 'elements.dart'; |
20 | 22 |
21 abstract class ElementCommon implements Element { | 23 abstract class ElementCommon implements Element { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 return false; | 425 return false; |
424 } | 426 } |
425 | 427 |
426 @override | 428 @override |
427 bool implementsInterface(ClassElement intrface) { | 429 bool implementsInterface(ClassElement intrface) { |
428 return this != intrface && | 430 return this != intrface && |
429 allSupertypesAndSelf.asInstanceOf(intrface) != null; | 431 allSupertypesAndSelf.asInstanceOf(intrface) != null; |
430 } | 432 } |
431 | 433 |
432 @override | 434 @override |
| 435 bool implementsFunction(CoreClasses coreClasses) { |
| 436 return asInstanceOf(coreClasses.functionClass) != null || |
| 437 callType != null; |
| 438 } |
| 439 |
| 440 @override |
433 bool isSubclassOf(ClassElement cls) { | 441 bool isSubclassOf(ClassElement cls) { |
434 // Use [declaration] for both [this] and [cls], because | 442 // Use [declaration] for both [this] and [cls], because |
435 // declaration classes hold the superclass hierarchy. | 443 // declaration classes hold the superclass hierarchy. |
436 cls = cls.declaration; | 444 cls = cls.declaration; |
437 for (ClassElement s = declaration; s != null; s = s.superclass) { | 445 for (ClassElement s = declaration; s != null; s = s.superclass) { |
438 if (identical(s, cls)) return true; | 446 if (identical(s, cls)) return true; |
439 } | 447 } |
440 return false; | 448 return false; |
441 } | 449 } |
442 | 450 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 } | 545 } |
538 | 546 |
539 @override | 547 @override |
540 void forEachLocalMember(void f(Element member)) { | 548 void forEachLocalMember(void f(Element member)) { |
541 constructors.forEach(f); | 549 constructors.forEach(f); |
542 if (mixin != null) mixin.forEachLocalMember((Element mixedInElement) { | 550 if (mixin != null) mixin.forEachLocalMember((Element mixedInElement) { |
543 if (mixedInElement.isInstanceMember) f(mixedInElement); | 551 if (mixedInElement.isInstanceMember) f(mixedInElement); |
544 }); | 552 }); |
545 } | 553 } |
546 } | 554 } |
OLD | NEW |