| 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 5263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5274 * @param firstTypes the first map of name/type pairs being compared | 5274 * @param firstTypes the first map of name/type pairs being compared |
| 5275 * @param secondTypes the second map of name/type pairs being compared | 5275 * @param secondTypes the second map of name/type pairs being compared |
| 5276 * @param visitedElementPairs a set of visited element pairs | 5276 * @param visitedElementPairs a set of visited element pairs |
| 5277 * @return `true` if all of the name/type pairs in the first map are equal to
the | 5277 * @return `true` if all of the name/type pairs in the first map are equal to
the |
| 5278 * corresponding name/type pairs in the second map | 5278 * corresponding name/type pairs in the second map |
| 5279 */ | 5279 */ |
| 5280 static bool _equals(Map<String, DartType> firstTypes, Map<String, DartType> se
condTypes, Set<ElementPair> visitedElementPairs) { | 5280 static bool _equals(Map<String, DartType> firstTypes, Map<String, DartType> se
condTypes, Set<ElementPair> visitedElementPairs) { |
| 5281 if (secondTypes.length != firstTypes.length) { | 5281 if (secondTypes.length != firstTypes.length) { |
| 5282 return false; | 5282 return false; |
| 5283 } | 5283 } |
| 5284 JavaIterator<MapEntry<String, DartType>> firstIterator = new JavaIterator(ge
tMapEntrySet(firstTypes)); | 5284 Iterator<String> firstKeys = firstTypes.keys.iterator; |
| 5285 JavaIterator<MapEntry<String, DartType>> secondIterator = new JavaIterator(g
etMapEntrySet(secondTypes)); | 5285 Iterator<String> secondKeys = secondTypes.keys.iterator; |
| 5286 while (firstIterator.hasNext) { | 5286 while (firstKeys.moveNext() && secondKeys.moveNext()) { |
| 5287 MapEntry<String, DartType> firstEntry = firstIterator.next(); | 5287 String firstKey = firstKeys.current; |
| 5288 MapEntry<String, DartType> secondEntry = secondIterator.next(); | 5288 String secondKey = secondKeys.current; |
| 5289 if (firstEntry.getKey() != secondEntry.getKey() || !(firstEntry.getValue()
as TypeImpl).internalEquals(secondEntry.getValue(), visitedElementPairs)) { | 5289 TypeImpl firstType = firstTypes[firstKey]; |
| 5290 TypeImpl secondType = secondTypes[secondKey]; |
| 5291 if (firstKey != secondKey |
| 5292 || !firstType.internalEquals(secondType, visitedElementPairs)) { |
| 5290 return false; | 5293 return false; |
| 5291 } | 5294 } |
| 5292 } | 5295 } |
| 5293 return true; | 5296 return true; |
| 5294 } | 5297 } |
| 5295 | 5298 |
| 5296 /** | 5299 /** |
| 5297 * An array containing the actual types of the type arguments. | 5300 * An array containing the actual types of the type arguments. |
| 5298 */ | 5301 */ |
| 5299 List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY; | 5302 List<DartType> typeArguments = TypeImpl.EMPTY_ARRAY; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5356 } | 5359 } |
| 5357 buffer.write("]"); | 5360 buffer.write("]"); |
| 5358 needsComma = true; | 5361 needsComma = true; |
| 5359 } | 5362 } |
| 5360 if (namedParameterTypes.length > 0) { | 5363 if (namedParameterTypes.length > 0) { |
| 5361 if (needsComma) { | 5364 if (needsComma) { |
| 5362 buffer.write(", "); | 5365 buffer.write(", "); |
| 5363 needsComma = false; | 5366 needsComma = false; |
| 5364 } | 5367 } |
| 5365 buffer.write("{"); | 5368 buffer.write("{"); |
| 5366 for (MapEntry<String, DartType> entry in getMapEntrySet(namedParameterTy
pes)) { | 5369 namedParameterTypes.forEach((String name, DartType type) { |
| 5367 if (needsComma) { | 5370 if (needsComma) { |
| 5368 buffer.write(", "); | 5371 buffer.write(", "); |
| 5369 } else { | 5372 } else { |
| 5370 needsComma = true; | 5373 needsComma = true; |
| 5371 } | 5374 } |
| 5372 buffer.write(entry.getKey()); | 5375 buffer.write(name); |
| 5373 buffer.write(": "); | 5376 buffer.write(": "); |
| 5374 buffer.write(entry.getValue().displayName); | 5377 buffer.write(type.displayName); |
| 5375 } | 5378 }); |
| 5376 buffer.write("}"); | 5379 buffer.write("}"); |
| 5377 needsComma = true; | 5380 needsComma = true; |
| 5378 } | 5381 } |
| 5379 buffer.write(")"); | 5382 buffer.write(")"); |
| 5380 buffer.write(Element.RIGHT_ARROW); | 5383 buffer.write(Element.RIGHT_ARROW); |
| 5381 if (returnType == null) { | 5384 if (returnType == null) { |
| 5382 buffer.write("null"); | 5385 buffer.write("null"); |
| 5383 } else { | 5386 } else { |
| 5384 buffer.write(returnType.displayName); | 5387 buffer.write(returnType.displayName); |
| 5385 } | 5388 } |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5552 return false; | 5555 return false; |
| 5553 } | 5556 } |
| 5554 } | 5557 } |
| 5555 } | 5558 } |
| 5556 Map<String, DartType> namedTypesT = t.namedParameterTypes; | 5559 Map<String, DartType> namedTypesT = t.namedParameterTypes; |
| 5557 Map<String, DartType> namedTypesS = s.namedParameterTypes; | 5560 Map<String, DartType> namedTypesS = s.namedParameterTypes; |
| 5558 // if k >= m is false, return false: the passed function type has more nam
ed parameter types than this | 5561 // if k >= m is false, return false: the passed function type has more nam
ed parameter types than this |
| 5559 if (namedTypesT.length < namedTypesS.length) { | 5562 if (namedTypesT.length < namedTypesS.length) { |
| 5560 return false; | 5563 return false; |
| 5561 } | 5564 } |
| 5562 // Loop through each element in S verifying that T has a matching paramete
r name and that the | 5565 // Loop through each element in S verifying that T has a matching |
| 5563 // corresponding type is more specific then the type in S. | 5566 // parameter name and that the corresponding type is more specific then |
| 5564 JavaIterator<MapEntry<String, DartType>> iteratorS = new JavaIterator(getM
apEntrySet(namedTypesS)); | 5567 // the type in S. |
| 5565 while (iteratorS.hasNext) { | 5568 for (String keyS in namedTypesS.keys) { |
| 5566 MapEntry<String, DartType> entryS = iteratorS.next(); | 5569 DartType typeT = namedTypesT[keyS]; |
| 5567 DartType typeT = namedTypesT[entryS.getKey()]; | |
| 5568 if (typeT == null) { | 5570 if (typeT == null) { |
| 5569 return false; | 5571 return false; |
| 5570 } | 5572 } |
| 5571 if (!(typeT as TypeImpl).isMoreSpecificThan2(entryS.getValue(), withDyna
mic, visitedTypePairs)) { | 5573 if (!(typeT as TypeImpl).isMoreSpecificThan2(namedTypesS[keyS], withDyna
mic, visitedTypePairs)) { |
| 5572 return false; | 5574 return false; |
| 5573 } | 5575 } |
| 5574 } | 5576 } |
| 5575 } else if (s.namedParameterTypes.length > 0) { | 5577 } else if (s.namedParameterTypes.length > 0) { |
| 5576 return false; | 5578 return false; |
| 5577 } else { | 5579 } else { |
| 5578 // positional parameter case | 5580 // positional parameter case |
| 5579 int tArgLength = tTypes.length + tOpTypes.length; | 5581 int tArgLength = tTypes.length + tOpTypes.length; |
| 5580 int sArgLength = sTypes.length + sOpTypes.length; | 5582 int sArgLength = sTypes.length + sOpTypes.length; |
| 5581 // Check that the total number of parameters in t is greater than or equal
to the number of | 5583 // Check that the total number of parameters in t is greater than or equal
to the number of |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5684 } | 5686 } |
| 5685 buffer.write("]"); | 5687 buffer.write("]"); |
| 5686 needsComma = true; | 5688 needsComma = true; |
| 5687 } | 5689 } |
| 5688 if (namedParameterTypes.length > 0) { | 5690 if (namedParameterTypes.length > 0) { |
| 5689 if (needsComma) { | 5691 if (needsComma) { |
| 5690 buffer.write(", "); | 5692 buffer.write(", "); |
| 5691 needsComma = false; | 5693 needsComma = false; |
| 5692 } | 5694 } |
| 5693 buffer.write("{"); | 5695 buffer.write("{"); |
| 5694 for (MapEntry<String, DartType> entry in getMapEntrySet(namedParameterType
s)) { | 5696 namedParameterTypes.forEach((String name, DartType type) { |
| 5695 if (needsComma) { | 5697 if (needsComma) { |
| 5696 buffer.write(", "); | 5698 buffer.write(", "); |
| 5697 } else { | 5699 } else { |
| 5698 needsComma = true; | 5700 needsComma = true; |
| 5699 } | 5701 } |
| 5700 buffer.write(entry.getKey()); | 5702 buffer.write(name); |
| 5701 buffer.write(": "); | 5703 buffer.write(": "); |
| 5702 (entry.getValue() as TypeImpl).appendTo(buffer); | 5704 (type as TypeImpl).appendTo(buffer); |
| 5703 } | 5705 }); |
| 5704 buffer.write("}"); | 5706 buffer.write("}"); |
| 5705 needsComma = true; | 5707 needsComma = true; |
| 5706 } | 5708 } |
| 5707 buffer.write(")"); | 5709 buffer.write(")"); |
| 5708 buffer.write(Element.RIGHT_ARROW); | 5710 buffer.write(Element.RIGHT_ARROW); |
| 5709 if (returnType == null) { | 5711 if (returnType == null) { |
| 5710 buffer.write("null"); | 5712 buffer.write("null"); |
| 5711 } else { | 5713 } else { |
| 5712 (returnType as TypeImpl).appendTo(buffer); | 5714 (returnType as TypeImpl).appendTo(buffer); |
| 5713 } | 5715 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5780 return false; | 5782 return false; |
| 5781 } | 5783 } |
| 5782 } | 5784 } |
| 5783 } | 5785 } |
| 5784 Map<String, DartType> namedTypesT = t.namedParameterTypes; | 5786 Map<String, DartType> namedTypesT = t.namedParameterTypes; |
| 5785 Map<String, DartType> namedTypesS = s.namedParameterTypes; | 5787 Map<String, DartType> namedTypesS = s.namedParameterTypes; |
| 5786 // if k >= m is false, return false: the passed function type has more nam
ed parameter types than this | 5788 // if k >= m is false, return false: the passed function type has more nam
ed parameter types than this |
| 5787 if (namedTypesT.length < namedTypesS.length) { | 5789 if (namedTypesT.length < namedTypesS.length) { |
| 5788 return false; | 5790 return false; |
| 5789 } | 5791 } |
| 5790 // Loop through each element in S verifying that T has a matching paramete
r name and that the | 5792 // Loop through each element in S verifying that T has a matching |
| 5791 // corresponding type is assignable to the type in S. | 5793 // parameter name and that the corresponding type is assignable to the |
| 5792 JavaIterator<MapEntry<String, DartType>> iteratorS = new JavaIterator(getM
apEntrySet(namedTypesS)); | 5794 // type in S. |
| 5793 while (iteratorS.hasNext) { | 5795 for (String keyS in namedTypesS.keys) { |
| 5794 MapEntry<String, DartType> entryS = iteratorS.next(); | 5796 DartType typeT = namedTypesT[keyS]; |
| 5795 DartType typeT = namedTypesT[entryS.getKey()]; | |
| 5796 if (typeT == null) { | 5797 if (typeT == null) { |
| 5797 return false; | 5798 return false; |
| 5798 } | 5799 } |
| 5799 if (!(typeT as TypeImpl).isAssignableTo2(entryS.getValue(), visitedTypeP
airs)) { | 5800 if (!(typeT as TypeImpl).isAssignableTo2(namedTypesS[keyS], visitedTypeP
airs)) { |
| 5800 return false; | 5801 return false; |
| 5801 } | 5802 } |
| 5802 } | 5803 } |
| 5803 } else if (s.namedParameterTypes.length > 0) { | 5804 } else if (s.namedParameterTypes.length > 0) { |
| 5804 return false; | 5805 return false; |
| 5805 } else { | 5806 } else { |
| 5806 // positional parameter case | 5807 // positional parameter case |
| 5807 int tArgLength = tTypes.length + tOpTypes.length; | 5808 int tArgLength = tTypes.length + tOpTypes.length; |
| 5808 int sArgLength = sTypes.length + sOpTypes.length; | 5809 int sArgLength = sTypes.length + sOpTypes.length; |
| 5809 // Check that the total number of parameters in t is greater than or equal
to the number of | 5810 // Check that the total number of parameters in t is greater than or equal
to the number of |
| (...skipping 5437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11247 } | 11248 } |
| 11248 } | 11249 } |
| 11249 if (set.length == 0) { | 11250 if (set.length == 0) { |
| 11250 // TODO(collinsn): better to return [null] here? The use case is e.g. | 11251 // TODO(collinsn): better to return [null] here? The use case is e.g. |
| 11251 // | 11252 // |
| 11252 // union(null, null) ==> null; | 11253 // union(null, null) ==> null; |
| 11253 // | 11254 // |
| 11254 // instead of raising an exception. | 11255 // instead of raising an exception. |
| 11255 throw new IllegalArgumentException("No known use case for empty unions."); | 11256 throw new IllegalArgumentException("No known use case for empty unions."); |
| 11256 } else if (set.length == 1) { | 11257 } else if (set.length == 1) { |
| 11257 return new JavaIterator(set).next(); | 11258 return set.first; |
| 11258 } else { | 11259 } else { |
| 11259 return new UnionTypeImpl(set); | 11260 return new UnionTypeImpl(set); |
| 11260 } | 11261 } |
| 11261 } | 11262 } |
| 11262 | 11263 |
| 11263 /** | 11264 /** |
| 11264 * The types in this union. | 11265 * The types in this union. |
| 11265 */ | 11266 */ |
| 11266 final Set<DartType> _types; | 11267 final Set<DartType> _types; |
| 11267 | 11268 |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11758 if (type is UnionType) { | 11759 if (type is UnionType) { |
| 11759 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite
dTypePairs); | 11760 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf(this, visite
dTypePairs); |
| 11760 } | 11761 } |
| 11761 // The only subtype relations that pertain to void are therefore: | 11762 // The only subtype relations that pertain to void are therefore: |
| 11762 // void <: void (by reflexivity) | 11763 // void <: void (by reflexivity) |
| 11763 // bottom <: void (as bottom is a subtype of all types). | 11764 // bottom <: void (as bottom is a subtype of all types). |
| 11764 // void <: dynamic (as dynamic is a supertype of all types) | 11765 // void <: dynamic (as dynamic is a supertype of all types) |
| 11765 return identical(type, this) || type.isDynamic; | 11766 return identical(type, this) || type.isDynamic; |
| 11766 } | 11767 } |
| 11767 } | 11768 } |
| OLD | NEW |