| 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'; |
| 11 import 'java_core.dart'; | 11 import 'java_core.dart'; |
| 12 import 'java_engine.dart'; | 12 import 'java_engine.dart'; |
| 13 import 'utilities_collection.dart'; | 13 import 'utilities_collection.dart'; |
| 14 import 'source.dart'; | 14 import 'source.dart'; |
| 15 import 'scanner.dart' show Keyword; | 15 import 'scanner.dart' show Keyword; |
| 16 import 'ast.dart'; | 16 import 'ast.dart'; |
| 17 import 'sdk.dart' show DartSdk; | 17 import 'sdk.dart' show DartSdk; |
| 18 import 'html.dart' show XmlAttributeNode, XmlTagNode; | 18 import 'html.dart' show XmlAttributeNode, XmlTagNode; |
| 19 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; | 19 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; |
| 20 import 'constant.dart' show EvaluationResultImpl; | 20 import 'constant.dart' show EvaluationResultImpl; |
| 21 import 'resolver.dart'; |
| 21 import 'utilities_dart.dart'; | 22 import 'utilities_dart.dart'; |
| 22 | 23 |
| 23 /** | 24 /** |
| 24 * Information about Angular application. | 25 * Information about Angular application. |
| 25 */ | 26 */ |
| 26 class AngularApplication { | 27 class AngularApplication { |
| 27 final Source entryPoint; | 28 final Source entryPoint; |
| 28 | 29 |
| 29 final Set<Source> _librarySources; | 30 final Set<Source> _librarySources; |
| 30 | 31 |
| (...skipping 5448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5479 return false; | 5480 return false; |
| 5480 } | 5481 } |
| 5481 } | 5482 } |
| 5482 } | 5483 } |
| 5483 } | 5484 } |
| 5484 DartType tRetType = t.returnType; | 5485 DartType tRetType = t.returnType; |
| 5485 DartType sRetType = s.returnType; | 5486 DartType sRetType = s.returnType; |
| 5486 return sRetType.isVoid || (tRetType as TypeImpl).isMoreSpecificThan2(sRetTyp
e, withDynamic, visitedTypePairs); | 5487 return sRetType.isVoid || (tRetType as TypeImpl).isMoreSpecificThan2(sRetTyp
e, withDynamic, visitedTypePairs); |
| 5487 } | 5488 } |
| 5488 | 5489 |
| 5490 /** |
| 5491 * Return `true` if this type is assignable to the given type. A function type
<i>T</i> may |
| 5492 * be assigned to a function type <i>S</i>, written <i>T</i> ⇔ <i>S</i>,
iff <i>T</i> <: |
| 5493 * <i>S</i> (Function Types section of spec). Note that this is more restricti
ve than the |
| 5494 * "may be assigned to" rule for interface types. |
| 5495 * |
| 5496 * |
| 5497 * @param type the type being compared with this type |
| 5498 * @return `true` if this type is assignable to the given type |
| 5499 */ |
| 5489 @override | 5500 @override |
| 5490 bool isAssignableTo(DartType type) => isSubtypeOf2(type, new HashSet<TypeImpl_
TypePair>()); | 5501 bool isAssignableTo(DartType type) => isSubtypeOf2(type, new HashSet<TypeImpl_
TypePair>()); |
| 5491 | 5502 |
| 5492 @override | 5503 @override |
| 5493 FunctionTypeImpl substitute3(List<DartType> argumentTypes) => substitute2(argu
mentTypes, typeArguments); | 5504 FunctionTypeImpl substitute3(List<DartType> argumentTypes) => substitute2(argu
mentTypes, typeArguments); |
| 5494 | 5505 |
| 5495 @override | 5506 @override |
| 5496 FunctionTypeImpl substitute2(List<DartType> argumentTypes, List<DartType> para
meterTypes) { | 5507 FunctionTypeImpl substitute2(List<DartType> argumentTypes, List<DartType> para
meterTypes) { |
| 5497 if (argumentTypes.length != parameterTypes.length) { | 5508 if (argumentTypes.length != parameterTypes.length) { |
| 5498 throw new IllegalArgumentException("argumentTypes.length (${argumentTypes.
length}) != parameterTypes.length (${parameterTypes.length})"); | 5509 throw new IllegalArgumentException("argumentTypes.length (${argumentTypes.
length}) != parameterTypes.length (${parameterTypes.length})"); |
| (...skipping 1660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7159 @override | 7170 @override |
| 7160 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) { | 7171 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) { |
| 7161 // | 7172 // |
| 7162 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S | 7173 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S |
| 7163 // | 7174 // |
| 7164 if (type.isDynamic) { | 7175 if (type.isDynamic) { |
| 7165 return true; | 7176 return true; |
| 7166 } else if (type is TypeParameterType) { | 7177 } else if (type is TypeParameterType) { |
| 7167 return false; | 7178 return false; |
| 7168 } else if (type is FunctionType) { | 7179 } else if (type is FunctionType) { |
| 7180 // This implementation assumes transitivity |
| 7181 // for function type subtyping on the RHS, but a literal reading |
| 7182 // of the spec does not specify this. More precisely: if T <: F1 and F1 <:
F2 and |
| 7183 // F1 and F2 are function types, then we assume T <: F2. |
| 7184 // |
| 7185 // From the Function Types section of the spec: |
| 7186 // |
| 7187 // If a type I includes an instance method named call(), and the type of
call() |
| 7188 // is the function type F, then I is considered to be a subtype of F. |
| 7189 // |
| 7190 // However, the section on Interface Types says |
| 7191 // |
| 7192 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S. |
| 7193 // |
| 7194 // after giving rules for << (pronounced "more specific than"). However, t
he "only if" |
| 7195 // direction of the "iff" |
| 7196 // in the definition of <: seems to be contradicted by the special case <:
rule |
| 7197 // quoted from the Function Types section: I see no rule for << which tell
s us that |
| 7198 // I << F if I has call() at type F. |
| 7199 // |
| 7200 // After defining <: , the spec then |
| 7201 // emphasizes that unlike the relation <<, the relation <: is not transiti
ve in general: |
| 7202 // |
| 7203 // Note that <: is not a partial order on types, it is only binary relat
ion on types. |
| 7204 // This is because <: is not transitive. If it was, the subtype rule wou
ld have a cycle. |
| 7205 // For example: List <: List<String> and List<int> <: List, but List<int
> is not a subtype |
| 7206 // of List<String>. Although <: is not a partial order on types, it does
contain a partial |
| 7207 // order, namely <<. This means that, barring raw types, intuition about
classical subtype |
| 7208 // rules does apply. |
| 7209 // |
| 7210 // There is no other occurrence of the word "raw" in relation to types in
the spec that I can |
| 7211 // find, but presumably it's a reference to |
| 7212 // |
| 7213 // http://docs.oracle.com/javase/tutorial/java/generics/rawTypes.html |
| 7214 // |
| 7215 // so e.g. non-generic types are never raw. As pointed out by paulberry, i
t's not clear |
| 7216 // whether a type like T<int, dynamic> should be considered raw or not. On
the one hand, it |
| 7217 // doesn't correspond to a "raw"-in-the-Java-sense occurrence of T, which
would instead |
| 7218 // be T<dynamic, dynamic>; on the other hand, it's treated differently by
<: and << when |
| 7219 // occurring on the left hand side. |
| 7169 ClassElement element = this.element; | 7220 ClassElement element = this.element; |
| 7170 MethodElement callMethod = element.lookUpMethod("call", element.library); | 7221 InheritanceManager manager = new InheritanceManager(element.library); |
| 7171 if (callMethod != null) { | 7222 FunctionType callType = manager.lookupMemberType(this, "call"); |
| 7172 return callMethod.type.isSubtypeOf(type); | 7223 if (callType != null) { |
| 7224 // A more literal reading of the spec would give something like |
| 7225 // |
| 7226 // return callType.equals(type) |
| 7227 // |
| 7228 // here, but that causes 101 errors in the external tests |
| 7229 // (tools/test.py --mode release --compiler dartanalyzer --runtime none)
. |
| 7230 return callType.isSubtypeOf(type); |
| 7173 } | 7231 } |
| 7174 return false; | 7232 return false; |
| 7175 } else if (type is! InterfaceType) { | 7233 } else if (type is! InterfaceType) { |
| 7176 return false; | 7234 return false; |
| 7177 } else if (this == type) { | 7235 } else if (this == type) { |
| 7178 return true; | 7236 return true; |
| 7179 } | 7237 } |
| 7180 return _isSubtypeOf(type as InterfaceType, new HashSet<ClassElement>(), visi
tedTypePairs); | 7238 return _isSubtypeOf(type as InterfaceType, new HashSet<ClassElement>(), visi
tedTypePairs); |
| 7181 } | 7239 } |
| 7182 | 7240 |
| (...skipping 2561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9744 void set static(bool isStatic) { | 9802 void set static(bool isStatic) { |
| 9745 setModifier(Modifier.STATIC, isStatic); | 9803 setModifier(Modifier.STATIC, isStatic); |
| 9746 } | 9804 } |
| 9747 | 9805 |
| 9748 @override | 9806 @override |
| 9749 void appendTo(JavaStringBuilder builder) { | 9807 void appendTo(JavaStringBuilder builder) { |
| 9750 builder.append(isGetter ? "get " : "set "); | 9808 builder.append(isGetter ? "get " : "set "); |
| 9751 builder.append(variable.displayName); | 9809 builder.append(variable.displayName); |
| 9752 super.appendTo(builder); | 9810 super.appendTo(builder); |
| 9753 } | 9811 } |
| 9812 |
| 9813 @override |
| 9814 String get identifier { |
| 9815 String name = displayName; |
| 9816 String suffix = isGetter ? "?" : "="; |
| 9817 return "${name}${suffix}"; |
| 9818 } |
| 9754 } | 9819 } |
| 9755 | 9820 |
| 9756 /** | 9821 /** |
| 9757 * Instances of the class `PropertyAccessorMember` represent a property accessor
element | 9822 * Instances of the class `PropertyAccessorMember` represent a property accessor
element |
| 9758 * defined in a parameterized type where the values of the type parameters are k
nown. | 9823 * defined in a parameterized type where the values of the type parameters are k
nown. |
| 9759 */ | 9824 */ |
| 9760 class PropertyAccessorMember extends ExecutableMember implements PropertyAccesso
rElement { | 9825 class PropertyAccessorMember extends ExecutableMember implements PropertyAccesso
rElement { |
| 9761 /** | 9826 /** |
| 9762 * If the given property accessor's type is different when any type parameters
from the defining | 9827 * If the given property accessor's type is different when any type parameters
from the defining |
| 9763 * type's declaration are replaced with the actual type arguments from the def
ining type, create a | 9828 * type's declaration are replaced with the actual type arguments from the def
ining type, create a |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10476 | 10541 |
| 10477 @override | 10542 @override |
| 10478 DartType getLeastUpperBound(DartType type) => null; | 10543 DartType getLeastUpperBound(DartType type) => null; |
| 10479 | 10544 |
| 10480 @override | 10545 @override |
| 10481 bool isAssignableTo(DartType type) => isAssignableTo2(type, new HashSet<TypeIm
pl_TypePair>()); | 10546 bool isAssignableTo(DartType type) => isAssignableTo2(type, new HashSet<TypeIm
pl_TypePair>()); |
| 10482 | 10547 |
| 10483 /** | 10548 /** |
| 10484 * Return `true` if this type is assignable to the given type. A type <i>T</i>
may be | 10549 * Return `true` if this type is assignable to the given type. A type <i>T</i>
may be |
| 10485 * assigned to a type <i>S</i>, written <i>T</i> ⇔ <i>S</i>, iff either <
i>T</i> <: <i>S</i> | 10550 * assigned to a type <i>S</i>, written <i>T</i> ⇔ <i>S</i>, iff either <
i>T</i> <: <i>S</i> |
| 10486 * or <i>S</i> <: <i>T</i>. | 10551 * or <i>S</i> <: <i>T</i> (Interface Types section of spec). |
| 10487 * | 10552 * |
| 10488 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method | 10553 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method |
| 10489 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is | 10554 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is |
| 10490 * used to prevent infinite loops. | 10555 * used to prevent infinite loops. |
| 10491 * | 10556 * |
| 10492 * @param type the type being compared with this type | 10557 * @param type the type being compared with this type |
| 10493 * @param visitedPairs the set of pairs of types used to prevent infinite loop
s | 10558 * @param visitedTypePairs the set of pairs of types used to prevent infinite
loops |
| 10494 * @return `true` if this type is assignable to the given type | 10559 * @return `true` if this type is assignable to the given type |
| 10495 */ | 10560 */ |
| 10496 bool isAssignableTo2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) =
> isSubtypeOf2(type, visitedTypePairs) || (type as TypeImpl).isSubtypeOf2(this,
visitedTypePairs); | 10561 bool isAssignableTo2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) =
> isSubtypeOf2(type, visitedTypePairs) || (type as TypeImpl).isSubtypeOf2(this,
visitedTypePairs); |
| 10497 | 10562 |
| 10498 @override | 10563 @override |
| 10499 bool get isBottom => false; | 10564 bool get isBottom => false; |
| 10500 | 10565 |
| 10501 @override | 10566 @override |
| 10502 bool get isDartCoreFunction => false; | 10567 bool get isDartCoreFunction => false; |
| 10503 | 10568 |
| 10504 @override | 10569 @override |
| 10505 bool get isDynamic => false; | 10570 bool get isDynamic => false; |
| 10506 | 10571 |
| 10507 @override | 10572 @override |
| 10508 bool isMoreSpecificThan(DartType type) => isMoreSpecificThan2(type, false, new
HashSet<TypeImpl_TypePair>()); | 10573 bool isMoreSpecificThan(DartType type) => isMoreSpecificThan2(type, false, new
HashSet<TypeImpl_TypePair>()); |
| 10509 | 10574 |
| 10510 /** | 10575 /** |
| 10511 * Return `true` if this type is more specific than the given type. | 10576 * Return `true` if this type is more specific than the given type. |
| 10512 * | 10577 * |
| 10513 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method | 10578 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method |
| 10514 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is | 10579 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is |
| 10515 * used to prevent infinite loops. | 10580 * used to prevent infinite loops. |
| 10516 * | 10581 * |
| 10517 * @param type the type being compared with this type | 10582 * @param type the type being compared with this type |
| 10518 * @param withDynamic `true` if "dynamic" should be considered as a subtype of
any type | 10583 * @param withDynamic `true` if "dynamic" should be considered as a subtype of
any type |
| 10519 * @param visitedPairs the set of pairs of types used to prevent infinite loop
s | 10584 * @param visitedTypePairs the set of pairs of types used to prevent infinite
loops |
| 10520 * @return `true` if this type is more specific than the given type | 10585 * @return `true` if this type is more specific than the given type |
| 10521 */ | 10586 */ |
| 10522 bool isMoreSpecificThan2(DartType type, bool withDynamic, Set<TypeImpl_TypePai
r> visitedTypePairs) { | 10587 bool isMoreSpecificThan2(DartType type, bool withDynamic, Set<TypeImpl_TypePai
r> visitedTypePairs) { |
| 10523 // If the visitedTypePairs already has the pair (this, type), return false | 10588 // If the visitedTypePairs already has the pair (this, type), return false |
| 10524 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); | 10589 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); |
| 10525 if (!visitedTypePairs.add(typePair)) { | 10590 if (!visitedTypePairs.add(typePair)) { |
| 10526 return false; | 10591 return false; |
| 10527 } | 10592 } |
| 10528 bool result = internalIsMoreSpecificThan(type, withDynamic, visitedTypePairs
); | 10593 bool result = internalIsMoreSpecificThan(type, withDynamic, visitedTypePairs
); |
| 10529 visitedTypePairs.remove(typePair); | 10594 visitedTypePairs.remove(typePair); |
| 10530 return result; | 10595 return result; |
| 10531 } | 10596 } |
| 10532 | 10597 |
| 10533 @override | 10598 @override |
| 10534 bool get isObject => false; | 10599 bool get isObject => false; |
| 10535 | 10600 |
| 10536 @override | 10601 @override |
| 10537 bool isSubtypeOf(DartType type) => isSubtypeOf2(type, new HashSet<TypeImpl_Typ
ePair>()); | 10602 bool isSubtypeOf(DartType type) => isSubtypeOf2(type, new HashSet<TypeImpl_Typ
ePair>()); |
| 10538 | 10603 |
| 10539 /** | 10604 /** |
| 10540 * Return `true` if this type is a subtype of the given type. | 10605 * Return `true` if this type is a subtype of the given type. |
| 10541 * | 10606 * |
| 10542 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method | 10607 * The given set of pairs of types (T1, T2), where each pair indicates that we
invoked this method |
| 10543 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is | 10608 * because we are in the process of answering the question of whether T1 is a
subtype of T2, is |
| 10544 * used to prevent infinite loops. | 10609 * used to prevent infinite loops. |
| 10545 * | 10610 * |
| 10546 * @param type the type being compared with this type | 10611 * @param type the type being compared with this type |
| 10547 * @param visitedPairs the set of pairs of types used to prevent infinite loop
s | 10612 * @param visitedTypePairs the set of pairs of types used to prevent infinite
loops |
| 10548 * @return `true` if this type is a subtype of the given type | 10613 * @return `true` if this type is a subtype of the given type |
| 10549 */ | 10614 */ |
| 10550 bool isSubtypeOf2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { | 10615 bool isSubtypeOf2(DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10551 // If the visitedTypePairs already has the pair (this, type), return false | 10616 // If the visitedTypePairs already has the pair (this, type), return false |
| 10552 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); | 10617 TypeImpl_TypePair typePair = new TypeImpl_TypePair(this, type); |
| 10553 if (!visitedTypePairs.add(typePair)) { | 10618 if (!visitedTypePairs.add(typePair)) { |
| 10554 return false; | 10619 return false; |
| 10555 } | 10620 } |
| 10556 bool result = internalIsSubtypeOf(type, visitedTypePairs); | 10621 bool result = internalIsSubtypeOf(type, visitedTypePairs); |
| 10557 visitedTypePairs.remove(typePair); | 10622 visitedTypePairs.remove(typePair); |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11189 | 11254 |
| 11190 @override | 11255 @override |
| 11191 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id
entical(object, this); | 11256 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => id
entical(object, this); |
| 11192 | 11257 |
| 11193 @override | 11258 @override |
| 11194 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) => isSubtypeOf(type); | 11259 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, Set<TypeImpl_
TypePair> visitedTypePairs) => isSubtypeOf(type); |
| 11195 | 11260 |
| 11196 @override | 11261 @override |
| 11197 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) => identical(type, this) || identical(type, DynamicTypeImpl.instance); | 11262 bool internalIsSubtypeOf(DartType type, Set<TypeImpl_TypePair> visitedTypePair
s) => identical(type, this) || identical(type, DynamicTypeImpl.instance); |
| 11198 } | 11263 } |
| OLD | NEW |