| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.element; | 8 library engine.element; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 5487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5498 } | 5498 } |
| 5499 | 5499 |
| 5500 @override | 5500 @override |
| 5501 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) { | 5501 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) { |
| 5502 // trivial base cases | 5502 // trivial base cases |
| 5503 if (type == null) { | 5503 if (type == null) { |
| 5504 return false; | 5504 return false; |
| 5505 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { | 5505 } else if (identical(this, type) || type.isDynamic || type.isDartCoreFunctio
n || type.isObject) { |
| 5506 return true; | 5506 return true; |
| 5507 } else if (type is UnionType) { | 5507 } else if (type is UnionType) { |
| 5508 return (type as UnionTypeImpl).internalUnionTypeIsMoreSpecificThan(this, w
ithDynamic, visitedTypePairs); | 5508 return (type as UnionTypeImpl).internalUnionTypeIsLessSpecificThan(this, w
ithDynamic, visitedTypePairs); |
| 5509 } else if (type is! FunctionType) { | 5509 } else if (type is! FunctionType) { |
| 5510 return false; | 5510 return false; |
| 5511 } else if (this == type) { | 5511 } else if (this == type) { |
| 5512 return true; | 5512 return true; |
| 5513 } | 5513 } |
| 5514 FunctionType t = this; | 5514 FunctionType t = this; |
| 5515 FunctionType s = type as FunctionType; | 5515 FunctionType s = type as FunctionType; |
| 5516 List<DartType> tTypes = t.normalParameterTypes; | 5516 List<DartType> tTypes = t.normalParameterTypes; |
| 5517 List<DartType> tOpTypes = t.optionalParameterTypes; | 5517 List<DartType> tOpTypes = t.optionalParameterTypes; |
| 5518 List<DartType> sTypes = s.normalParameterTypes; | 5518 List<DartType> sTypes = s.normalParameterTypes; |
| (...skipping 1752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7271 @override | 7271 @override |
| 7272 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) { | 7272 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) { |
| 7273 // | 7273 // |
| 7274 // S is dynamic. | 7274 // S is dynamic. |
| 7275 // The test to determine whether S is dynamic is done here because dynamic i
s not an instance of | 7275 // The test to determine whether S is dynamic is done here because dynamic i
s not an instance of |
| 7276 // InterfaceType. | 7276 // InterfaceType. |
| 7277 // | 7277 // |
| 7278 if (identical(type, DynamicTypeImpl.instance)) { | 7278 if (identical(type, DynamicTypeImpl.instance)) { |
| 7279 return true; | 7279 return true; |
| 7280 } else if (type is UnionType) { | 7280 } else if (type is UnionType) { |
| 7281 return (type as UnionTypeImpl).internalUnionTypeIsMoreSpecificThan(this, w
ithDynamic, visitedTypePairs); | 7281 return (type as UnionTypeImpl).internalUnionTypeIsLessSpecificThan(this, w
ithDynamic, visitedTypePairs); |
| 7282 } else if (type is! InterfaceType) { | 7282 } else if (type is! InterfaceType) { |
| 7283 return false; | 7283 return false; |
| 7284 } | 7284 } |
| 7285 return _isMoreSpecificThan(type as InterfaceType, new HashSet<ClassElement>(
), withDynamic, visitedTypePairs); | 7285 return _isMoreSpecificThan(type as InterfaceType, new HashSet<ClassElement>(
), withDynamic, visitedTypePairs); |
| 7286 } | 7286 } |
| 7287 | 7287 |
| 7288 @override | 7288 @override |
| 7289 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) { | 7289 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) { |
| 7290 // | 7290 // |
| 7291 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S | 7291 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S |
| (...skipping 3443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10735 * or <i>S</i> <: <i>T</i> (Interface Types section of spec). | 10735 * or <i>S</i> <: <i>T</i> (Interface Types section of spec). |
| 10736 * | 10736 * |
| 10737 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method | 10737 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method |
| 10738 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is | 10738 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is |
| 10739 * used to prevent infinite loops. | 10739 * used to prevent infinite loops. |
| 10740 * | 10740 * |
| 10741 * @param type the type being compared with this type | 10741 * @param type the type being compared with this type |
| 10742 * @param visitedTypePairs the set of pairs of types used to prevent infinite
loops | 10742 * @param visitedTypePairs the set of pairs of types used to prevent infinite
loops |
| 10743 * @return `true` if this type is assignable to the given type | 10743 * @return `true` if this type is assignable to the given type |
| 10744 */ | 10744 */ |
| 10745 bool isAssignableTo2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) =
> isSubtypeOf2(type, visitedTypePairs) || (type as TypeImpl).isSubtypeOf2(this,
visitedTypePairs); | 10745 bool isAssignableTo2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10746 // Strictness matters for union types on the LHS, but not for union types |
| 10747 // on the RHS. |
| 10748 if (this is UnionType) { |
| 10749 if (AnalysisEngine.instance.strictUnionTypes) { |
| 10750 // *Every* element on the LHS must be assignable to the RHS. We recursiv
ely fall into |
| 10751 // the next case when the RHS is also a union: the order here is importa
nt! |
| 10752 for (DartType left in (this as UnionType).elements) { |
| 10753 // Would have to cast to [TypeImpl] to call the [visitedTypePairs] ver
sion here. |
| 10754 if (!left.isAssignableTo(type)) { |
| 10755 return false; |
| 10756 } |
| 10757 } |
| 10758 return true; |
| 10759 } else { |
| 10760 // *Some* element on the LHS must be assignable to the RHS. |
| 10761 for (DartType left in (this as UnionType).elements) { |
| 10762 // Would have to cast to [TypeImpl] to call the [visitedTypePairs] ver
sion here. |
| 10763 if (left.isAssignableTo(type)) { |
| 10764 return true; |
| 10765 } |
| 10766 } |
| 10767 return false; |
| 10768 } |
| 10769 } else if (type is UnionType) { |
| 10770 // The LHS, which is not a union, must be assignable to *some* element on
the RHS. |
| 10771 for (DartType right in type.elements) { |
| 10772 if (this.isAssignableTo2(right, visitedTypePairs)) { |
| 10773 return true; |
| 10774 } |
| 10775 } |
| 10776 return false; |
| 10777 } else { |
| 10778 // For non union types we use the language spec definition of [<=>]. |
| 10779 return isSubtypeOf2(type, visitedTypePairs) || (type as TypeImpl).isSubtyp
eOf2(this, visitedTypePairs); |
| 10780 } |
| 10781 } |
| 10746 | 10782 |
| 10747 @override | 10783 @override |
| 10748 bool get isBottom => false; | 10784 bool get isBottom => false; |
| 10749 | 10785 |
| 10750 @override | 10786 @override |
| 10751 bool get isDartCoreFunction => false; | 10787 bool get isDartCoreFunction => false; |
| 10752 | 10788 |
| 10753 @override | 10789 @override |
| 10754 bool get isDynamic => false; | 10790 bool get isDynamic => false; |
| 10755 | 10791 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11201 } | 11237 } |
| 11202 builder.append("}"); | 11238 builder.append("}"); |
| 11203 } | 11239 } |
| 11204 | 11240 |
| 11205 @override | 11241 @override |
| 11206 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => th
is == object; | 11242 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => th
is == object; |
| 11207 | 11243 |
| 11208 @override | 11244 @override |
| 11209 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) { | 11245 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) { |
| 11210 // What version of subtyping do we want? See discussion below in [internalIs
SubtypeOf]. | 11246 // What version of subtyping do we want? See discussion below in [internalIs
SubtypeOf]. |
| 11211 // | 11247 if (AnalysisEngine.instance.strictUnionTypes) { |
| 11212 // The more unsound version: any. | 11248 // The less unsound version: all. |
| 11213 for (DartType t in _types) { | 11249 for (DartType t in _types) { |
| 11214 if ((t as TypeImpl).internalIsMoreSpecificThan(type, withDynamic, visitedT
ypePairs)) { | 11250 if (!(t as TypeImpl).internalIsMoreSpecificThan(type, withDynamic, visit
edTypePairs)) { |
| 11215 return true; | 11251 return false; |
| 11252 } |
| 11216 } | 11253 } |
| 11254 return true; |
| 11255 } else { |
| 11256 // The more unsound version: any. |
| 11257 for (DartType t in _types) { |
| 11258 if ((t as TypeImpl).internalIsMoreSpecificThan(type, withDynamic, visite
dTypePairs)) { |
| 11259 return true; |
| 11260 } |
| 11261 } |
| 11262 return false; |
| 11217 } | 11263 } |
| 11218 return false; | |
| 11219 } | 11264 } |
| 11220 | 11265 |
| 11221 @override | 11266 @override |
| 11222 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) { | 11267 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) { |
| 11223 // The more unsound version: any. | 11268 if (AnalysisEngine.instance.strictUnionTypes) { |
| 11224 for (DartType t in _types) { | 11269 // The less unsound version: all. |
| 11225 if ((t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) { | 11270 // |
| 11226 return true; | 11271 // For this version to make sense we also need to redefine assignment comp
atibility [<=>]. |
| 11272 // See discussion above. |
| 11273 for (DartType t in _types) { |
| 11274 if (!(t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) { |
| 11275 return false; |
| 11276 } |
| 11227 } | 11277 } |
| 11278 return true; |
| 11279 } else { |
| 11280 // The more unsound version: any. |
| 11281 for (DartType t in _types) { |
| 11282 if ((t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) { |
| 11283 return true; |
| 11284 } |
| 11285 } |
| 11286 return false; |
| 11228 } | 11287 } |
| 11229 return false; | |
| 11230 } | 11288 } |
| 11231 | 11289 |
| 11232 /** | 11290 /** |
| 11233 * The more-specific-than test for union types on the RHS is uniform in non-un
ion LHSs. So, other | 11291 * The more-specific-than test for union types on the RHS is uniform in non-un
ion LHSs. So, other |
| 11234 * `TypeImpl`s can call this method to implement `internalIsMoreSpecificThan`
for | 11292 * `TypeImpl`s can call this method to implement `internalIsMoreSpecificThan`
for |
| 11235 * union types. | 11293 * union types. |
| 11236 * | 11294 * |
| 11237 * @param type | 11295 * @param type |
| 11238 * @param visitedTypePairs | 11296 * @param visitedTypePairs |
| 11239 * @return true if `type` is more specific than this union type | 11297 * @return true if `type` is more specific than this union type |
| 11240 */ | 11298 */ |
| 11241 bool internalUnionTypeIsMoreSpecificThan(DartType type, bool withDynamic, Set<
TypeImpl_TypePair> visitedTypePairs) { | 11299 bool internalUnionTypeIsLessSpecificThan(DartType type, bool withDynamic, Set<
TypeImpl_TypePair> visitedTypePairs) { |
| 11242 // This implementation does not make sense when [type] is a union type, at l
east | 11300 // This implementation does not make sense when [type] is a union type, at l
east |
| 11243 // for the "less unsound" version of [internalIsMoreSpecificThan] above. | 11301 // for the "less unsound" version of [internalIsMoreSpecificThan] above. |
| 11244 if (type is UnionType) { | 11302 if (type is UnionType) { |
| 11245 throw new IllegalArgumentException("Only non-union types are supported."); | 11303 throw new IllegalArgumentException("Only non-union types are supported."); |
| 11246 } | 11304 } |
| 11247 for (DartType t in _types) { | 11305 for (DartType t in _types) { |
| 11248 if ((type as TypeImpl).internalIsMoreSpecificThan(t, withDynamic, visitedT
ypePairs)) { | 11306 if ((type as TypeImpl).internalIsMoreSpecificThan(t, withDynamic, visitedT
ypePairs)) { |
| 11249 return true; | 11307 return true; |
| 11250 } | 11308 } |
| 11251 } | 11309 } |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11614 if (type is UnionType) { | 11672 if (type is UnionType) { |
| 11615 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite
dTypePairs); | 11673 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite
dTypePairs); |
| 11616 } | 11674 } |
| 11617 // The only subtype relations that pertain to void are therefore: | 11675 // The only subtype relations that pertain to void are therefore: |
| 11618 // void <: void (by reflexivity) | 11676 // void <: void (by reflexivity) |
| 11619 // bottom <: void (as bottom is a subtype of all types). | 11677 // bottom <: void (as bottom is a subtype of all types). |
| 11620 // void <: dynamic (as dynamic is a supertype of all types) | 11678 // void <: dynamic (as dynamic is a supertype of all types) |
| 11621 return identical(type, this) || identical(type, DynamicTypeImpl.instance); | 11679 return identical(type, this) || identical(type, DynamicTypeImpl.instance); |
| 11622 } | 11680 } |
| 11623 } | 11681 } |
| OLD | NEW |