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, |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
399 } | 399 } |
400 } | 400 } |
401 } | 401 } |
402 lookupClass = lookupClass.superclass; | 402 lookupClass = lookupClass.superclass; |
403 } | 403 } |
404 return false; | 404 return false; |
405 } | 405 } |
406 | 406 |
407 @override | 407 @override |
408 bool implementsInterface(ClassElement intrface) { | 408 bool implementsInterface(ClassElement intrface) { |
409 for (DartType implementedInterfaceType in allSupertypes) { | 409 return this != intrface && |
410 ClassElement implementedInterface = implementedInterfaceType.element; | 410 allSupertypesAndSelf.asInstanceOf(intrface) != null; |
Johnni Winther
2015/10/13 10:14:55
Optimization
| |
411 if (identical(implementedInterface, intrface)) { | |
412 return true; | |
413 } | |
414 } | |
415 return false; | |
416 } | 411 } |
417 | 412 |
418 @override | 413 @override |
419 bool isSubclassOf(ClassElement cls) { | 414 bool isSubclassOf(ClassElement cls) { |
420 // Use [declaration] for both [this] and [cls], because | 415 // Use [declaration] for both [this] and [cls], because |
421 // declaration classes hold the superclass hierarchy. | 416 // declaration classes hold the superclass hierarchy. |
422 cls = cls.declaration; | 417 cls = cls.declaration; |
423 for (ClassElement s = declaration; s != null; s = s.superclass) { | 418 for (ClassElement s = declaration; s != null; s = s.superclass) { |
424 if (identical(s, cls)) return true; | 419 if (identical(s, cls)) return true; |
425 } | 420 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
489 // this signature must not have more required parameters. Having more | 484 // this signature must not have more required parameters. Having more |
490 // optional parameters is not a problem, they simply are never provided | 485 // optional parameters is not a problem, they simply are never provided |
491 // by call sites of a call to a method with the other signature. | 486 // by call sites of a call to a method with the other signature. |
492 int otherTotalCount = signature.parameterCount; | 487 int otherTotalCount = signature.parameterCount; |
493 return requiredParameterCount <= otherTotalCount | 488 return requiredParameterCount <= otherTotalCount |
494 && parameterCount >= otherTotalCount; | 489 && parameterCount >= otherTotalCount; |
495 } | 490 } |
496 return true; | 491 return true; |
497 } | 492 } |
498 } | 493 } |
OLD | NEW |