| 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 | 11 |
| 12 import 'package:analyzer/src/generated/utilities_general.dart'; | 12 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 13 | 13 |
| 14 import 'ast.dart'; | 14 import 'ast.dart'; |
| 15 import 'constant.dart' show EvaluationResultImpl; | 15 import 'constant.dart' show EvaluationResultImpl; |
| 16 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; | 16 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; |
| 17 import 'html.dart' show XmlAttributeNode, XmlTagNode; | 17 import 'html.dart' show XmlAttributeNode, XmlTagNode; |
| 18 import 'java_core.dart'; | 18 import 'java_core.dart'; |
| 19 import 'java_engine.dart'; | 19 import 'java_engine.dart'; |
| 20 import 'resolver.dart'; | 20 import 'resolver.dart'; |
| 21 import 'scanner.dart' show Keyword; | 21 import 'scanner.dart' show Keyword; |
| 22 import 'sdk.dart' show DartSdk; | 22 import 'sdk.dart' show DartSdk; |
| 23 import 'source.dart'; | 23 import 'source.dart'; |
| 24 import 'utilities_collection.dart'; | 24 import 'utilities_collection.dart'; |
| 25 import 'utilities_dart.dart'; | 25 import 'utilities_dart.dart'; |
| 26 | 26 |
| 27 | |
| 28 /** | 27 /** |
| 29 * For AST nodes that could be in both the getter and setter contexts ([IndexExp
ression]s and | 28 * For AST nodes that could be in both the getter and setter contexts ([IndexExp
ression]s and |
| 30 * [SimpleIdentifier]s), the additional resolved elements are stored in the AST
node, in an | 29 * [SimpleIdentifier]s), the additional resolved elements are stored in the AST
node, in an |
| 31 * [AuxiliaryElements]. Since resolved elements are either statically resolved o
r resolved | 30 * [AuxiliaryElements]. Since resolved elements are either statically resolved o
r resolved |
| 32 * using propagated type information, this class is a wrapper for a pair of | 31 * using propagated type information, this class is a wrapper for a pair of |
| 33 * [ExecutableElement]s, not just a single [ExecutableElement]. | 32 * [ExecutableElement]s, not just a single [ExecutableElement]. |
| 34 */ | 33 */ |
| 35 class AuxiliaryElements { | 34 class AuxiliaryElements { |
| 36 /** | 35 /** |
| 37 * The element based on propagated type information, or `null` if the AST stru
cture has not | 36 * The element based on propagated type information, or `null` if the AST stru
cture has not |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 85 |
| 87 @override | 86 @override |
| 88 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => | 87 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => |
| 89 identical(object, this); | 88 identical(object, this); |
| 90 | 89 |
| 91 @override | 90 @override |
| 92 int internalHashCode(List<DartType> visitedTypes) => hashCode; | 91 int internalHashCode(List<DartType> visitedTypes) => hashCode; |
| 93 | 92 |
| 94 @override | 93 @override |
| 95 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, | 94 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, |
| 96 Set<TypeImpl_TypePair> visitedTypePairs) => | 95 Set<TypeImpl_TypePair> visitedTypePairs) => true; |
| 97 true; | |
| 98 | 96 |
| 99 @override | 97 @override |
| 100 bool internalIsSubtypeOf(DartType type, | 98 bool internalIsSubtypeOf( |
| 101 Set<TypeImpl_TypePair> visitedTypePairs) => | 99 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) => true; |
| 102 true; | |
| 103 | 100 |
| 104 @override | 101 @override |
| 105 bool isSupertypeOf(DartType type) => false; | 102 bool isSupertypeOf(DartType type) => false; |
| 106 | 103 |
| 107 @override | 104 @override |
| 108 BottomTypeImpl substitute2(List<DartType> argumentTypes, | 105 BottomTypeImpl substitute2( |
| 109 List<DartType> parameterTypes) => | 106 List<DartType> argumentTypes, List<DartType> parameterTypes) => this; |
| 110 this; | |
| 111 } | 107 } |
| 112 | 108 |
| 113 /** | 109 /** |
| 114 * The interface `ClassElement` defines the behavior of elements that represent
a class. | 110 * The interface `ClassElement` defines the behavior of elements that represent
a class. |
| 115 */ | 111 */ |
| 116 abstract class ClassElement implements Element { | 112 abstract class ClassElement implements Element { |
| 117 /** | 113 /** |
| 118 * Return an array containing all of the accessors (getters and setters) decla
red in this class. | 114 * Return an array containing all of the accessors (getters and setters) decla
red in this class. |
| 119 * | 115 * |
| 120 * @return the accessors declared in this class | 116 * @return the accessors declared in this class |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 373 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result |
| 378 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 374 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. |
| 379 * Otherwise, we say that the lookup has failed. | 375 * Otherwise, we say that the lookup has failed. |
| 380 * </blockquote> | 376 * </blockquote> |
| 381 * | 377 * |
| 382 * @param getterName the name of the getter being looked up | 378 * @param getterName the name of the getter being looked up |
| 383 * @param library the library with respect to which the lookup is being perfor
med | 379 * @param library the library with respect to which the lookup is being perfor
med |
| 384 * @return the result of looking up the given getter in this class with respec
t to the given | 380 * @return the result of looking up the given getter in this class with respec
t to the given |
| 385 * library | 381 * library |
| 386 */ | 382 */ |
| 387 PropertyAccessorElement lookUpGetter(String getterName, | 383 PropertyAccessorElement lookUpGetter( |
| 388 LibraryElement library); | 384 String getterName, LibraryElement library); |
| 389 | 385 |
| 390 /** | 386 /** |
| 391 * Return the element representing the getter that results from looking up the
given getter in the | 387 * Return the element representing the getter that results from looking up the
given getter in the |
| 392 * superclass of this class with respect to the given library, ignoring abstra
ct getters, or | 388 * superclass of this class with respect to the given library, ignoring abstra
ct getters, or |
| 393 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language | 389 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language |
| 394 * Specification in section 12.15.1: <blockquote>The result of looking up gett
er (respectively | 390 * Specification in section 12.15.1: <blockquote>The result of looking up gett
er (respectively |
| 395 * setter) <i>m</i> in class <i>C</i> with respect to library <i>L</i> is: | 391 * setter) <i>m</i> in class <i>C</i> with respect to library <i>L</i> is: |
| 396 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 392 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is |
| 397 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 393 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. |
| 398 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 394 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result |
| 399 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 395 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. |
| 400 * Otherwise, we say that the lookup has failed. | 396 * Otherwise, we say that the lookup has failed. |
| 401 * </blockquote> | 397 * </blockquote> |
| 402 * | 398 * |
| 403 * @param getterName the name of the getter being looked up | 399 * @param getterName the name of the getter being looked up |
| 404 * @param library the library with respect to which the lookup is being perfor
med | 400 * @param library the library with respect to which the lookup is being perfor
med |
| 405 * @return the result of looking up the given getter in this class with respec
t to the given | 401 * @return the result of looking up the given getter in this class with respec
t to the given |
| 406 * library | 402 * library |
| 407 */ | 403 */ |
| 408 PropertyAccessorElement lookUpInheritedConcreteGetter(String getterName, | 404 PropertyAccessorElement lookUpInheritedConcreteGetter( |
| 409 LibraryElement library); | 405 String getterName, LibraryElement library); |
| 410 | 406 |
| 411 /** | 407 /** |
| 412 * Return the element representing the method that results from looking up the
given method in the | 408 * Return the element representing the method that results from looking up the
given method in the |
| 413 * superclass of this class with respect to the given library, ignoring abstra
ct methods, or | 409 * superclass of this class with respect to the given library, ignoring abstra
ct methods, or |
| 414 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language | 410 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language |
| 415 * Specification in section 12.15.1: <blockquote> The result of looking up met
hod <i>m</i> in | 411 * Specification in section 12.15.1: <blockquote> The result of looking up met
hod <i>m</i> in |
| 416 * class <i>C</i> with respect to library <i>L</i> is: | 412 * class <i>C</i> with respect to library <i>L</i> is: |
| 417 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | 413 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then |
| 418 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 414 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then |
| 419 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 415 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect |
| 420 * to <i>L</i>. Otherwise, we say that the lookup has failed. | 416 * to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 421 * </blockquote> | 417 * </blockquote> |
| 422 * | 418 * |
| 423 * @param methodName the name of the method being looked up | 419 * @param methodName the name of the method being looked up |
| 424 * @param library the library with respect to which the lookup is being perfor
med | 420 * @param library the library with respect to which the lookup is being perfor
med |
| 425 * @return the result of looking up the given method in the superclass of this
class with respect | 421 * @return the result of looking up the given method in the superclass of this
class with respect |
| 426 * to the given library | 422 * to the given library |
| 427 */ | 423 */ |
| 428 MethodElement lookUpInheritedConcreteMethod(String methodName, | 424 MethodElement lookUpInheritedConcreteMethod( |
| 429 LibraryElement library); | 425 String methodName, LibraryElement library); |
| 430 | 426 |
| 431 /** | 427 /** |
| 432 * Return the element representing the setter that results from looking up the
given setter in the | 428 * Return the element representing the setter that results from looking up the
given setter in the |
| 433 * superclass of this class with respect to the given library, ignoring abstra
ct setters, or | 429 * superclass of this class with respect to the given library, ignoring abstra
ct setters, or |
| 434 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language | 430 * `null` if the look up fails. The behavior of this method is defined by the
Dart Language |
| 435 * Specification in section 12.16: <blockquote> The result of looking up gette
r (respectively | 431 * Specification in section 12.16: <blockquote> The result of looking up gette
r (respectively |
| 436 * setter) <i>m</i> in class <i>C</i> with respect to library <i>L</i> is: | 432 * setter) <i>m</i> in class <i>C</i> with respect to library <i>L</i> is: |
| 437 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 433 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is |
| 438 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 434 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. |
| 439 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 435 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result |
| 440 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 436 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. |
| 441 * Otherwise, we say that the lookup has failed. | 437 * Otherwise, we say that the lookup has failed. |
| 442 * </blockquote> | 438 * </blockquote> |
| 443 * | 439 * |
| 444 * @param setterName the name of the setter being looked up | 440 * @param setterName the name of the setter being looked up |
| 445 * @param library the library with respect to which the lookup is being perfor
med | 441 * @param library the library with respect to which the lookup is being perfor
med |
| 446 * @return the result of looking up the given setter in this class with respec
t to the given | 442 * @return the result of looking up the given setter in this class with respec
t to the given |
| 447 * library | 443 * library |
| 448 */ | 444 */ |
| 449 PropertyAccessorElement lookUpInheritedConcreteSetter(String setterName, | 445 PropertyAccessorElement lookUpInheritedConcreteSetter( |
| 450 LibraryElement library); | 446 String setterName, LibraryElement library); |
| 451 | 447 |
| 452 /** | 448 /** |
| 453 * Return the element representing the method that results from looking up the
given method in the | 449 * Return the element representing the method that results from looking up the
given method in the |
| 454 * superclass of this class with respect to the given library, or `null` if th
e look up | 450 * superclass of this class with respect to the given library, or `null` if th
e look up |
| 455 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | 451 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section |
| 456 * 12.15.1: <blockquote> The result of looking up method <i>m</i> in class <i>
C</i> with respect | 452 * 12.15.1: <blockquote> The result of looking up method <i>m</i> in class <i>
C</i> with respect |
| 457 * to library <i>L</i> is: | 453 * to library <i>L</i> is: |
| 458 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | 454 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then |
| 459 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 455 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then |
| 460 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 456 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect |
| 461 * to <i>L</i>. Otherwise, we say that the lookup has failed. | 457 * to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 462 * </blockquote> | 458 * </blockquote> |
| 463 * | 459 * |
| 464 * @param methodName the name of the method being looked up | 460 * @param methodName the name of the method being looked up |
| 465 * @param library the library with respect to which the lookup is being perfor
med | 461 * @param library the library with respect to which the lookup is being perfor
med |
| 466 * @return the result of looking up the given method in the superclass of this
class with respect | 462 * @return the result of looking up the given method in the superclass of this
class with respect |
| 467 * to the given library | 463 * to the given library |
| 468 */ | 464 */ |
| 469 MethodElement lookUpInheritedMethod(String methodName, | 465 MethodElement lookUpInheritedMethod( |
| 470 LibraryElement library); | 466 String methodName, LibraryElement library); |
| 471 | 467 |
| 472 /** | 468 /** |
| 473 * Return the element representing the method that results from looking up the
given method in | 469 * Return the element representing the method that results from looking up the
given method in |
| 474 * this class with respect to the given library, or `null` if the look up fail
s. The | 470 * this class with respect to the given library, or `null` if the look up fail
s. The |
| 475 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | 471 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: |
| 476 * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> wit
h respect to library | 472 * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> wit
h respect to library |
| 477 * <i>L</i> is: | 473 * <i>L</i> is: |
| 478 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | 474 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then |
| 479 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 475 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then |
| 480 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 476 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect |
| (...skipping 18 matching lines...) Expand all Loading... |
| 499 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 495 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result |
| 500 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 496 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. |
| 501 * Otherwise, we say that the lookup has failed. | 497 * Otherwise, we say that the lookup has failed. |
| 502 * </blockquote> | 498 * </blockquote> |
| 503 * | 499 * |
| 504 * @param setterName the name of the setter being looked up | 500 * @param setterName the name of the setter being looked up |
| 505 * @param library the library with respect to which the lookup is being perfor
med | 501 * @param library the library with respect to which the lookup is being perfor
med |
| 506 * @return the result of looking up the given setter in this class with respec
t to the given | 502 * @return the result of looking up the given setter in this class with respec
t to the given |
| 507 * library | 503 * library |
| 508 */ | 504 */ |
| 509 PropertyAccessorElement lookUpSetter(String setterName, | 505 PropertyAccessorElement lookUpSetter( |
| 510 LibraryElement library); | 506 String setterName, LibraryElement library); |
| 511 } | 507 } |
| 512 | 508 |
| 513 /** | 509 /** |
| 514 * Instances of the class `ClassElementImpl` implement a `ClassElement`. | 510 * Instances of the class `ClassElementImpl` implement a `ClassElement`. |
| 515 */ | 511 */ |
| 516 class ClassElementImpl extends ElementImpl implements ClassElement { | 512 class ClassElementImpl extends ElementImpl implements ClassElement { |
| 517 /** | 513 /** |
| 518 * An empty list of class elements. | 514 * An empty list of class elements. |
| 519 */ | 515 */ |
| 520 static const List<ClassElement> EMPTY_ARRAY = const <ClassElement>[]; | 516 static const List<ClassElement> EMPTY_ARRAY = const <ClassElement>[]; |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 // accessible (see dartbug.com/19576). | 942 // accessible (see dartbug.com/19576). |
| 947 for (ParameterElement parameter in constructor.parameters) { | 943 for (ParameterElement parameter in constructor.parameters) { |
| 948 if (parameter.parameterKind != ParameterKind.REQUIRED) { | 944 if (parameter.parameterKind != ParameterKind.REQUIRED) { |
| 949 return false; | 945 return false; |
| 950 } | 946 } |
| 951 } | 947 } |
| 952 return true; | 948 return true; |
| 953 } | 949 } |
| 954 | 950 |
| 955 @override | 951 @override |
| 956 MethodElement lookUpConcreteMethod(String methodName, | 952 MethodElement lookUpConcreteMethod( |
| 957 LibraryElement library) => | 953 String methodName, LibraryElement library) => |
| 958 _internalLookUpConcreteMethod(methodName, library, true); | 954 _internalLookUpConcreteMethod(methodName, library, true); |
| 959 | 955 |
| 960 @override | 956 @override |
| 961 PropertyAccessorElement lookUpGetter(String getterName, | 957 PropertyAccessorElement lookUpGetter( |
| 962 LibraryElement library) => | 958 String getterName, LibraryElement library) => |
| 963 _internalLookUpGetter(getterName, library, true); | 959 _internalLookUpGetter(getterName, library, true); |
| 964 | 960 |
| 965 @override | 961 @override |
| 966 PropertyAccessorElement lookUpInheritedConcreteGetter(String getterName, | 962 PropertyAccessorElement lookUpInheritedConcreteGetter( |
| 967 LibraryElement library) => | 963 String getterName, LibraryElement library) => |
| 968 _internalLookUpConcreteGetter(getterName, library, false); | 964 _internalLookUpConcreteGetter(getterName, library, false); |
| 969 | 965 |
| 970 @override | 966 @override |
| 971 MethodElement lookUpInheritedConcreteMethod(String methodName, | 967 MethodElement lookUpInheritedConcreteMethod( |
| 972 LibraryElement library) => | 968 String methodName, LibraryElement library) => |
| 973 _internalLookUpConcreteMethod(methodName, library, false); | 969 _internalLookUpConcreteMethod(methodName, library, false); |
| 974 | 970 |
| 975 @override | 971 @override |
| 976 PropertyAccessorElement lookUpInheritedConcreteSetter(String setterName, | 972 PropertyAccessorElement lookUpInheritedConcreteSetter( |
| 977 LibraryElement library) => | 973 String setterName, LibraryElement library) => |
| 978 _internalLookUpConcreteSetter(setterName, library, false); | 974 _internalLookUpConcreteSetter(setterName, library, false); |
| 979 | 975 |
| 980 @override | 976 @override |
| 981 MethodElement lookUpInheritedMethod(String methodName, | 977 MethodElement lookUpInheritedMethod( |
| 982 LibraryElement library) => | 978 String methodName, LibraryElement library) => |
| 983 _internalLookUpMethod(methodName, library, false); | 979 _internalLookUpMethod(methodName, library, false); |
| 984 | 980 |
| 985 @override | 981 @override |
| 986 MethodElement lookUpMethod(String methodName, LibraryElement library) => | 982 MethodElement lookUpMethod(String methodName, LibraryElement library) => |
| 987 _internalLookUpMethod(methodName, library, true); | 983 _internalLookUpMethod(methodName, library, true); |
| 988 | 984 |
| 989 @override | 985 @override |
| 990 PropertyAccessorElement lookUpSetter(String setterName, | 986 PropertyAccessorElement lookUpSetter( |
| 991 LibraryElement library) => | 987 String setterName, LibraryElement library) => |
| 992 _internalLookUpSetter(setterName, library, true); | 988 _internalLookUpSetter(setterName, library, true); |
| 993 | 989 |
| 994 @override | 990 @override |
| 995 void visitChildren(ElementVisitor visitor) { | 991 void visitChildren(ElementVisitor visitor) { |
| 996 super.visitChildren(visitor); | 992 super.visitChildren(visitor); |
| 997 safelyVisitChildren(_accessors, visitor); | 993 safelyVisitChildren(_accessors, visitor); |
| 998 safelyVisitChildren(_constructors, visitor); | 994 safelyVisitChildren(_constructors, visitor); |
| 999 safelyVisitChildren(_fields, visitor); | 995 safelyVisitChildren(_fields, visitor); |
| 1000 safelyVisitChildren(_methods, visitor); | 996 safelyVisitChildren(_methods, visitor); |
| 1001 safelyVisitChildren(_typeParameters, visitor); | 997 safelyVisitChildren(_typeParameters, visitor); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1023 for (InterfaceType type in currentElement.mixins) { | 1019 for (InterfaceType type in currentElement.mixins) { |
| 1024 ClassElement element = type.element; | 1020 ClassElement element = type.element; |
| 1025 if (!visitedClasses.contains(element)) { | 1021 if (!visitedClasses.contains(element)) { |
| 1026 supertypes.add(type); | 1022 supertypes.add(type); |
| 1027 } | 1023 } |
| 1028 } | 1024 } |
| 1029 } | 1025 } |
| 1030 } | 1026 } |
| 1031 } | 1027 } |
| 1032 | 1028 |
| 1033 PropertyAccessorElement _internalLookUpConcreteGetter(String getterName, | 1029 PropertyAccessorElement _internalLookUpConcreteGetter( |
| 1034 LibraryElement library, bool includeThisClass) { | 1030 String getterName, LibraryElement library, bool includeThisClass) { |
| 1035 PropertyAccessorElement getter = | 1031 PropertyAccessorElement getter = |
| 1036 _internalLookUpGetter(getterName, library, includeThisClass); | 1032 _internalLookUpGetter(getterName, library, includeThisClass); |
| 1037 while (getter != null && getter.isAbstract) { | 1033 while (getter != null && getter.isAbstract) { |
| 1038 Element definingClass = getter.enclosingElement; | 1034 Element definingClass = getter.enclosingElement; |
| 1039 if (definingClass is! ClassElementImpl) { | 1035 if (definingClass is! ClassElementImpl) { |
| 1040 return null; | 1036 return null; |
| 1041 } | 1037 } |
| 1042 getter = (definingClass as ClassElementImpl)._internalLookUpGetter( | 1038 getter = (definingClass as ClassElementImpl)._internalLookUpGetter( |
| 1043 getterName, | 1039 getterName, library, false); |
| 1044 library, | |
| 1045 false); | |
| 1046 } | 1040 } |
| 1047 return getter; | 1041 return getter; |
| 1048 } | 1042 } |
| 1049 | 1043 |
| 1050 MethodElement _internalLookUpConcreteMethod(String methodName, | 1044 MethodElement _internalLookUpConcreteMethod( |
| 1051 LibraryElement library, bool includeThisClass) { | 1045 String methodName, LibraryElement library, bool includeThisClass) { |
| 1052 MethodElement method = | 1046 MethodElement method = |
| 1053 _internalLookUpMethod(methodName, library, includeThisClass); | 1047 _internalLookUpMethod(methodName, library, includeThisClass); |
| 1054 while (method != null && method.isAbstract) { | 1048 while (method != null && method.isAbstract) { |
| 1055 ClassElement definingClass = method.enclosingElement; | 1049 ClassElement definingClass = method.enclosingElement; |
| 1056 if (definingClass == null) { | 1050 if (definingClass == null) { |
| 1057 return null; | 1051 return null; |
| 1058 } | 1052 } |
| 1059 method = definingClass.lookUpInheritedMethod(methodName, library); | 1053 method = definingClass.lookUpInheritedMethod(methodName, library); |
| 1060 } | 1054 } |
| 1061 return method; | 1055 return method; |
| 1062 } | 1056 } |
| 1063 | 1057 |
| 1064 PropertyAccessorElement _internalLookUpConcreteSetter(String setterName, | 1058 PropertyAccessorElement _internalLookUpConcreteSetter( |
| 1065 LibraryElement library, bool includeThisClass) { | 1059 String setterName, LibraryElement library, bool includeThisClass) { |
| 1066 PropertyAccessorElement setter = | 1060 PropertyAccessorElement setter = |
| 1067 _internalLookUpSetter(setterName, library, includeThisClass); | 1061 _internalLookUpSetter(setterName, library, includeThisClass); |
| 1068 while (setter != null && setter.isAbstract) { | 1062 while (setter != null && setter.isAbstract) { |
| 1069 Element definingClass = setter.enclosingElement; | 1063 Element definingClass = setter.enclosingElement; |
| 1070 if (definingClass is! ClassElementImpl) { | 1064 if (definingClass is! ClassElementImpl) { |
| 1071 return null; | 1065 return null; |
| 1072 } | 1066 } |
| 1073 setter = (definingClass as ClassElementImpl)._internalLookUpSetter( | 1067 setter = (definingClass as ClassElementImpl)._internalLookUpSetter( |
| 1074 setterName, | 1068 setterName, library, false); |
| 1075 library, | |
| 1076 false); | |
| 1077 } | 1069 } |
| 1078 return setter; | 1070 return setter; |
| 1079 } | 1071 } |
| 1080 | 1072 |
| 1081 PropertyAccessorElement _internalLookUpGetter(String getterName, | 1073 PropertyAccessorElement _internalLookUpGetter( |
| 1082 LibraryElement library, bool includeThisClass) { | 1074 String getterName, LibraryElement library, bool includeThisClass) { |
| 1083 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); | 1075 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); |
| 1084 ClassElement currentElement = this; | 1076 ClassElement currentElement = this; |
| 1085 if (includeThisClass) { | 1077 if (includeThisClass) { |
| 1086 PropertyAccessorElement element = currentElement.getGetter(getterName); | 1078 PropertyAccessorElement element = currentElement.getGetter(getterName); |
| 1087 if (element != null && element.isAccessibleIn(library)) { | 1079 if (element != null && element.isAccessibleIn(library)) { |
| 1088 return element; | 1080 return element; |
| 1089 } | 1081 } |
| 1090 } | 1082 } |
| 1091 while (currentElement != null && visitedClasses.add(currentElement)) { | 1083 while (currentElement != null && visitedClasses.add(currentElement)) { |
| 1092 for (InterfaceType mixin in currentElement.mixins.reversed) { | 1084 for (InterfaceType mixin in currentElement.mixins.reversed) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1104 } | 1096 } |
| 1105 currentElement = supertype.element; | 1097 currentElement = supertype.element; |
| 1106 PropertyAccessorElement element = currentElement.getGetter(getterName); | 1098 PropertyAccessorElement element = currentElement.getGetter(getterName); |
| 1107 if (element != null && element.isAccessibleIn(library)) { | 1099 if (element != null && element.isAccessibleIn(library)) { |
| 1108 return element; | 1100 return element; |
| 1109 } | 1101 } |
| 1110 } | 1102 } |
| 1111 return null; | 1103 return null; |
| 1112 } | 1104 } |
| 1113 | 1105 |
| 1114 MethodElement _internalLookUpMethod(String methodName, LibraryElement library, | 1106 MethodElement _internalLookUpMethod( |
| 1115 bool includeThisClass) { | 1107 String methodName, LibraryElement library, bool includeThisClass) { |
| 1116 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); | 1108 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); |
| 1117 ClassElement currentElement = this; | 1109 ClassElement currentElement = this; |
| 1118 if (includeThisClass) { | 1110 if (includeThisClass) { |
| 1119 MethodElement element = currentElement.getMethod(methodName); | 1111 MethodElement element = currentElement.getMethod(methodName); |
| 1120 if (element != null && element.isAccessibleIn(library)) { | 1112 if (element != null && element.isAccessibleIn(library)) { |
| 1121 return element; | 1113 return element; |
| 1122 } | 1114 } |
| 1123 } | 1115 } |
| 1124 while (currentElement != null && visitedClasses.add(currentElement)) { | 1116 while (currentElement != null && visitedClasses.add(currentElement)) { |
| 1125 for (InterfaceType mixin in currentElement.mixins.reversed) { | 1117 for (InterfaceType mixin in currentElement.mixins.reversed) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1137 } | 1129 } |
| 1138 currentElement = supertype.element; | 1130 currentElement = supertype.element; |
| 1139 MethodElement element = currentElement.getMethod(methodName); | 1131 MethodElement element = currentElement.getMethod(methodName); |
| 1140 if (element != null && element.isAccessibleIn(library)) { | 1132 if (element != null && element.isAccessibleIn(library)) { |
| 1141 return element; | 1133 return element; |
| 1142 } | 1134 } |
| 1143 } | 1135 } |
| 1144 return null; | 1136 return null; |
| 1145 } | 1137 } |
| 1146 | 1138 |
| 1147 PropertyAccessorElement _internalLookUpSetter(String setterName, | 1139 PropertyAccessorElement _internalLookUpSetter( |
| 1148 LibraryElement library, bool includeThisClass) { | 1140 String setterName, LibraryElement library, bool includeThisClass) { |
| 1149 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); | 1141 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); |
| 1150 ClassElement currentElement = this; | 1142 ClassElement currentElement = this; |
| 1151 if (includeThisClass) { | 1143 if (includeThisClass) { |
| 1152 PropertyAccessorElement element = currentElement.getSetter(setterName); | 1144 PropertyAccessorElement element = currentElement.getSetter(setterName); |
| 1153 if (element != null && element.isAccessibleIn(library)) { | 1145 if (element != null && element.isAccessibleIn(library)) { |
| 1154 return element; | 1146 return element; |
| 1155 } | 1147 } |
| 1156 } | 1148 } |
| 1157 while (currentElement != null && visitedClasses.add(currentElement)) { | 1149 while (currentElement != null && visitedClasses.add(currentElement)) { |
| 1158 for (InterfaceType mixin in currentElement.mixins.reversed) { | 1150 for (InterfaceType mixin in currentElement.mixins.reversed) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1170 } | 1162 } |
| 1171 currentElement = supertype.element; | 1163 currentElement = supertype.element; |
| 1172 PropertyAccessorElement element = currentElement.getSetter(setterName); | 1164 PropertyAccessorElement element = currentElement.getSetter(setterName); |
| 1173 if (element != null && element.isAccessibleIn(library)) { | 1165 if (element != null && element.isAccessibleIn(library)) { |
| 1174 return element; | 1166 return element; |
| 1175 } | 1167 } |
| 1176 } | 1168 } |
| 1177 return null; | 1169 return null; |
| 1178 } | 1170 } |
| 1179 | 1171 |
| 1180 bool _safeIsOrInheritsProxy(ClassElement classElt, | 1172 bool _safeIsOrInheritsProxy( |
| 1181 HashSet<ClassElement> visitedClassElts) { | 1173 ClassElement classElt, HashSet<ClassElement> visitedClassElts) { |
| 1182 if (visitedClassElts.contains(classElt)) { | 1174 if (visitedClassElts.contains(classElt)) { |
| 1183 return false; | 1175 return false; |
| 1184 } | 1176 } |
| 1185 visitedClassElts.add(classElt); | 1177 visitedClassElts.add(classElt); |
| 1186 if (classElt.isProxy) { | 1178 if (classElt.isProxy) { |
| 1187 return true; | 1179 return true; |
| 1188 } else if (classElt.supertype != null && | 1180 } else if (classElt.supertype != null && |
| 1189 _safeIsOrInheritsProxy(classElt.supertype.element, visitedClassElts)) { | 1181 _safeIsOrInheritsProxy(classElt.supertype.element, visitedClassElts)) { |
| 1190 return true; | 1182 return true; |
| 1191 } | 1183 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1319 * @param className the name of the class to be returned | 1311 * @param className the name of the class to be returned |
| 1320 * @return the class with the given name that is defined in this compilation u
nit | 1312 * @return the class with the given name that is defined in this compilation u
nit |
| 1321 */ | 1313 */ |
| 1322 ClassElement getType(String className); | 1314 ClassElement getType(String className); |
| 1323 } | 1315 } |
| 1324 | 1316 |
| 1325 /** | 1317 /** |
| 1326 * Instances of the class `CompilationUnitElementImpl` implement a | 1318 * Instances of the class `CompilationUnitElementImpl` implement a |
| 1327 * [CompilationUnitElement]. | 1319 * [CompilationUnitElement]. |
| 1328 */ | 1320 */ |
| 1329 class CompilationUnitElementImpl extends UriReferencedElementImpl implements | 1321 class CompilationUnitElementImpl extends UriReferencedElementImpl |
| 1330 CompilationUnitElement { | 1322 implements CompilationUnitElement { |
| 1331 /** | 1323 /** |
| 1332 * An empty list of compilation unit elements. | 1324 * An empty list of compilation unit elements. |
| 1333 */ | 1325 */ |
| 1334 static const List<CompilationUnitElement> EMPTY_ARRAY = const | 1326 static const List<CompilationUnitElement> EMPTY_ARRAY = |
| 1335 <CompilationUnitElement>[ | 1327 const <CompilationUnitElement>[]; |
| 1336 ]; | |
| 1337 | 1328 |
| 1338 /** | 1329 /** |
| 1339 * The source that corresponds to this compilation unit. | 1330 * The source that corresponds to this compilation unit. |
| 1340 */ | 1331 */ |
| 1341 Source source; | 1332 Source source; |
| 1342 | 1333 |
| 1343 /** | 1334 /** |
| 1344 * An array containing all of the top-level accessors (getters and setters) co
ntained in this | 1335 * An array containing all of the top-level accessors (getters and setters) co
ntained in this |
| 1345 * compilation unit. | 1336 * compilation unit. |
| 1346 */ | 1337 */ |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 @override | 1636 @override |
| 1646 void set evaluationResult(EvaluationResultImpl result) { | 1637 void set evaluationResult(EvaluationResultImpl result) { |
| 1647 this._result = result; | 1638 this._result = result; |
| 1648 } | 1639 } |
| 1649 } | 1640 } |
| 1650 | 1641 |
| 1651 /** | 1642 /** |
| 1652 * The interface `ConstructorElement` defines the behavior of elements represent
ing a | 1643 * The interface `ConstructorElement` defines the behavior of elements represent
ing a |
| 1653 * constructor or a factory method defined within a type. | 1644 * constructor or a factory method defined within a type. |
| 1654 */ | 1645 */ |
| 1655 abstract class ConstructorElement implements ClassMemberElement, | 1646 abstract class ConstructorElement |
| 1656 ExecutableElement { | 1647 implements ClassMemberElement, ExecutableElement { |
| 1657 /** | 1648 /** |
| 1658 * Return `true` if this constructor is a const constructor. | 1649 * Return `true` if this constructor is a const constructor. |
| 1659 * | 1650 * |
| 1660 * @return `true` if this constructor is a const constructor | 1651 * @return `true` if this constructor is a const constructor |
| 1661 */ | 1652 */ |
| 1662 bool get isConst; | 1653 bool get isConst; |
| 1663 | 1654 |
| 1664 /** | 1655 /** |
| 1665 * Return `true` if this constructor can be used as a default constructor - un
named and has | 1656 * Return `true` if this constructor can be used as a default constructor - un
named and has |
| 1666 * no required parameters. | 1657 * no required parameters. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 * constructor has not yet been resolved. | 1697 * constructor has not yet been resolved. |
| 1707 * | 1698 * |
| 1708 * @return the constructor to which this constructor is redirecting | 1699 * @return the constructor to which this constructor is redirecting |
| 1709 */ | 1700 */ |
| 1710 ConstructorElement get redirectedConstructor; | 1701 ConstructorElement get redirectedConstructor; |
| 1711 } | 1702 } |
| 1712 | 1703 |
| 1713 /** | 1704 /** |
| 1714 * Instances of the class `ConstructorElementImpl` implement a `ConstructorEleme
nt`. | 1705 * Instances of the class `ConstructorElementImpl` implement a `ConstructorEleme
nt`. |
| 1715 */ | 1706 */ |
| 1716 class ConstructorElementImpl extends ExecutableElementImpl implements | 1707 class ConstructorElementImpl extends ExecutableElementImpl |
| 1717 ConstructorElement { | 1708 implements ConstructorElement { |
| 1718 /** | 1709 /** |
| 1719 * An empty list of constructor elements. | 1710 * An empty list of constructor elements. |
| 1720 */ | 1711 */ |
| 1721 static const List<ConstructorElement> EMPTY_ARRAY = const | 1712 static const List<ConstructorElement> EMPTY_ARRAY = |
| 1722 <ConstructorElement>[ | 1713 const <ConstructorElement>[]; |
| 1723 ]; | |
| 1724 | 1714 |
| 1725 /** | 1715 /** |
| 1726 * The constructor to which this constructor is redirecting. | 1716 * The constructor to which this constructor is redirecting. |
| 1727 */ | 1717 */ |
| 1728 ConstructorElement redirectedConstructor; | 1718 ConstructorElement redirectedConstructor; |
| 1729 | 1719 |
| 1730 /** | 1720 /** |
| 1731 * The initializers for this constructor (used for evaluating constant instanc
e creation | 1721 * The initializers for this constructor (used for evaluating constant instanc
e creation |
| 1732 * expressions). | 1722 * expressions). |
| 1733 */ | 1723 */ |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 * If the given constructor's type is different when any type parameters from
the defining type's | 1912 * If the given constructor's type is different when any type parameters from
the defining type's |
| 1923 * declaration are replaced with the actual type arguments from the defining t
ype, create a | 1913 * declaration are replaced with the actual type arguments from the defining t
ype, create a |
| 1924 * constructor member representing the given constructor. Return the member th
at was created, or | 1914 * constructor member representing the given constructor. Return the member th
at was created, or |
| 1925 * the base constructor if no member was created. | 1915 * the base constructor if no member was created. |
| 1926 * | 1916 * |
| 1927 * @param baseConstructor the base constructor for which a member might be cre
ated | 1917 * @param baseConstructor the base constructor for which a member might be cre
ated |
| 1928 * @param definingType the type defining the parameters and arguments to be us
ed in the | 1918 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 1929 * substitution | 1919 * substitution |
| 1930 * @return the constructor element that will return the correctly substituted
types | 1920 * @return the constructor element that will return the correctly substituted
types |
| 1931 */ | 1921 */ |
| 1932 static ConstructorElement from(ConstructorElement baseConstructor, | 1922 static ConstructorElement from( |
| 1933 InterfaceType definingType) { | 1923 ConstructorElement baseConstructor, InterfaceType definingType) { |
| 1934 if (baseConstructor == null || definingType.typeArguments.length == 0) { | 1924 if (baseConstructor == null || definingType.typeArguments.length == 0) { |
| 1935 return baseConstructor; | 1925 return baseConstructor; |
| 1936 } | 1926 } |
| 1937 FunctionType baseType = baseConstructor.type; | 1927 FunctionType baseType = baseConstructor.type; |
| 1938 if (baseType == null) { | 1928 if (baseType == null) { |
| 1939 // TODO(brianwilkerson) We need to understand when this can happen. | 1929 // TODO(brianwilkerson) We need to understand when this can happen. |
| 1940 return baseConstructor; | 1930 return baseConstructor; |
| 1941 } | 1931 } |
| 1942 List<DartType> argumentTypes = definingType.typeArguments; | 1932 List<DartType> argumentTypes = definingType.typeArguments; |
| 1943 List<DartType> parameterTypes = definingType.element.type.typeArguments; | 1933 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 * <i>y<sub>i</sub>, 1 <= i <= n</i> have been replaced with | 2065 * <i>y<sub>i</sub>, 1 <= i <= n</i> have been replaced with |
| 2076 * <i>x<sub>i</sub></i>. | 2066 * <i>x<sub>i</sub></i>. |
| 2077 * </blockquote> | 2067 * </blockquote> |
| 2078 * Note that, contrary to the specification, this method will not create a | 2068 * Note that, contrary to the specification, this method will not create a |
| 2079 * copy of this type if no substitutions were required, but will return this | 2069 * copy of this type if no substitutions were required, but will return this |
| 2080 * type directly. | 2070 * type directly. |
| 2081 * | 2071 * |
| 2082 * Note too that the current implementation of this method is only guaranteed | 2072 * Note too that the current implementation of this method is only guaranteed |
| 2083 * to work when the argument types are type variables. | 2073 * to work when the argument types are type variables. |
| 2084 */ | 2074 */ |
| 2085 DartType substitute2(List<DartType> argumentTypes, | 2075 DartType substitute2( |
| 2086 List<DartType> parameterTypes); | 2076 List<DartType> argumentTypes, List<DartType> parameterTypes); |
| 2087 } | 2077 } |
| 2088 | 2078 |
| 2089 /** | 2079 /** |
| 2090 * Instances of the class `DefaultFieldFormalParameterElementImpl` implement a | 2080 * Instances of the class `DefaultFieldFormalParameterElementImpl` implement a |
| 2091 * `FieldFormalParameterElementImpl` for parameters that have an initializer. | 2081 * `FieldFormalParameterElementImpl` for parameters that have an initializer. |
| 2092 */ | 2082 */ |
| 2093 class DefaultFieldFormalParameterElementImpl extends | 2083 class DefaultFieldFormalParameterElementImpl |
| 2094 FieldFormalParameterElementImpl { | 2084 extends FieldFormalParameterElementImpl { |
| 2095 /** | 2085 /** |
| 2096 * The result of evaluating this variable's initializer. | 2086 * The result of evaluating this variable's initializer. |
| 2097 */ | 2087 */ |
| 2098 EvaluationResultImpl _result; | 2088 EvaluationResultImpl _result; |
| 2099 | 2089 |
| 2100 /** | 2090 /** |
| 2101 * Initialize a newly created parameter element to have the given name. | 2091 * Initialize a newly created parameter element to have the given name. |
| 2102 * | 2092 * |
| 2103 * @param name the name of this element | 2093 * @param name the name of this element |
| 2104 */ | 2094 */ |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2218 Set<TypeImpl_TypePair> visitedTypePairs) { | 2208 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 2219 // T is S | 2209 // T is S |
| 2220 if (identical(this, type)) { | 2210 if (identical(this, type)) { |
| 2221 return true; | 2211 return true; |
| 2222 } | 2212 } |
| 2223 // else | 2213 // else |
| 2224 return withDynamic; | 2214 return withDynamic; |
| 2225 } | 2215 } |
| 2226 | 2216 |
| 2227 @override | 2217 @override |
| 2228 bool internalIsSubtypeOf(DartType type, | 2218 bool internalIsSubtypeOf( |
| 2229 Set<TypeImpl_TypePair> visitedTypePairs) => | 2219 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) => true; |
| 2230 true; | |
| 2231 | 2220 |
| 2232 @override | 2221 @override |
| 2233 bool isSupertypeOf(DartType type) => true; | 2222 bool isSupertypeOf(DartType type) => true; |
| 2234 | 2223 |
| 2235 @override | 2224 @override |
| 2236 DartType substitute2(List<DartType> argumentTypes, | 2225 DartType substitute2( |
| 2237 List<DartType> parameterTypes) { | 2226 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 2238 int length = parameterTypes.length; | 2227 int length = parameterTypes.length; |
| 2239 for (int i = 0; i < length; i++) { | 2228 for (int i = 0; i < length; i++) { |
| 2240 if (parameterTypes[i] == this) { | 2229 if (parameterTypes[i] == this) { |
| 2241 return argumentTypes[i]; | 2230 return argumentTypes[i]; |
| 2242 } | 2231 } |
| 2243 } | 2232 } |
| 2244 return this; | 2233 return this; |
| 2245 } | 2234 } |
| 2246 } | 2235 } |
| 2247 | 2236 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2266 abstract class Element { | 2255 abstract class Element { |
| 2267 /** | 2256 /** |
| 2268 * An Unicode right arrow. | 2257 * An Unicode right arrow. |
| 2269 */ | 2258 */ |
| 2270 static final String RIGHT_ARROW = " \u2192 "; | 2259 static final String RIGHT_ARROW = " \u2192 "; |
| 2271 | 2260 |
| 2272 /** | 2261 /** |
| 2273 * A comparator that can be used to sort elements by their name offset. Elemen
ts with a smaller | 2262 * A comparator that can be used to sort elements by their name offset. Elemen
ts with a smaller |
| 2274 * offset will be sorted to be before elements with a larger name offset. | 2263 * offset will be sorted to be before elements with a larger name offset. |
| 2275 */ | 2264 */ |
| 2276 static final Comparator<Element> SORT_BY_OFFSET = | 2265 static final Comparator<Element> SORT_BY_OFFSET = (Element firstElement, |
| 2277 (Element firstElement, Element secondElement) => | 2266 Element secondElement) => |
| 2278 firstElement.nameOffset - secondElement.nameOffset; | 2267 firstElement.nameOffset - secondElement.nameOffset; |
| 2279 | 2268 |
| 2280 /** | 2269 /** |
| 2281 * Return the analysis context in which this element is defined. | 2270 * Return the analysis context in which this element is defined. |
| 2282 * | 2271 * |
| 2283 * @return the analysis context in which this element is defined | 2272 * @return the analysis context in which this element is defined |
| 2284 */ | 2273 */ |
| 2285 AnalysisContext get context; | 2274 AnalysisContext get context; |
| 2286 | 2275 |
| 2287 /** | 2276 /** |
| 2288 * Return the display name of this element, or `null` if this element does not
have a name. | 2277 * Return the display name of this element, or `null` if this element does not
have a name. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2525 bool get isProxy; | 2514 bool get isProxy; |
| 2526 } | 2515 } |
| 2527 | 2516 |
| 2528 /** | 2517 /** |
| 2529 * Instances of the class `ElementAnnotationImpl` implement an [ElementAnnotatio
n]. | 2518 * Instances of the class `ElementAnnotationImpl` implement an [ElementAnnotatio
n]. |
| 2530 */ | 2519 */ |
| 2531 class ElementAnnotationImpl implements ElementAnnotation { | 2520 class ElementAnnotationImpl implements ElementAnnotation { |
| 2532 /** | 2521 /** |
| 2533 * An empty list of annotations. | 2522 * An empty list of annotations. |
| 2534 */ | 2523 */ |
| 2535 static const List<ElementAnnotationImpl> EMPTY_ARRAY = const | 2524 static const List<ElementAnnotationImpl> EMPTY_ARRAY = |
| 2536 <ElementAnnotationImpl>[ | 2525 const <ElementAnnotationImpl>[]; |
| 2537 ]; | |
| 2538 | 2526 |
| 2539 /** | 2527 /** |
| 2540 * The name of the class used to mark an element as being deprecated. | 2528 * The name of the class used to mark an element as being deprecated. |
| 2541 */ | 2529 */ |
| 2542 static String _DEPRECATED_CLASS_NAME = "Deprecated"; | 2530 static String _DEPRECATED_CLASS_NAME = "Deprecated"; |
| 2543 | 2531 |
| 2544 /** | 2532 /** |
| 2545 * The name of the top-level variable used to mark an element as being depreca
ted. | 2533 * The name of the top-level variable used to mark an element as being depreca
ted. |
| 2546 */ | 2534 */ |
| 2547 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; | 2535 static String _DEPRECATED_VARIABLE_NAME = "deprecated"; |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3058 static const ElementKind FUNCTION_TYPE_ALIAS = | 3046 static const ElementKind FUNCTION_TYPE_ALIAS = |
| 3059 const ElementKind('FUNCTION_TYPE_ALIAS', 22, "function type alias"); | 3047 const ElementKind('FUNCTION_TYPE_ALIAS', 22, "function type alias"); |
| 3060 | 3048 |
| 3061 static const ElementKind TYPE_PARAMETER = | 3049 static const ElementKind TYPE_PARAMETER = |
| 3062 const ElementKind('TYPE_PARAMETER', 23, "type parameter"); | 3050 const ElementKind('TYPE_PARAMETER', 23, "type parameter"); |
| 3063 | 3051 |
| 3064 static const ElementKind UNIVERSE = | 3052 static const ElementKind UNIVERSE = |
| 3065 const ElementKind('UNIVERSE', 24, "<universe>"); | 3053 const ElementKind('UNIVERSE', 24, "<universe>"); |
| 3066 | 3054 |
| 3067 static const List<ElementKind> values = const [ | 3055 static const List<ElementKind> values = const [ |
| 3068 CLASS, | 3056 CLASS, |
| 3069 COMPILATION_UNIT, | 3057 COMPILATION_UNIT, |
| 3070 CONSTRUCTOR, | 3058 CONSTRUCTOR, |
| 3071 DYNAMIC, | 3059 DYNAMIC, |
| 3072 EMBEDDED_HTML_SCRIPT, | 3060 EMBEDDED_HTML_SCRIPT, |
| 3073 ERROR, | 3061 ERROR, |
| 3074 EXPORT, | 3062 EXPORT, |
| 3075 EXTERNAL_HTML_SCRIPT, | 3063 EXTERNAL_HTML_SCRIPT, |
| 3076 FIELD, | 3064 FIELD, |
| 3077 FUNCTION, | 3065 FUNCTION, |
| 3078 GETTER, | 3066 GETTER, |
| 3079 HTML, | 3067 HTML, |
| 3080 IMPORT, | 3068 IMPORT, |
| 3081 LABEL, | 3069 LABEL, |
| 3082 LIBRARY, | 3070 LIBRARY, |
| 3083 LOCAL_VARIABLE, | 3071 LOCAL_VARIABLE, |
| 3084 METHOD, | 3072 METHOD, |
| 3085 NAME, | 3073 NAME, |
| 3086 PARAMETER, | 3074 PARAMETER, |
| 3087 PREFIX, | 3075 PREFIX, |
| 3088 SETTER, | 3076 SETTER, |
| 3089 TOP_LEVEL_VARIABLE, | 3077 TOP_LEVEL_VARIABLE, |
| 3090 FUNCTION_TYPE_ALIAS, | 3078 FUNCTION_TYPE_ALIAS, |
| 3091 TYPE_PARAMETER, | 3079 TYPE_PARAMETER, |
| 3092 UNIVERSE]; | 3080 UNIVERSE |
| 3081 ]; |
| 3093 | 3082 |
| 3094 /** | 3083 /** |
| 3095 * The name displayed in the UI for this kind of element. | 3084 * The name displayed in the UI for this kind of element. |
| 3096 */ | 3085 */ |
| 3097 final String displayName; | 3086 final String displayName; |
| 3098 | 3087 |
| 3099 /** | 3088 /** |
| 3100 * Initialize a newly created element kind to have the given display name. | 3089 * Initialize a newly created element kind to have the given display name. |
| 3101 * | 3090 * |
| 3102 * @param displayName the name displayed in the UI for this kind of element | 3091 * @param displayName the name displayed in the UI for this kind of element |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3424 * | 3413 * |
| 3425 * @return the library element (not `null`) | 3414 * @return the library element (not `null`) |
| 3426 */ | 3415 */ |
| 3427 LibraryElement get scriptLibrary; | 3416 LibraryElement get scriptLibrary; |
| 3428 } | 3417 } |
| 3429 | 3418 |
| 3430 /** | 3419 /** |
| 3431 * Instances of the class `EmbeddedHtmlScriptElementImpl` implement an | 3420 * Instances of the class `EmbeddedHtmlScriptElementImpl` implement an |
| 3432 * [EmbeddedHtmlScriptElement]. | 3421 * [EmbeddedHtmlScriptElement]. |
| 3433 */ | 3422 */ |
| 3434 class EmbeddedHtmlScriptElementImpl extends HtmlScriptElementImpl implements | 3423 class EmbeddedHtmlScriptElementImpl extends HtmlScriptElementImpl |
| 3435 EmbeddedHtmlScriptElement { | 3424 implements EmbeddedHtmlScriptElement { |
| 3436 /** | 3425 /** |
| 3437 * The library defined by the script tag's content. | 3426 * The library defined by the script tag's content. |
| 3438 */ | 3427 */ |
| 3439 LibraryElement _scriptLibrary; | 3428 LibraryElement _scriptLibrary; |
| 3440 | 3429 |
| 3441 /** | 3430 /** |
| 3442 * Initialize a newly created script element to have the specified tag name an
d offset. | 3431 * Initialize a newly created script element to have the specified tag name an
d offset. |
| 3443 * | 3432 * |
| 3444 * @param node the XML node from which this element is derived (not `null`) | 3433 * @param node the XML node from which this element is derived (not `null`) |
| 3445 */ | 3434 */ |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3554 * | 3543 * |
| 3555 * @return the type of function defined by this executable element | 3544 * @return the type of function defined by this executable element |
| 3556 */ | 3545 */ |
| 3557 FunctionType get type; | 3546 FunctionType get type; |
| 3558 } | 3547 } |
| 3559 | 3548 |
| 3560 /** | 3549 /** |
| 3561 * The abstract class `ExecutableElementImpl` implements the behavior common to | 3550 * The abstract class `ExecutableElementImpl` implements the behavior common to |
| 3562 * `ExecutableElement`s. | 3551 * `ExecutableElement`s. |
| 3563 */ | 3552 */ |
| 3564 abstract class ExecutableElementImpl extends ElementImpl implements | 3553 abstract class ExecutableElementImpl extends ElementImpl |
| 3565 ExecutableElement { | 3554 implements ExecutableElement { |
| 3566 /** | 3555 /** |
| 3567 * An empty list of executable elements. | 3556 * An empty list of executable elements. |
| 3568 */ | 3557 */ |
| 3569 static const List<ExecutableElement> EMPTY_ARRAY = const <ExecutableElement>[ | 3558 static const List<ExecutableElement> EMPTY_ARRAY = const <ExecutableElement>[ |
| 3570 ]; | 3559 ]; |
| 3571 | 3560 |
| 3572 /** | 3561 /** |
| 3573 * An array containing all of the functions defined within this executable ele
ment. | 3562 * An array containing all of the functions defined within this executable ele
ment. |
| 3574 */ | 3563 */ |
| 3575 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; | 3564 List<FunctionElement> _functions = FunctionElementImpl.EMPTY_ARRAY; |
| 3576 | 3565 |
| 3577 /** | 3566 /** |
| 3578 * An array containing all of the labels defined within this executable elemen
t. | 3567 * An array containing all of the labels defined within this executable elemen
t. |
| 3579 */ | 3568 */ |
| 3580 List<LabelElement> _labels = LabelElementImpl.EMPTY_ARRAY; | 3569 List<LabelElement> _labels = LabelElementImpl.EMPTY_ARRAY; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3895 * Return the library that is exported from this library by this export direct
ive. | 3884 * Return the library that is exported from this library by this export direct
ive. |
| 3896 * | 3885 * |
| 3897 * @return the library that is exported from this library | 3886 * @return the library that is exported from this library |
| 3898 */ | 3887 */ |
| 3899 LibraryElement get exportedLibrary; | 3888 LibraryElement get exportedLibrary; |
| 3900 } | 3889 } |
| 3901 | 3890 |
| 3902 /** | 3891 /** |
| 3903 * Instances of the class `ExportElementImpl` implement an [ExportElement]. | 3892 * Instances of the class `ExportElementImpl` implement an [ExportElement]. |
| 3904 */ | 3893 */ |
| 3905 class ExportElementImpl extends UriReferencedElementImpl implements | 3894 class ExportElementImpl extends UriReferencedElementImpl |
| 3906 ExportElement { | 3895 implements ExportElement { |
| 3907 /** | 3896 /** |
| 3908 * The library that is exported from this library by this export directive. | 3897 * The library that is exported from this library by this export directive. |
| 3909 */ | 3898 */ |
| 3910 LibraryElement exportedLibrary; | 3899 LibraryElement exportedLibrary; |
| 3911 | 3900 |
| 3912 /** | 3901 /** |
| 3913 * The combinators that were specified as part of the export directive in the
order in which they | 3902 * The combinators that were specified as part of the export directive in the
order in which they |
| 3914 * were specified. | 3903 * were specified. |
| 3915 */ | 3904 */ |
| 3916 List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY; | 3905 List<NamespaceCombinator> combinators = NamespaceCombinator.EMPTY_ARRAY; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3948 * | 3937 * |
| 3949 * @return the source for the external Dart library | 3938 * @return the source for the external Dart library |
| 3950 */ | 3939 */ |
| 3951 Source get scriptSource; | 3940 Source get scriptSource; |
| 3952 } | 3941 } |
| 3953 | 3942 |
| 3954 /** | 3943 /** |
| 3955 * Instances of the class `ExternalHtmlScriptElementImpl` implement an | 3944 * Instances of the class `ExternalHtmlScriptElementImpl` implement an |
| 3956 * [ExternalHtmlScriptElement]. | 3945 * [ExternalHtmlScriptElement]. |
| 3957 */ | 3946 */ |
| 3958 class ExternalHtmlScriptElementImpl extends HtmlScriptElementImpl implements | 3947 class ExternalHtmlScriptElementImpl extends HtmlScriptElementImpl |
| 3959 ExternalHtmlScriptElement { | 3948 implements ExternalHtmlScriptElement { |
| 3960 /** | 3949 /** |
| 3961 * The source specified in the `source` attribute or `null` if unspecified. | 3950 * The source specified in the `source` attribute or `null` if unspecified. |
| 3962 */ | 3951 */ |
| 3963 Source scriptSource; | 3952 Source scriptSource; |
| 3964 | 3953 |
| 3965 /** | 3954 /** |
| 3966 * Initialize a newly created script element to have the specified tag name an
d offset. | 3955 * Initialize a newly created script element to have the specified tag name an
d offset. |
| 3967 * | 3956 * |
| 3968 * @param node the XML node from which this element is derived (not `null`) | 3957 * @param node the XML node from which this element is derived (not `null`) |
| 3969 */ | 3958 */ |
| 3970 ExternalHtmlScriptElementImpl(XmlTagNode node) : super(node); | 3959 ExternalHtmlScriptElementImpl(XmlTagNode node) : super(node); |
| 3971 | 3960 |
| 3972 @override | 3961 @override |
| 3973 ElementKind get kind => ElementKind.EXTERNAL_HTML_SCRIPT; | 3962 ElementKind get kind => ElementKind.EXTERNAL_HTML_SCRIPT; |
| 3974 | 3963 |
| 3975 @override | 3964 @override |
| 3976 accept(ElementVisitor visitor) => | 3965 accept(ElementVisitor visitor) => |
| 3977 visitor.visitExternalHtmlScriptElement(this); | 3966 visitor.visitExternalHtmlScriptElement(this); |
| 3978 } | 3967 } |
| 3979 | 3968 |
| 3980 /** | 3969 /** |
| 3981 * The interface `FieldElement` defines the behavior of elements representing a
field defined | 3970 * The interface `FieldElement` defines the behavior of elements representing a
field defined |
| 3982 * within a type. | 3971 * within a type. |
| 3983 */ | 3972 */ |
| 3984 abstract class FieldElement implements ClassMemberElement, | 3973 abstract class FieldElement |
| 3985 PropertyInducingElement { | 3974 implements ClassMemberElement, PropertyInducingElement { |
| 3986 /** | 3975 /** |
| 3987 * Return {@code true} if this element is an enum constant. | 3976 * Return {@code true} if this element is an enum constant. |
| 3988 * | 3977 * |
| 3989 * @return {@code true} if this an enum constant | 3978 * @return {@code true} if this an enum constant |
| 3990 */ | 3979 */ |
| 3991 bool get isEnumConstant; | 3980 bool get isEnumConstant; |
| 3992 } | 3981 } |
| 3993 | 3982 |
| 3994 /** | 3983 /** |
| 3995 * Instances of the class `FieldElementImpl` implement a `FieldElement`. | 3984 * Instances of the class `FieldElementImpl` implement a `FieldElement`. |
| 3996 */ | 3985 */ |
| 3997 class FieldElementImpl extends PropertyInducingElementImpl implements | 3986 class FieldElementImpl extends PropertyInducingElementImpl |
| 3998 FieldElement { | 3987 implements FieldElement { |
| 3999 /** | 3988 /** |
| 4000 * An empty list of field elements. | 3989 * An empty list of field elements. |
| 4001 */ | 3990 */ |
| 4002 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[]; | 3991 static const List<FieldElement> EMPTY_ARRAY = const <FieldElement>[]; |
| 4003 | 3992 |
| 4004 /** | 3993 /** |
| 4005 * Initialize a newly created synthetic field element to have the given name. | 3994 * Initialize a newly created synthetic field element to have the given name. |
| 4006 * | 3995 * |
| 4007 * @param name the name of this element | 3996 * @param name the name of this element |
| 4008 * @param nameOffset the offset of the name of this element in the file that c
ontains the | 3997 * @param nameOffset the offset of the name of this element in the file that c
ontains the |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4055 * @return the field element associated with this field formal parameter | 4044 * @return the field element associated with this field formal parameter |
| 4056 */ | 4045 */ |
| 4057 FieldElement get field; | 4046 FieldElement get field; |
| 4058 } | 4047 } |
| 4059 | 4048 |
| 4060 /** | 4049 /** |
| 4061 * Instances of the class `FieldFormalParameterElementImpl` extend | 4050 * Instances of the class `FieldFormalParameterElementImpl` extend |
| 4062 * [ParameterElementImpl] to provide the additional information of the [FieldEle
ment] | 4051 * [ParameterElementImpl] to provide the additional information of the [FieldEle
ment] |
| 4063 * associated with the parameter. | 4052 * associated with the parameter. |
| 4064 */ | 4053 */ |
| 4065 class FieldFormalParameterElementImpl extends ParameterElementImpl implements | 4054 class FieldFormalParameterElementImpl extends ParameterElementImpl |
| 4066 FieldFormalParameterElement { | 4055 implements FieldFormalParameterElement { |
| 4067 /** | 4056 /** |
| 4068 * The field associated with this field formal parameter. | 4057 * The field associated with this field formal parameter. |
| 4069 */ | 4058 */ |
| 4070 FieldElement field; | 4059 FieldElement field; |
| 4071 | 4060 |
| 4072 /** | 4061 /** |
| 4073 * Initialize a newly created parameter element to have the given name. | 4062 * Initialize a newly created parameter element to have the given name. |
| 4074 * | 4063 * |
| 4075 * @param name the name of this element | 4064 * @param name the name of this element |
| 4076 */ | 4065 */ |
| 4077 FieldFormalParameterElementImpl(Identifier name) : super.forNode(name); | 4066 FieldFormalParameterElementImpl(Identifier name) : super.forNode(name); |
| 4078 | 4067 |
| 4079 @override | 4068 @override |
| 4080 bool get isInitializingFormal => true; | 4069 bool get isInitializingFormal => true; |
| 4081 | 4070 |
| 4082 @override | 4071 @override |
| 4083 accept(ElementVisitor visitor) => | 4072 accept(ElementVisitor visitor) => |
| 4084 visitor.visitFieldFormalParameterElement(this); | 4073 visitor.visitFieldFormalParameterElement(this); |
| 4085 } | 4074 } |
| 4086 | 4075 |
| 4087 /** | 4076 /** |
| 4088 * Instances of the class `FieldFormalParameterMember` represent a parameter ele
ment defined | 4077 * Instances of the class `FieldFormalParameterMember` represent a parameter ele
ment defined |
| 4089 * in a parameterized type where the values of the type parameters are known. | 4078 * in a parameterized type where the values of the type parameters are known. |
| 4090 */ | 4079 */ |
| 4091 class FieldFormalParameterMember extends ParameterMember implements | 4080 class FieldFormalParameterMember extends ParameterMember |
| 4092 FieldFormalParameterElement { | 4081 implements FieldFormalParameterElement { |
| 4093 /** | 4082 /** |
| 4094 * Initialize a newly created element to represent a parameter of the given pa
rameterized type. | 4083 * Initialize a newly created element to represent a parameter of the given pa
rameterized type. |
| 4095 * | 4084 * |
| 4096 * @param baseElement the element on which the parameterized element was creat
ed | 4085 * @param baseElement the element on which the parameterized element was creat
ed |
| 4097 * @param definingType the type in which the element is defined | 4086 * @param definingType the type in which the element is defined |
| 4098 */ | 4087 */ |
| 4099 FieldFormalParameterMember(FieldFormalParameterElement baseElement, | 4088 FieldFormalParameterMember( |
| 4100 ParameterizedType definingType) | 4089 FieldFormalParameterElement baseElement, ParameterizedType definingType) |
| 4101 : super(baseElement, definingType); | 4090 : super(baseElement, definingType); |
| 4102 | 4091 |
| 4103 @override | 4092 @override |
| 4104 FieldElement get field { | 4093 FieldElement get field { |
| 4105 FieldElement field = (baseElement as FieldFormalParameterElement).field; | 4094 FieldElement field = (baseElement as FieldFormalParameterElement).field; |
| 4106 if (field is FieldElement) { | 4095 if (field is FieldElement) { |
| 4107 return FieldMember.from(field, definingType); | 4096 return FieldMember.from(field, definingType); |
| 4108 } | 4097 } |
| 4109 return field; | 4098 return field; |
| 4110 } | 4099 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4183 | 4172 |
| 4184 /** | 4173 /** |
| 4185 * Determine whether the given field's type is changed when type parameters fr
om the defining | 4174 * Determine whether the given field's type is changed when type parameters fr
om the defining |
| 4186 * type's declaration are replaced with the actual type arguments from the def
ining type. | 4175 * type's declaration are replaced with the actual type arguments from the def
ining type. |
| 4187 * | 4176 * |
| 4188 * @param baseField the base field | 4177 * @param baseField the base field |
| 4189 * @param definingType the type defining the parameters and arguments to be us
ed in the | 4178 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 4190 * substitution | 4179 * substitution |
| 4191 * @return true if the type is changed by type substitution. | 4180 * @return true if the type is changed by type substitution. |
| 4192 */ | 4181 */ |
| 4193 static bool _isChangedByTypeSubstitution(FieldElement baseField, | 4182 static bool _isChangedByTypeSubstitution( |
| 4194 InterfaceType definingType) { | 4183 FieldElement baseField, InterfaceType definingType) { |
| 4195 List<DartType> argumentTypes = definingType.typeArguments; | 4184 List<DartType> argumentTypes = definingType.typeArguments; |
| 4196 if (baseField != null && argumentTypes.length != 0) { | 4185 if (baseField != null && argumentTypes.length != 0) { |
| 4197 DartType baseType = baseField.type; | 4186 DartType baseType = baseField.type; |
| 4198 List<DartType> parameterTypes = definingType.element.type.typeArguments; | 4187 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 4199 if (baseType != null) { | 4188 if (baseType != null) { |
| 4200 DartType substitutedType = | 4189 DartType substitutedType = |
| 4201 baseType.substitute2(argumentTypes, parameterTypes); | 4190 baseType.substitute2(argumentTypes, parameterTypes); |
| 4202 if (baseType != substitutedType) { | 4191 if (baseType != substitutedType) { |
| 4203 return true; | 4192 return true; |
| 4204 } | 4193 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4248 * | 4237 * |
| 4249 * @return the resolved [FunctionDeclaration], not `null`. | 4238 * @return the resolved [FunctionDeclaration], not `null`. |
| 4250 */ | 4239 */ |
| 4251 @override | 4240 @override |
| 4252 FunctionDeclaration get node; | 4241 FunctionDeclaration get node; |
| 4253 } | 4242 } |
| 4254 | 4243 |
| 4255 /** | 4244 /** |
| 4256 * Instances of the class `FunctionElementImpl` implement a `FunctionElement`. | 4245 * Instances of the class `FunctionElementImpl` implement a `FunctionElement`. |
| 4257 */ | 4246 */ |
| 4258 class FunctionElementImpl extends ExecutableElementImpl implements | 4247 class FunctionElementImpl extends ExecutableElementImpl |
| 4259 FunctionElement { | 4248 implements FunctionElement { |
| 4260 /** | 4249 /** |
| 4261 * An empty list of function elements. | 4250 * An empty list of function elements. |
| 4262 */ | 4251 */ |
| 4263 static const List<FunctionElement> EMPTY_ARRAY = const <FunctionElement>[]; | 4252 static const List<FunctionElement> EMPTY_ARRAY = const <FunctionElement>[]; |
| 4264 | 4253 |
| 4265 /** | 4254 /** |
| 4266 * The offset to the beginning of the visible range for this element. | 4255 * The offset to the beginning of the visible range for this element. |
| 4267 */ | 4256 */ |
| 4268 int _visibleRangeOffset = 0; | 4257 int _visibleRangeOffset = 0; |
| 4269 | 4258 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4458 * `call()`, and the type of `call()` is the function type <i>F</i>, then <i>I
</i> is | 4447 * `call()`, and the type of `call()` is the function type <i>F</i>, then <i>I
</i> is |
| 4459 * considered to be a subtype of <i>F</i>. | 4448 * considered to be a subtype of <i>F</i>. |
| 4460 * | 4449 * |
| 4461 * @param type the type being compared with this type | 4450 * @param type the type being compared with this type |
| 4462 * @return `true` if this type is a subtype of the given type | 4451 * @return `true` if this type is a subtype of the given type |
| 4463 */ | 4452 */ |
| 4464 @override | 4453 @override |
| 4465 bool isSubtypeOf(DartType type); | 4454 bool isSubtypeOf(DartType type); |
| 4466 | 4455 |
| 4467 @override | 4456 @override |
| 4468 FunctionType substitute2(List<DartType> argumentTypes, | 4457 FunctionType substitute2( |
| 4469 List<DartType> parameterTypes); | 4458 List<DartType> argumentTypes, List<DartType> parameterTypes); |
| 4470 | 4459 |
| 4471 /** | 4460 /** |
| 4472 * Return the type resulting from substituting the given arguments for this ty
pe's parameters. | 4461 * Return the type resulting from substituting the given arguments for this ty
pe's parameters. |
| 4473 * This is fully equivalent to `substitute(argumentTypes, getTypeArguments())`
. | 4462 * This is fully equivalent to `substitute(argumentTypes, getTypeArguments())`
. |
| 4474 * | 4463 * |
| 4475 * @param argumentTypes the actual type arguments being substituted for the ty
pe parameters | 4464 * @param argumentTypes the actual type arguments being substituted for the ty
pe parameters |
| 4476 * @return the result of performing the substitution | 4465 * @return the result of performing the substitution |
| 4477 */ | 4466 */ |
| 4478 FunctionType substitute3(List<DartType> argumentTypes); | 4467 FunctionType substitute3(List<DartType> argumentTypes); |
| 4479 } | 4468 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4529 * | 4518 * |
| 4530 * @return the type parameters defined for this type | 4519 * @return the type parameters defined for this type |
| 4531 */ | 4520 */ |
| 4532 List<TypeParameterElement> get typeParameters; | 4521 List<TypeParameterElement> get typeParameters; |
| 4533 } | 4522 } |
| 4534 | 4523 |
| 4535 /** | 4524 /** |
| 4536 * Instances of the class `FunctionTypeAliasElementImpl` implement a | 4525 * Instances of the class `FunctionTypeAliasElementImpl` implement a |
| 4537 * `FunctionTypeAliasElement`. | 4526 * `FunctionTypeAliasElement`. |
| 4538 */ | 4527 */ |
| 4539 class FunctionTypeAliasElementImpl extends ElementImpl implements | 4528 class FunctionTypeAliasElementImpl extends ElementImpl |
| 4540 FunctionTypeAliasElement { | 4529 implements FunctionTypeAliasElement { |
| 4541 /** | 4530 /** |
| 4542 * An empty array of type alias elements. | 4531 * An empty array of type alias elements. |
| 4543 */ | 4532 */ |
| 4544 static List<FunctionTypeAliasElement> EMPTY_ARRAY = | 4533 static List<FunctionTypeAliasElement> EMPTY_ARRAY = |
| 4545 new List<FunctionTypeAliasElement>(0); | 4534 new List<FunctionTypeAliasElement>(0); |
| 4546 | 4535 |
| 4547 /** | 4536 /** |
| 4548 * An array containing all of the parameters defined by this type alias. | 4537 * An array containing all of the parameters defined by this type alias. |
| 4549 */ | 4538 */ |
| 4550 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; | 4539 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4926 // null and we need to understand why it is and fix it. | 4915 // null and we need to understand why it is and fix it. |
| 4927 return DynamicTypeImpl.instance; | 4916 return DynamicTypeImpl.instance; |
| 4928 } | 4917 } |
| 4929 // If there are no arguments to substitute, or if the arguments size doesn't | 4918 // If there are no arguments to substitute, or if the arguments size doesn't |
| 4930 // match the parameter size, return the base return type. | 4919 // match the parameter size, return the base return type. |
| 4931 if (typeArguments.length == 0 || | 4920 if (typeArguments.length == 0 || |
| 4932 typeArguments.length != typeParameters.length) { | 4921 typeArguments.length != typeParameters.length) { |
| 4933 return baseReturnType; | 4922 return baseReturnType; |
| 4934 } | 4923 } |
| 4935 return baseReturnType.substitute2( | 4924 return baseReturnType.substitute2( |
| 4936 typeArguments, | 4925 typeArguments, TypeParameterTypeImpl.getTypes(typeParameters)); |
| 4937 TypeParameterTypeImpl.getTypes(typeParameters)); | |
| 4938 } | 4926 } |
| 4939 | 4927 |
| 4940 @override | 4928 @override |
| 4941 List<TypeParameterElement> get typeParameters { | 4929 List<TypeParameterElement> get typeParameters { |
| 4942 Element element = this.element; | 4930 Element element = this.element; |
| 4943 if (element is FunctionTypeAliasElement) { | 4931 if (element is FunctionTypeAliasElement) { |
| 4944 return element.typeParameters; | 4932 return element.typeParameters; |
| 4945 } | 4933 } |
| 4946 ClassElement definingClass = | 4934 ClassElement definingClass = |
| 4947 element.getAncestor((element) => element is ClassElement); | 4935 element.getAncestor((element) => element is ClassElement); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5028 return false; | 5016 return false; |
| 5029 } | 5017 } |
| 5030 FunctionTypeImpl otherType = object as FunctionTypeImpl; | 5018 FunctionTypeImpl otherType = object as FunctionTypeImpl; |
| 5031 // If the visitedTypePairs already has the pair (this, type), | 5019 // If the visitedTypePairs already has the pair (this, type), |
| 5032 // use the elements to determine equality | 5020 // use the elements to determine equality |
| 5033 ElementPair elementPair = new ElementPair(element, otherType.element); | 5021 ElementPair elementPair = new ElementPair(element, otherType.element); |
| 5034 if (!visitedElementPairs.add(elementPair)) { | 5022 if (!visitedElementPairs.add(elementPair)) { |
| 5035 return elementPair.firstElt == elementPair.secondElt; | 5023 return elementPair.firstElt == elementPair.secondElt; |
| 5036 } | 5024 } |
| 5037 // Compute the result | 5025 // Compute the result |
| 5038 bool result = | 5026 bool result = TypeImpl.equalArrays(normalParameterTypes, |
| 5039 TypeImpl.equalArrays( | 5027 otherType.normalParameterTypes, visitedElementPairs) && |
| 5040 normalParameterTypes, | 5028 TypeImpl.equalArrays(optionalParameterTypes, |
| 5041 otherType.normalParameterTypes, | 5029 otherType.optionalParameterTypes, visitedElementPairs) && |
| 5042 visitedElementPairs) && | 5030 _equals(namedParameterTypes, otherType.namedParameterTypes, |
| 5043 TypeImpl.equalArrays( | |
| 5044 optionalParameterTypes, | |
| 5045 otherType.optionalParameterTypes, | |
| 5046 visitedElementPairs) && | |
| 5047 _equals( | |
| 5048 namedParameterTypes, | |
| 5049 otherType.namedParameterTypes, | |
| 5050 visitedElementPairs) && | 5031 visitedElementPairs) && |
| 5051 (returnType as TypeImpl).internalEquals( | 5032 (returnType as TypeImpl).internalEquals( |
| 5052 otherType.returnType, | 5033 otherType.returnType, visitedElementPairs); |
| 5053 visitedElementPairs); | |
| 5054 // Remove the pair from our visited pairs list | 5034 // Remove the pair from our visited pairs list |
| 5055 visitedElementPairs.remove(elementPair); | 5035 visitedElementPairs.remove(elementPair); |
| 5056 // Return the result | 5036 // Return the result |
| 5057 return result; | 5037 return result; |
| 5058 } | 5038 } |
| 5059 | 5039 |
| 5060 @override | 5040 @override |
| 5061 int internalHashCode(List<DartType> visitedTypes) { | 5041 int internalHashCode(List<DartType> visitedTypes) { |
| 5062 if (element == null) { | 5042 if (element == null) { |
| 5063 return 0; | 5043 return 0; |
| 5064 } else if (visitedTypes.contains(this)) { | 5044 } else if (visitedTypes.contains(this)) { |
| 5065 return 3; | 5045 return 3; |
| 5066 } | 5046 } |
| 5067 visitedTypes.add(this); | 5047 visitedTypes.add(this); |
| 5068 // Reference the arrays of parameters | 5048 // Reference the arrays of parameters |
| 5069 List<DartType> normalParameterTypes = this.normalParameterTypes; | 5049 List<DartType> normalParameterTypes = this.normalParameterTypes; |
| 5070 List<DartType> optionalParameterTypes = this.optionalParameterTypes; | 5050 List<DartType> optionalParameterTypes = this.optionalParameterTypes; |
| 5071 Iterable<DartType> namedParameterTypes = this.namedParameterTypes.values; | 5051 Iterable<DartType> namedParameterTypes = this.namedParameterTypes.values; |
| 5072 // Generate the hashCode | 5052 // Generate the hashCode |
| 5073 int code = (returnType as TypeImpl).internalHashCode(visitedTypes); | 5053 int code = (returnType as TypeImpl).internalHashCode(visitedTypes); |
| 5074 for (int i = 0; i < normalParameterTypes.length; i++) { | 5054 for (int i = 0; i < normalParameterTypes.length; i++) { |
| 5075 code = (code << 1) + | 5055 code = (code << 1) + |
| 5076 (normalParameterTypes[i] as TypeImpl).internalHashCode(visitedTypes); | 5056 (normalParameterTypes[i] as TypeImpl).internalHashCode(visitedTypes); |
| 5077 } | 5057 } |
| 5078 for (int i = 0; i < optionalParameterTypes.length; i++) { | 5058 for (int i = 0; i < optionalParameterTypes.length; i++) { |
| 5079 code = (code << 1) + | 5059 code = (code << 1) + |
| 5080 (optionalParameterTypes[i] as TypeImpl).internalHashCode(visitedTypes)
; | 5060 (optionalParameterTypes[i] as TypeImpl) |
| 5061 .internalHashCode(visitedTypes); |
| 5081 } | 5062 } |
| 5082 for (DartType type in namedParameterTypes) { | 5063 for (DartType type in namedParameterTypes) { |
| 5083 code = (code << 1) + (type as TypeImpl).internalHashCode(visitedTypes); | 5064 code = (code << 1) + (type as TypeImpl).internalHashCode(visitedTypes); |
| 5084 } | 5065 } |
| 5085 return code; | 5066 return code; |
| 5086 } | 5067 } |
| 5087 | 5068 |
| 5088 @override | 5069 @override |
| 5089 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, | 5070 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, |
| 5090 Set<TypeImpl_TypePair> visitedTypePairs) { | 5071 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 5091 // trivial base cases | 5072 // trivial base cases |
| 5092 if (type == null) { | 5073 if (type == null) { |
| 5093 return false; | 5074 return false; |
| 5094 } else if (identical(this, type) || | 5075 } else if (identical(this, type) || |
| 5095 type.isDynamic || | 5076 type.isDynamic || |
| 5096 type.isDartCoreFunction || | 5077 type.isDartCoreFunction || |
| 5097 type.isObject) { | 5078 type.isObject) { |
| 5098 return true; | 5079 return true; |
| 5099 } else if (type is UnionType) { | 5080 } else if (type is UnionType) { |
| 5100 return (type as UnionTypeImpl).internalUnionTypeIsLessSpecificThan( | 5081 return (type as UnionTypeImpl).internalUnionTypeIsLessSpecificThan( |
| 5101 this, | 5082 this, withDynamic, visitedTypePairs); |
| 5102 withDynamic, | |
| 5103 visitedTypePairs); | |
| 5104 } else if (type is! FunctionType) { | 5083 } else if (type is! FunctionType) { |
| 5105 return false; | 5084 return false; |
| 5106 } else if (this == type) { | 5085 } else if (this == type) { |
| 5107 return true; | 5086 return true; |
| 5108 } | 5087 } |
| 5109 FunctionType t = this; | 5088 FunctionType t = this; |
| 5110 FunctionType s = type as FunctionType; | 5089 FunctionType s = type as FunctionType; |
| 5111 List<DartType> tTypes = t.normalParameterTypes; | 5090 List<DartType> tTypes = t.normalParameterTypes; |
| 5112 List<DartType> tOpTypes = t.optionalParameterTypes; | 5091 List<DartType> tOpTypes = t.optionalParameterTypes; |
| 5113 List<DartType> sTypes = s.normalParameterTypes; | 5092 List<DartType> sTypes = s.normalParameterTypes; |
| 5114 List<DartType> sOpTypes = s.optionalParameterTypes; | 5093 List<DartType> sOpTypes = s.optionalParameterTypes; |
| 5115 // If one function has positional and the other has named parameters, | 5094 // If one function has positional and the other has named parameters, |
| 5116 // return false. | 5095 // return false. |
| 5117 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || | 5096 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || |
| 5118 (tOpTypes.length > 0 && s.namedParameterTypes.length > 0)) { | 5097 (tOpTypes.length > 0 && s.namedParameterTypes.length > 0)) { |
| 5119 return false; | 5098 return false; |
| 5120 } | 5099 } |
| 5121 // named parameters case | 5100 // named parameters case |
| 5122 if (t.namedParameterTypes.length > 0) { | 5101 if (t.namedParameterTypes.length > 0) { |
| 5123 // check that the number of required parameters are equal, and check that | 5102 // check that the number of required parameters are equal, and check that |
| 5124 // every t_i is more specific than every s_i | 5103 // every t_i is more specific than every s_i |
| 5125 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { | 5104 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { |
| 5126 return false; | 5105 return false; |
| 5127 } else if (t.normalParameterTypes.length > 0) { | 5106 } else if (t.normalParameterTypes.length > 0) { |
| 5128 for (int i = 0; i < tTypes.length; i++) { | 5107 for (int i = 0; i < tTypes.length; i++) { |
| 5129 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan2( | 5108 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan2( |
| 5130 sTypes[i], | 5109 sTypes[i], withDynamic, visitedTypePairs)) { |
| 5131 withDynamic, | |
| 5132 visitedTypePairs)) { | |
| 5133 return false; | 5110 return false; |
| 5134 } | 5111 } |
| 5135 } | 5112 } |
| 5136 } | 5113 } |
| 5137 Map<String, DartType> namedTypesT = t.namedParameterTypes; | 5114 Map<String, DartType> namedTypesT = t.namedParameterTypes; |
| 5138 Map<String, DartType> namedTypesS = s.namedParameterTypes; | 5115 Map<String, DartType> namedTypesS = s.namedParameterTypes; |
| 5139 // if k >= m is false, return false: the passed function type has more | 5116 // if k >= m is false, return false: the passed function type has more |
| 5140 // named parameter types than this | 5117 // named parameter types than this |
| 5141 if (namedTypesT.length < namedTypesS.length) { | 5118 if (namedTypesT.length < namedTypesS.length) { |
| 5142 return false; | 5119 return false; |
| 5143 } | 5120 } |
| 5144 // Loop through each element in S verifying that T has a matching | 5121 // Loop through each element in S verifying that T has a matching |
| 5145 // parameter name and that the corresponding type is more specific then | 5122 // parameter name and that the corresponding type is more specific then |
| 5146 // the type in S. | 5123 // the type in S. |
| 5147 for (String keyS in namedTypesS.keys) { | 5124 for (String keyS in namedTypesS.keys) { |
| 5148 DartType typeT = namedTypesT[keyS]; | 5125 DartType typeT = namedTypesT[keyS]; |
| 5149 if (typeT == null) { | 5126 if (typeT == null) { |
| 5150 return false; | 5127 return false; |
| 5151 } | 5128 } |
| 5152 if (!(typeT as TypeImpl).isMoreSpecificThan2( | 5129 if (!(typeT as TypeImpl).isMoreSpecificThan2( |
| 5153 namedTypesS[keyS], | 5130 namedTypesS[keyS], withDynamic, visitedTypePairs)) { |
| 5154 withDynamic, | |
| 5155 visitedTypePairs)) { | |
| 5156 return false; | 5131 return false; |
| 5157 } | 5132 } |
| 5158 } | 5133 } |
| 5159 } else if (s.namedParameterTypes.length > 0) { | 5134 } else if (s.namedParameterTypes.length > 0) { |
| 5160 return false; | 5135 return false; |
| 5161 } else { | 5136 } else { |
| 5162 // positional parameter case | 5137 // positional parameter case |
| 5163 int tArgLength = tTypes.length + tOpTypes.length; | 5138 int tArgLength = tTypes.length + tOpTypes.length; |
| 5164 int sArgLength = sTypes.length + sOpTypes.length; | 5139 int sArgLength = sTypes.length + sOpTypes.length; |
| 5165 // Check that the total number of parameters in t is greater than or equal | 5140 // Check that the total number of parameters in t is greater than or equal |
| 5166 // to the number of parameters in s and that the number of required | 5141 // to the number of parameters in s and that the number of required |
| 5167 // parameters in s is greater than or equal to the number of required | 5142 // parameters in s is greater than or equal to the number of required |
| 5168 // parameters in t. | 5143 // parameters in t. |
| 5169 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { | 5144 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { |
| 5170 return false; | 5145 return false; |
| 5171 } | 5146 } |
| 5172 if (tOpTypes.length == 0 && sOpTypes.length == 0) { | 5147 if (tOpTypes.length == 0 && sOpTypes.length == 0) { |
| 5173 // No positional arguments, don't copy contents to new array | 5148 // No positional arguments, don't copy contents to new array |
| 5174 for (int i = 0; i < sTypes.length; i++) { | 5149 for (int i = 0; i < sTypes.length; i++) { |
| 5175 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan2( | 5150 if (!(tTypes[i] as TypeImpl).isMoreSpecificThan2( |
| 5176 sTypes[i], | 5151 sTypes[i], withDynamic, visitedTypePairs)) { |
| 5177 withDynamic, | |
| 5178 visitedTypePairs)) { | |
| 5179 return false; | 5152 return false; |
| 5180 } | 5153 } |
| 5181 } | 5154 } |
| 5182 } else { | 5155 } else { |
| 5183 // Else, we do have positional parameters, copy required and positional | 5156 // Else, we do have positional parameters, copy required and positional |
| 5184 // parameter types into arrays to do the compare (for loop below). | 5157 // parameter types into arrays to do the compare (for loop below). |
| 5185 List<DartType> tAllTypes = new List<DartType>(sArgLength); | 5158 List<DartType> tAllTypes = new List<DartType>(sArgLength); |
| 5186 for (int i = 0; i < tTypes.length; i++) { | 5159 for (int i = 0; i < tTypes.length; i++) { |
| 5187 tAllTypes[i] = tTypes[i]; | 5160 tAllTypes[i] = tTypes[i]; |
| 5188 } | 5161 } |
| 5189 for (int i = tTypes.length, | 5162 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 5190 j = 0; i < sArgLength; i++, j++) { | |
| 5191 tAllTypes[i] = tOpTypes[j]; | 5163 tAllTypes[i] = tOpTypes[j]; |
| 5192 } | 5164 } |
| 5193 List<DartType> sAllTypes = new List<DartType>(sArgLength); | 5165 List<DartType> sAllTypes = new List<DartType>(sArgLength); |
| 5194 for (int i = 0; i < sTypes.length; i++) { | 5166 for (int i = 0; i < sTypes.length; i++) { |
| 5195 sAllTypes[i] = sTypes[i]; | 5167 sAllTypes[i] = sTypes[i]; |
| 5196 } | 5168 } |
| 5197 for (int i = sTypes.length, | 5169 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 5198 j = 0; i < sArgLength; i++, j++) { | |
| 5199 sAllTypes[i] = sOpTypes[j]; | 5170 sAllTypes[i] = sOpTypes[j]; |
| 5200 } | 5171 } |
| 5201 for (int i = 0; i < sAllTypes.length; i++) { | 5172 for (int i = 0; i < sAllTypes.length; i++) { |
| 5202 if (!(tAllTypes[i] as TypeImpl).isMoreSpecificThan2( | 5173 if (!(tAllTypes[i] as TypeImpl).isMoreSpecificThan2( |
| 5203 sAllTypes[i], | 5174 sAllTypes[i], withDynamic, visitedTypePairs)) { |
| 5204 withDynamic, | |
| 5205 visitedTypePairs)) { | |
| 5206 return false; | 5175 return false; |
| 5207 } | 5176 } |
| 5208 } | 5177 } |
| 5209 } | 5178 } |
| 5210 } | 5179 } |
| 5211 DartType tRetType = t.returnType; | 5180 DartType tRetType = t.returnType; |
| 5212 DartType sRetType = s.returnType; | 5181 DartType sRetType = s.returnType; |
| 5213 return sRetType.isVoid || | 5182 return sRetType.isVoid || |
| 5214 (tRetType as TypeImpl).isMoreSpecificThan2( | 5183 (tRetType as TypeImpl).isMoreSpecificThan2( |
| 5215 sRetType, | 5184 sRetType, withDynamic, visitedTypePairs); |
| 5216 withDynamic, | |
| 5217 visitedTypePairs); | |
| 5218 } | 5185 } |
| 5219 | 5186 |
| 5220 @override | 5187 @override |
| 5221 bool internalIsSubtypeOf(DartType type, | 5188 bool internalIsSubtypeOf( |
| 5222 Set<TypeImpl_TypePair> visitedTypePairs) { | 5189 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 5223 // trivial base cases | 5190 // trivial base cases |
| 5224 if (type == null) { | 5191 if (type == null) { |
| 5225 return false; | 5192 return false; |
| 5226 } else if (identical(this, type) || | 5193 } else if (identical(this, type) || |
| 5227 type.isDynamic || | 5194 type.isDynamic || |
| 5228 type.isDartCoreFunction || | 5195 type.isDartCoreFunction || |
| 5229 type.isObject) { | 5196 type.isObject) { |
| 5230 return true; | 5197 return true; |
| 5231 } else if (type is UnionType) { | 5198 } else if (type is UnionType) { |
| 5232 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf( | 5199 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf( |
| 5233 this, | 5200 this, visitedTypePairs); |
| 5234 visitedTypePairs); | |
| 5235 } else if (type is! FunctionType) { | 5201 } else if (type is! FunctionType) { |
| 5236 return false; | 5202 return false; |
| 5237 } else if (this == type) { | 5203 } else if (this == type) { |
| 5238 return true; | 5204 return true; |
| 5239 } | 5205 } |
| 5240 FunctionType t = this; | 5206 FunctionType t = this; |
| 5241 FunctionType s = type as FunctionType; | 5207 FunctionType s = type as FunctionType; |
| 5242 List<DartType> tTypes = t.normalParameterTypes; | 5208 List<DartType> tTypes = t.normalParameterTypes; |
| 5243 List<DartType> tOpTypes = t.optionalParameterTypes; | 5209 List<DartType> tOpTypes = t.optionalParameterTypes; |
| 5244 List<DartType> sTypes = s.normalParameterTypes; | 5210 List<DartType> sTypes = s.normalParameterTypes; |
| 5245 List<DartType> sOpTypes = s.optionalParameterTypes; | 5211 List<DartType> sOpTypes = s.optionalParameterTypes; |
| 5246 // If one function has positional and the other has named parameters, | 5212 // If one function has positional and the other has named parameters, |
| 5247 // return false. | 5213 // return false. |
| 5248 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || | 5214 if ((sOpTypes.length > 0 && t.namedParameterTypes.length > 0) || |
| 5249 (tOpTypes.length > 0 && s.namedParameterTypes.length > 0)) { | 5215 (tOpTypes.length > 0 && s.namedParameterTypes.length > 0)) { |
| 5250 return false; | 5216 return false; |
| 5251 } | 5217 } |
| 5252 // named parameters case | 5218 // named parameters case |
| 5253 if (t.namedParameterTypes.length > 0) { | 5219 if (t.namedParameterTypes.length > 0) { |
| 5254 // check that the number of required parameters are equal, | 5220 // check that the number of required parameters are equal, |
| 5255 // and check that every t_i is assignable to every s_i | 5221 // and check that every t_i is assignable to every s_i |
| 5256 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { | 5222 if (t.normalParameterTypes.length != s.normalParameterTypes.length) { |
| 5257 return false; | 5223 return false; |
| 5258 } else if (t.normalParameterTypes.length > 0) { | 5224 } else if (t.normalParameterTypes.length > 0) { |
| 5259 for (int i = 0; i < tTypes.length; i++) { | 5225 for (int i = 0; i < tTypes.length; i++) { |
| 5260 if (!(tTypes[i] as TypeImpl).isAssignableTo2( | 5226 if (!(tTypes[i] as TypeImpl).isAssignableTo2( |
| 5261 sTypes[i], | 5227 sTypes[i], visitedTypePairs)) { |
| 5262 visitedTypePairs)) { | |
| 5263 return false; | 5228 return false; |
| 5264 } | 5229 } |
| 5265 } | 5230 } |
| 5266 } | 5231 } |
| 5267 Map<String, DartType> namedTypesT = t.namedParameterTypes; | 5232 Map<String, DartType> namedTypesT = t.namedParameterTypes; |
| 5268 Map<String, DartType> namedTypesS = s.namedParameterTypes; | 5233 Map<String, DartType> namedTypesS = s.namedParameterTypes; |
| 5269 // if k >= m is false, return false: the passed function type has more | 5234 // if k >= m is false, return false: the passed function type has more |
| 5270 // named parameter types than this | 5235 // named parameter types than this |
| 5271 if (namedTypesT.length < namedTypesS.length) { | 5236 if (namedTypesT.length < namedTypesS.length) { |
| 5272 return false; | 5237 return false; |
| 5273 } | 5238 } |
| 5274 // Loop through each element in S verifying that T has a matching | 5239 // Loop through each element in S verifying that T has a matching |
| 5275 // parameter name and that the corresponding type is assignable to the | 5240 // parameter name and that the corresponding type is assignable to the |
| 5276 // type in S. | 5241 // type in S. |
| 5277 for (String keyS in namedTypesS.keys) { | 5242 for (String keyS in namedTypesS.keys) { |
| 5278 DartType typeT = namedTypesT[keyS]; | 5243 DartType typeT = namedTypesT[keyS]; |
| 5279 if (typeT == null) { | 5244 if (typeT == null) { |
| 5280 return false; | 5245 return false; |
| 5281 } | 5246 } |
| 5282 if (!(typeT as TypeImpl).isAssignableTo2( | 5247 if (!(typeT as TypeImpl).isAssignableTo2( |
| 5283 namedTypesS[keyS], | 5248 namedTypesS[keyS], visitedTypePairs)) { |
| 5284 visitedTypePairs)) { | |
| 5285 return false; | 5249 return false; |
| 5286 } | 5250 } |
| 5287 } | 5251 } |
| 5288 } else if (s.namedParameterTypes.length > 0) { | 5252 } else if (s.namedParameterTypes.length > 0) { |
| 5289 return false; | 5253 return false; |
| 5290 } else { | 5254 } else { |
| 5291 // positional parameter case | 5255 // positional parameter case |
| 5292 int tArgLength = tTypes.length + tOpTypes.length; | 5256 int tArgLength = tTypes.length + tOpTypes.length; |
| 5293 int sArgLength = sTypes.length + sOpTypes.length; | 5257 int sArgLength = sTypes.length + sOpTypes.length; |
| 5294 // Check that the total number of parameters in t is greater than or equal | 5258 // Check that the total number of parameters in t is greater than or equal |
| 5295 // to the number of parameters in s and that the number of required | 5259 // to the number of parameters in s and that the number of required |
| 5296 // parameters in s is greater than or equal to the number of required | 5260 // parameters in s is greater than or equal to the number of required |
| 5297 // parameters in t. | 5261 // parameters in t. |
| 5298 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { | 5262 if (tArgLength < sArgLength || sTypes.length < tTypes.length) { |
| 5299 return false; | 5263 return false; |
| 5300 } | 5264 } |
| 5301 if (tOpTypes.length == 0 && sOpTypes.length == 0) { | 5265 if (tOpTypes.length == 0 && sOpTypes.length == 0) { |
| 5302 // No positional arguments, don't copy contents to new array | 5266 // No positional arguments, don't copy contents to new array |
| 5303 for (int i = 0; i < sTypes.length; i++) { | 5267 for (int i = 0; i < sTypes.length; i++) { |
| 5304 if (!(tTypes[i] as TypeImpl).isAssignableTo2( | 5268 if (!(tTypes[i] as TypeImpl).isAssignableTo2( |
| 5305 sTypes[i], | 5269 sTypes[i], visitedTypePairs)) { |
| 5306 visitedTypePairs)) { | |
| 5307 return false; | 5270 return false; |
| 5308 } | 5271 } |
| 5309 } | 5272 } |
| 5310 } else { | 5273 } else { |
| 5311 // Else, we do have positional parameters, copy required and positional | 5274 // Else, we do have positional parameters, copy required and positional |
| 5312 // parameter types into arrays to do the compare (for loop below). | 5275 // parameter types into arrays to do the compare (for loop below). |
| 5313 List<DartType> tAllTypes = new List<DartType>(sArgLength); | 5276 List<DartType> tAllTypes = new List<DartType>(sArgLength); |
| 5314 for (int i = 0; i < tTypes.length; i++) { | 5277 for (int i = 0; i < tTypes.length; i++) { |
| 5315 tAllTypes[i] = tTypes[i]; | 5278 tAllTypes[i] = tTypes[i]; |
| 5316 } | 5279 } |
| 5317 for (int i = tTypes.length, | 5280 for (int i = tTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 5318 j = 0; i < sArgLength; i++, j++) { | |
| 5319 tAllTypes[i] = tOpTypes[j]; | 5281 tAllTypes[i] = tOpTypes[j]; |
| 5320 } | 5282 } |
| 5321 List<DartType> sAllTypes = new List<DartType>(sArgLength); | 5283 List<DartType> sAllTypes = new List<DartType>(sArgLength); |
| 5322 for (int i = 0; i < sTypes.length; i++) { | 5284 for (int i = 0; i < sTypes.length; i++) { |
| 5323 sAllTypes[i] = sTypes[i]; | 5285 sAllTypes[i] = sTypes[i]; |
| 5324 } | 5286 } |
| 5325 for (int i = sTypes.length, | 5287 for (int i = sTypes.length, j = 0; i < sArgLength; i++, j++) { |
| 5326 j = 0; i < sArgLength; i++, j++) { | |
| 5327 sAllTypes[i] = sOpTypes[j]; | 5288 sAllTypes[i] = sOpTypes[j]; |
| 5328 } | 5289 } |
| 5329 for (int i = 0; i < sAllTypes.length; i++) { | 5290 for (int i = 0; i < sAllTypes.length; i++) { |
| 5330 if (!(tAllTypes[i] as TypeImpl).isAssignableTo2( | 5291 if (!(tAllTypes[i] as TypeImpl).isAssignableTo2( |
| 5331 sAllTypes[i], | 5292 sAllTypes[i], visitedTypePairs)) { |
| 5332 visitedTypePairs)) { | |
| 5333 return false; | 5293 return false; |
| 5334 } | 5294 } |
| 5335 } | 5295 } |
| 5336 } | 5296 } |
| 5337 } | 5297 } |
| 5338 DartType tRetType = t.returnType; | 5298 DartType tRetType = t.returnType; |
| 5339 DartType sRetType = s.returnType; | 5299 DartType sRetType = s.returnType; |
| 5340 return sRetType.isVoid || | 5300 return sRetType.isVoid || |
| 5341 (tRetType as TypeImpl).isAssignableTo2(sRetType, visitedTypePairs); | 5301 (tRetType as TypeImpl).isAssignableTo2(sRetType, visitedTypePairs); |
| 5342 } | 5302 } |
| 5343 | 5303 |
| 5344 /** | 5304 /** |
| 5345 * Return `true` if this type is assignable to the given type. A function type
<i>T</i> may | 5305 * Return `true` if this type is assignable to the given type. A function type
<i>T</i> may |
| 5346 * be assigned to a function type <i>S</i>, written <i>T</i> ⇔ <i>S</i>,
iff <i>T</i> <: | 5306 * be assigned to a function type <i>S</i>, written <i>T</i> ⇔ <i>S</i>,
iff <i>T</i> <: |
| 5347 * <i>S</i> (Function Types section of spec). Note that this is more restricti
ve than the | 5307 * <i>S</i> (Function Types section of spec). Note that this is more restricti
ve than the |
| 5348 * "may be assigned to" rule for interface types. | 5308 * "may be assigned to" rule for interface types. |
| 5349 * | 5309 * |
| 5350 * | 5310 * |
| 5351 * @param type the type being compared with this type | 5311 * @param type the type being compared with this type |
| 5352 * @return `true` if this type is assignable to the given type | 5312 * @return `true` if this type is assignable to the given type |
| 5353 */ | 5313 */ |
| 5354 @override | 5314 @override |
| 5355 bool isAssignableTo(DartType type) => | 5315 bool isAssignableTo(DartType type) => |
| 5356 isSubtypeOf2(type, new HashSet<TypeImpl_TypePair>()); | 5316 isSubtypeOf2(type, new HashSet<TypeImpl_TypePair>()); |
| 5357 | 5317 |
| 5358 @override | 5318 @override |
| 5359 FunctionTypeImpl substitute2(List<DartType> argumentTypes, | 5319 FunctionTypeImpl substitute2( |
| 5360 List<DartType> parameterTypes) { | 5320 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 5361 if (argumentTypes.length != parameterTypes.length) { | 5321 if (argumentTypes.length != parameterTypes.length) { |
| 5362 throw new IllegalArgumentException( | 5322 throw new IllegalArgumentException( |
| 5363 "argumentTypes.length (${argumentTypes.length}) != parameterTypes.leng
th (${parameterTypes.length})"); | 5323 "argumentTypes.length (${argumentTypes.length}) != parameterTypes.leng
th (${parameterTypes.length})"); |
| 5364 } | 5324 } |
| 5365 if (argumentTypes.length == 0) { | 5325 if (argumentTypes.length == 0) { |
| 5366 return this; | 5326 return this; |
| 5367 } | 5327 } |
| 5368 Element element = this.element; | 5328 Element element = this.element; |
| 5369 FunctionTypeImpl newType = (element is ExecutableElement) ? | 5329 FunctionTypeImpl newType = (element is ExecutableElement) |
| 5370 new FunctionTypeImpl.con1(element) : | 5330 ? new FunctionTypeImpl.con1(element) |
| 5371 new FunctionTypeImpl.con2(element as FunctionTypeAliasElement); | 5331 : new FunctionTypeImpl.con2(element as FunctionTypeAliasElement); |
| 5372 newType.typeArguments = | 5332 newType.typeArguments = |
| 5373 TypeImpl.substitute(typeArguments, argumentTypes, parameterTypes); | 5333 TypeImpl.substitute(typeArguments, argumentTypes, parameterTypes); |
| 5374 return newType; | 5334 return newType; |
| 5375 } | 5335 } |
| 5376 | 5336 |
| 5377 @override | 5337 @override |
| 5378 FunctionTypeImpl substitute3(List<DartType> argumentTypes) => | 5338 FunctionTypeImpl substitute3(List<DartType> argumentTypes) => |
| 5379 substitute2(argumentTypes, typeArguments); | 5339 substitute2(argumentTypes, typeArguments); |
| 5380 | 5340 |
| 5381 /** | 5341 /** |
| 5382 * Return `true` if all of the name/type pairs in the first map are equal to t
he | 5342 * Return `true` if all of the name/type pairs in the first map are equal to t
he |
| 5383 * corresponding name/type pairs in the second map. The maps are expected to i
terate over their | 5343 * corresponding name/type pairs in the second map. The maps are expected to i
terate over their |
| 5384 * entries in the same order in which those entries were added to the map. | 5344 * entries in the same order in which those entries were added to the map. |
| 5385 * | 5345 * |
| 5386 * @param firstTypes the first map of name/type pairs being compared | 5346 * @param firstTypes the first map of name/type pairs being compared |
| 5387 * @param secondTypes the second map of name/type pairs being compared | 5347 * @param secondTypes the second map of name/type pairs being compared |
| 5388 * @param visitedElementPairs a set of visited element pairs | 5348 * @param visitedElementPairs a set of visited element pairs |
| 5389 * @return `true` if all of the name/type pairs in the first map are equal to
the | 5349 * @return `true` if all of the name/type pairs in the first map are equal to
the |
| 5390 * corresponding name/type pairs in the second map | 5350 * corresponding name/type pairs in the second map |
| 5391 */ | 5351 */ |
| 5392 static bool _equals(Map<String, DartType> firstTypes, Map<String, | 5352 static bool _equals(Map<String, DartType> firstTypes, |
| 5393 DartType> secondTypes, Set<ElementPair> visitedElementPairs) { | 5353 Map<String, DartType> secondTypes, Set<ElementPair> visitedElementPairs) { |
| 5394 if (secondTypes.length != firstTypes.length) { | 5354 if (secondTypes.length != firstTypes.length) { |
| 5395 return false; | 5355 return false; |
| 5396 } | 5356 } |
| 5397 Iterator<String> firstKeys = firstTypes.keys.iterator; | 5357 Iterator<String> firstKeys = firstTypes.keys.iterator; |
| 5398 Iterator<String> secondKeys = secondTypes.keys.iterator; | 5358 Iterator<String> secondKeys = secondTypes.keys.iterator; |
| 5399 while (firstKeys.moveNext() && secondKeys.moveNext()) { | 5359 while (firstKeys.moveNext() && secondKeys.moveNext()) { |
| 5400 String firstKey = firstKeys.current; | 5360 String firstKey = firstKeys.current; |
| 5401 String secondKey = secondKeys.current; | 5361 String secondKey = secondKeys.current; |
| 5402 TypeImpl firstType = firstTypes[firstKey]; | 5362 TypeImpl firstType = firstTypes[firstKey]; |
| 5403 TypeImpl secondType = secondTypes[secondKey]; | 5363 TypeImpl secondType = secondTypes[secondKey]; |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5712 safelyVisitChildren(_scripts, visitor); | 5672 safelyVisitChildren(_scripts, visitor); |
| 5713 } | 5673 } |
| 5714 } | 5674 } |
| 5715 | 5675 |
| 5716 /** | 5676 /** |
| 5717 * The interface `HtmlScriptElement` defines the behavior of elements representi
ng a script | 5677 * The interface `HtmlScriptElement` defines the behavior of elements representi
ng a script |
| 5718 * tag in an HTML file. | 5678 * tag in an HTML file. |
| 5719 * | 5679 * |
| 5720 * See [EmbeddedHtmlScriptElement], and [ExternalHtmlScriptElement], | 5680 * See [EmbeddedHtmlScriptElement], and [ExternalHtmlScriptElement], |
| 5721 */ | 5681 */ |
| 5722 abstract class HtmlScriptElement implements Element { | 5682 abstract class HtmlScriptElement implements Element {} |
| 5723 } | |
| 5724 | 5683 |
| 5725 /** | 5684 /** |
| 5726 * Instances of the class `HtmlScriptElementImpl` implement an [HtmlScriptElemen
t]. | 5685 * Instances of the class `HtmlScriptElementImpl` implement an [HtmlScriptElemen
t]. |
| 5727 */ | 5686 */ |
| 5728 abstract class HtmlScriptElementImpl extends ElementImpl implements | 5687 abstract class HtmlScriptElementImpl extends ElementImpl |
| 5729 HtmlScriptElement { | 5688 implements HtmlScriptElement { |
| 5730 /** | 5689 /** |
| 5731 * An empty list of HTML script elements. | 5690 * An empty list of HTML script elements. |
| 5732 */ | 5691 */ |
| 5733 static const List<HtmlScriptElement> EMPTY_ARRAY = const <HtmlScriptElement>[ | 5692 static const List<HtmlScriptElement> EMPTY_ARRAY = const <HtmlScriptElement>[ |
| 5734 ]; | 5693 ]; |
| 5735 | 5694 |
| 5736 /** | 5695 /** |
| 5737 * Initialize a newly created script element to have the specified tag name an
d offset. | 5696 * Initialize a newly created script element to have the specified tag name an
d offset. |
| 5738 * | 5697 * |
| 5739 * @param node the XML node from which this element is derived (not `null`) | 5698 * @param node the XML node from which this element is derived (not `null`) |
| 5740 */ | 5699 */ |
| 5741 HtmlScriptElementImpl(XmlTagNode node) | 5700 HtmlScriptElementImpl(XmlTagNode node) |
| 5742 : super(node.tag, node.tagToken.offset); | 5701 : super(node.tag, node.tagToken.offset); |
| 5743 } | 5702 } |
| 5744 | 5703 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5788 * an offset. | 5747 * an offset. |
| 5789 * | 5748 * |
| 5790 * @return the offset of the prefix of this import | 5749 * @return the offset of the prefix of this import |
| 5791 */ | 5750 */ |
| 5792 int get prefixOffset; | 5751 int get prefixOffset; |
| 5793 } | 5752 } |
| 5794 | 5753 |
| 5795 /** | 5754 /** |
| 5796 * Instances of the class `ImportElementImpl` implement an [ImportElement]. | 5755 * Instances of the class `ImportElementImpl` implement an [ImportElement]. |
| 5797 */ | 5756 */ |
| 5798 class ImportElementImpl extends UriReferencedElementImpl implements | 5757 class ImportElementImpl extends UriReferencedElementImpl |
| 5799 ImportElement { | 5758 implements ImportElement { |
| 5800 /** | 5759 /** |
| 5801 * The offset of the prefix of this import in the file that contains the this
import directive, or | 5760 * The offset of the prefix of this import in the file that contains the this
import directive, or |
| 5802 * `-1` if this import is synthetic. | 5761 * `-1` if this import is synthetic. |
| 5803 */ | 5762 */ |
| 5804 int prefixOffset = 0; | 5763 int prefixOffset = 0; |
| 5805 | 5764 |
| 5806 /** | 5765 /** |
| 5807 * The library that is imported into this library by this import directive. | 5766 * The library that is imported into this library by this import directive. |
| 5808 */ | 5767 */ |
| 5809 LibraryElement importedLibrary; | 5768 LibraryElement importedLibrary; |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6018 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | 5977 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section |
| 6019 * 12.11.1: <blockquote>If <i>e</i> is of the form <b>new</b> <i>T.id()</i> th
en let <i>q<i> be | 5978 * 12.11.1: <blockquote>If <i>e</i> is of the form <b>new</b> <i>T.id()</i> th
en let <i>q<i> be |
| 6020 * the constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor <i>T<
i>. Otherwise, if | 5979 * the constructor <i>T.id</i>, otherwise let <i>q<i> be the constructor <i>T<
i>. Otherwise, if |
| 6021 * <i>q</i> is not defined or not accessible, a NoSuchMethodException is throw
n. </blockquote> | 5980 * <i>q</i> is not defined or not accessible, a NoSuchMethodException is throw
n. </blockquote> |
| 6022 * | 5981 * |
| 6023 * @param constructorName the name of the constructor being looked up | 5982 * @param constructorName the name of the constructor being looked up |
| 6024 * @param library the library with respect to which the lookup is being perfor
med | 5983 * @param library the library with respect to which the lookup is being perfor
med |
| 6025 * @return the result of looking up the given constructor in this class with r
espect to the given | 5984 * @return the result of looking up the given constructor in this class with r
espect to the given |
| 6026 * library | 5985 * library |
| 6027 */ | 5986 */ |
| 6028 ConstructorElement lookUpConstructor(String constructorName, | 5987 ConstructorElement lookUpConstructor( |
| 6029 LibraryElement library); | 5988 String constructorName, LibraryElement library); |
| 6030 | 5989 |
| 6031 /** | 5990 /** |
| 6032 * Return the element representing the getter that results from looking up the
given getter in | 5991 * Return the element representing the getter that results from looking up the
given getter in |
| 6033 * this class with respect to the given library, or `null` if the look up fail
s. The | 5992 * this class with respect to the given library, or `null` if the look up fail
s. The |
| 6034 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | 5993 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: |
| 6035 * <blockquote>The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> | 5994 * <blockquote>The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> |
| 6036 * with respect to library <i>L</i> is: | 5995 * with respect to library <i>L</i> is: |
| 6037 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 5996 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is |
| 6038 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 5997 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. |
| 6039 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 5998 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result |
| 6040 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 5999 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. |
| 6041 * Otherwise, we say that the lookup has failed. | 6000 * Otherwise, we say that the lookup has failed. |
| 6042 * </blockquote> | 6001 * </blockquote> |
| 6043 * | 6002 * |
| 6044 * @param getterName the name of the getter being looked up | 6003 * @param getterName the name of the getter being looked up |
| 6045 * @param library the library with respect to which the lookup is being perfor
med | 6004 * @param library the library with respect to which the lookup is being perfor
med |
| 6046 * @return the result of looking up the given getter in this class with respec
t to the given | 6005 * @return the result of looking up the given getter in this class with respec
t to the given |
| 6047 * library | 6006 * library |
| 6048 */ | 6007 */ |
| 6049 PropertyAccessorElement lookUpGetter(String getterName, | 6008 PropertyAccessorElement lookUpGetter( |
| 6050 LibraryElement library); | 6009 String getterName, LibraryElement library); |
| 6051 | 6010 |
| 6052 /** | 6011 /** |
| 6053 * Return the element representing the getter that results from looking up the
given getter in the | 6012 * Return the element representing the getter that results from looking up the
given getter in the |
| 6054 * superclass of this class with respect to the given library, or `null` if th
e look up | 6013 * superclass of this class with respect to the given library, or `null` if th
e look up |
| 6055 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | 6014 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section |
| 6056 * 12.15.1: <blockquote>The result of looking up getter (respectively setter)
<i>m</i> in class | 6015 * 12.15.1: <blockquote>The result of looking up getter (respectively setter)
<i>m</i> in class |
| 6057 * <i>C</i> with respect to library <i>L</i> is: | 6016 * <i>C</i> with respect to library <i>L</i> is: |
| 6058 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 6017 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is |
| 6059 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 6018 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. |
| 6060 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 6019 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result |
| 6061 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 6020 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. |
| 6062 * Otherwise, we say that the lookup has failed. | 6021 * Otherwise, we say that the lookup has failed. |
| 6063 * </blockquote> | 6022 * </blockquote> |
| 6064 * | 6023 * |
| 6065 * @param getterName the name of the getter being looked up | 6024 * @param getterName the name of the getter being looked up |
| 6066 * @param library the library with respect to which the lookup is being perfor
med | 6025 * @param library the library with respect to which the lookup is being perfor
med |
| 6067 * @return the result of looking up the given getter in this class with respec
t to the given | 6026 * @return the result of looking up the given getter in this class with respec
t to the given |
| 6068 * library | 6027 * library |
| 6069 */ | 6028 */ |
| 6070 PropertyAccessorElement lookUpGetterInSuperclass(String getterName, | 6029 PropertyAccessorElement lookUpGetterInSuperclass( |
| 6071 LibraryElement library); | 6030 String getterName, LibraryElement library); |
| 6072 | 6031 |
| 6073 /** | 6032 /** |
| 6074 * Return the element representing the method that results from looking up the
given method in | 6033 * Return the element representing the method that results from looking up the
given method in |
| 6075 * this class with respect to the given library, or `null` if the look up fail
s. The | 6034 * this class with respect to the given library, or `null` if the look up fail
s. The |
| 6076 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: | 6035 * behavior of this method is defined by the Dart Language Specification in se
ction 12.15.1: |
| 6077 * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> wit
h respect to library | 6036 * <blockquote> The result of looking up method <i>m</i> in class <i>C</i> wit
h respect to library |
| 6078 * <i>L</i> is: | 6037 * <i>L</i> is: |
| 6079 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then | 6038 * * If <i>C</i> declares an instance method named <i>m</i> that is accessible
to <i>L</i>, then |
| 6080 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 6039 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then |
| 6081 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 6040 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6099 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then | 6058 * that method is the result of the lookup. Otherwise, if <i>C</i> has a super
class <i>S</i>, then |
| 6100 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect | 6059 * the result of the lookup is the result of looking up method <i>m</i> in <i>
S</i> with respect |
| 6101 * to <i>L</i>. Otherwise, we say that the lookup has failed. | 6060 * to <i>L</i>. Otherwise, we say that the lookup has failed. |
| 6102 * </blockquote> | 6061 * </blockquote> |
| 6103 * | 6062 * |
| 6104 * @param methodName the name of the method being looked up | 6063 * @param methodName the name of the method being looked up |
| 6105 * @param library the library with respect to which the lookup is being perfor
med | 6064 * @param library the library with respect to which the lookup is being perfor
med |
| 6106 * @return the result of looking up the given method in this class with respec
t to the given | 6065 * @return the result of looking up the given method in this class with respec
t to the given |
| 6107 * library | 6066 * library |
| 6108 */ | 6067 */ |
| 6109 MethodElement lookUpMethodInSuperclass(String methodName, | 6068 MethodElement lookUpMethodInSuperclass( |
| 6110 LibraryElement library); | 6069 String methodName, LibraryElement library); |
| 6111 | 6070 |
| 6112 /** | 6071 /** |
| 6113 * Return the element representing the setter that results from looking up the
given setter in | 6072 * Return the element representing the setter that results from looking up the
given setter in |
| 6114 * this class with respect to the given library, or `null` if the look up fail
s. The | 6073 * this class with respect to the given library, or `null` if the look up fail
s. The |
| 6115 * behavior of this method is defined by the Dart Language Specification in se
ction 12.16: | 6074 * behavior of this method is defined by the Dart Language Specification in se
ction 12.16: |
| 6116 * <blockquote> The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> | 6075 * <blockquote> The result of looking up getter (respectively setter) <i>m</i>
in class <i>C</i> |
| 6117 * with respect to library <i>L</i> is: | 6076 * with respect to library <i>L</i> is: |
| 6118 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 6077 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is |
| 6119 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 6078 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. |
| 6120 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 6079 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result |
| 6121 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 6080 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. |
| 6122 * Otherwise, we say that the lookup has failed. | 6081 * Otherwise, we say that the lookup has failed. |
| 6123 * </blockquote> | 6082 * </blockquote> |
| 6124 * | 6083 * |
| 6125 * @param setterName the name of the setter being looked up | 6084 * @param setterName the name of the setter being looked up |
| 6126 * @param library the library with respect to which the lookup is being perfor
med | 6085 * @param library the library with respect to which the lookup is being perfor
med |
| 6127 * @return the result of looking up the given setter in this class with respec
t to the given | 6086 * @return the result of looking up the given setter in this class with respec
t to the given |
| 6128 * library | 6087 * library |
| 6129 */ | 6088 */ |
| 6130 PropertyAccessorElement lookUpSetter(String setterName, | 6089 PropertyAccessorElement lookUpSetter( |
| 6131 LibraryElement library); | 6090 String setterName, LibraryElement library); |
| 6132 | 6091 |
| 6133 /** | 6092 /** |
| 6134 * Return the element representing the setter that results from looking up the
given setter in the | 6093 * Return the element representing the setter that results from looking up the
given setter in the |
| 6135 * superclass of this class with respect to the given library, or `null` if th
e look up | 6094 * superclass of this class with respect to the given library, or `null` if th
e look up |
| 6136 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section | 6095 * fails. The behavior of this method is defined by the Dart Language Specific
ation in section |
| 6137 * 12.16: <blockquote> The result of looking up getter (respectively setter) <
i>m</i> in class | 6096 * 12.16: <blockquote> The result of looking up getter (respectively setter) <
i>m</i> in class |
| 6138 * <i>C</i> with respect to library <i>L</i> is: | 6097 * <i>C</i> with respect to library <i>L</i> is: |
| 6139 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is | 6098 * * If <i>C</i> declares an instance getter (respectively setter) named <i>m<
/i> that is |
| 6140 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. | 6099 * accessible to <i>L</i>, then that getter (respectively setter) is the resul
t of the lookup. |
| 6141 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result | 6100 * Otherwise, if <i>C</i> has a superclass <i>S</i>, then the result of the lo
okup is the result |
| 6142 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. | 6101 * of looking up getter (respectively setter) <i>m</i> in <i>S</i> with respec
t to <i>L</i>. |
| 6143 * Otherwise, we say that the lookup has failed. | 6102 * Otherwise, we say that the lookup has failed. |
| 6144 * </blockquote> | 6103 * </blockquote> |
| 6145 * | 6104 * |
| 6146 * @param setterName the name of the setter being looked up | 6105 * @param setterName the name of the setter being looked up |
| 6147 * @param library the library with respect to which the lookup is being perfor
med | 6106 * @param library the library with respect to which the lookup is being perfor
med |
| 6148 * @return the result of looking up the given setter in this class with respec
t to the given | 6107 * @return the result of looking up the given setter in this class with respec
t to the given |
| 6149 * library | 6108 * library |
| 6150 */ | 6109 */ |
| 6151 PropertyAccessorElement lookUpSetterInSuperclass(String setterName, | 6110 PropertyAccessorElement lookUpSetterInSuperclass( |
| 6152 LibraryElement library); | 6111 String setterName, LibraryElement library); |
| 6153 | 6112 |
| 6154 @override | 6113 @override |
| 6155 InterfaceType substitute2(List<DartType> argumentTypes, | 6114 InterfaceType substitute2( |
| 6156 List<DartType> parameterTypes); | 6115 List<DartType> argumentTypes, List<DartType> parameterTypes); |
| 6157 | 6116 |
| 6158 /** | 6117 /** |
| 6159 * Return the type resulting from substituting the given arguments for this | 6118 * Return the type resulting from substituting the given arguments for this |
| 6160 * type's parameters. This is fully equivalent to `substitute2(argumentTypes, | 6119 * type's parameters. This is fully equivalent to `substitute2(argumentTypes, |
| 6161 * getTypeArguments())`. | 6120 * getTypeArguments())`. |
| 6162 */ | 6121 */ |
| 6163 InterfaceType substitute4(List<DartType> argumentTypes); | 6122 InterfaceType substitute4(List<DartType> argumentTypes); |
| 6164 | 6123 |
| 6165 /** | 6124 /** |
| 6166 * Returns a "smart" version of the "least upper bound" of the given types. | 6125 * Returns a "smart" version of the "least upper bound" of the given types. |
| 6167 * | 6126 * |
| 6168 * If these types have the same element and differ only in terms of the type | 6127 * If these types have the same element and differ only in terms of the type |
| 6169 * arguments, attempts to find a compatible set of type arguments. | 6128 * arguments, attempts to find a compatible set of type arguments. |
| 6170 * | 6129 * |
| 6171 * Otherwise, calls [DartType.getLeastUpperBound]. | 6130 * Otherwise, calls [DartType.getLeastUpperBound]. |
| 6172 */ | 6131 */ |
| 6173 static InterfaceType getSmartLeastUpperBound(InterfaceType first, | 6132 static InterfaceType getSmartLeastUpperBound( |
| 6174 InterfaceType second) { | 6133 InterfaceType first, InterfaceType second) { |
| 6175 if (first.element == second.element) { | 6134 if (first.element == second.element) { |
| 6176 return _leastUpperBound(first, second); | 6135 return _leastUpperBound(first, second); |
| 6177 } | 6136 } |
| 6178 return first.getLeastUpperBound(second); | 6137 return first.getLeastUpperBound(second); |
| 6179 } | 6138 } |
| 6180 | 6139 |
| 6181 /** | 6140 /** |
| 6182 * Return the "least upper bound" of the given types under the assumption that | 6141 * Return the "least upper bound" of the given types under the assumption that |
| 6183 * the types have the same element and differ only in terms of the type | 6142 * the types have the same element and differ only in terms of the type |
| 6184 * arguments. | 6143 * arguments. |
| 6185 * | 6144 * |
| 6186 * The resulting type is composed by comparing the corresponding type | 6145 * The resulting type is composed by comparing the corresponding type |
| 6187 * arguments, keeping those that are the same, and using 'dynamic' for those | 6146 * arguments, keeping those that are the same, and using 'dynamic' for those |
| 6188 * that are different. | 6147 * that are different. |
| 6189 */ | 6148 */ |
| 6190 static InterfaceType _leastUpperBound(InterfaceType firstType, | 6149 static InterfaceType _leastUpperBound( |
| 6191 InterfaceType secondType) { | 6150 InterfaceType firstType, InterfaceType secondType) { |
| 6192 ClassElement firstElement = firstType.element; | 6151 ClassElement firstElement = firstType.element; |
| 6193 ClassElement secondElement = secondType.element; | 6152 ClassElement secondElement = secondType.element; |
| 6194 if (firstElement != secondElement) { | 6153 if (firstElement != secondElement) { |
| 6195 throw new IllegalArgumentException( | 6154 throw new IllegalArgumentException('The same elements expected, but ' |
| 6196 'The same elements expected, but ' | 6155 '$firstElement and $secondElement are given.'); |
| 6197 '$firstElement and $secondElement are given.'); | |
| 6198 } | 6156 } |
| 6199 if (firstType == secondType) { | 6157 if (firstType == secondType) { |
| 6200 return firstType; | 6158 return firstType; |
| 6201 } | 6159 } |
| 6202 List<DartType> firstArguments = firstType.typeArguments; | 6160 List<DartType> firstArguments = firstType.typeArguments; |
| 6203 List<DartType> secondArguments = secondType.typeArguments; | 6161 List<DartType> secondArguments = secondType.typeArguments; |
| 6204 int argumentCount = firstArguments.length; | 6162 int argumentCount = firstArguments.length; |
| 6205 if (argumentCount == 0) { | 6163 if (argumentCount == 0) { |
| 6206 return firstType; | 6164 return firstType; |
| 6207 } | 6165 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6397 if (i > 0) { | 6355 if (i > 0) { |
| 6398 buffer.write(", "); | 6356 buffer.write(", "); |
| 6399 } | 6357 } |
| 6400 (typeArguments[i] as TypeImpl).appendTo(buffer, visitedTypes); | 6358 (typeArguments[i] as TypeImpl).appendTo(buffer, visitedTypes); |
| 6401 } | 6359 } |
| 6402 buffer.write(">"); | 6360 buffer.write(">"); |
| 6403 } | 6361 } |
| 6404 } | 6362 } |
| 6405 | 6363 |
| 6406 @override | 6364 @override |
| 6407 PropertyAccessorElement getGetter(String getterName) => | 6365 PropertyAccessorElement getGetter(String getterName) => PropertyAccessorMember |
| 6408 PropertyAccessorMember.from( | 6366 .from((element as ClassElementImpl).getGetter(getterName), this); |
| 6409 (element as ClassElementImpl).getGetter(getterName), | |
| 6410 this); | |
| 6411 | 6367 |
| 6412 @override | 6368 @override |
| 6413 DartType getLeastUpperBound(DartType type) { | 6369 DartType getLeastUpperBound(DartType type) { |
| 6414 // quick check for self | 6370 // quick check for self |
| 6415 if (identical(type, this)) { | 6371 if (identical(type, this)) { |
| 6416 return this; | 6372 return this; |
| 6417 } | 6373 } |
| 6418 // dynamic | 6374 // dynamic |
| 6419 DartType dynamicType = DynamicTypeImpl.instance; | 6375 DartType dynamicType = DynamicTypeImpl.instance; |
| 6420 if (identical(this, dynamicType) || identical(type, dynamicType)) { | 6376 if (identical(this, dynamicType) || identical(type, dynamicType)) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 6440 List<int> depths = new List<int>.filled(s.length, 0); | 6396 List<int> depths = new List<int>.filled(s.length, 0); |
| 6441 int maxDepth = 0; | 6397 int maxDepth = 0; |
| 6442 for (int n = 0; n < s.length; n++) { | 6398 for (int n = 0; n < s.length; n++) { |
| 6443 depths[n] = computeLongestInheritancePathToObject(s[n]); | 6399 depths[n] = computeLongestInheritancePathToObject(s[n]); |
| 6444 if (depths[n] > maxDepth) { | 6400 if (depths[n] > maxDepth) { |
| 6445 maxDepth = depths[n]; | 6401 maxDepth = depths[n]; |
| 6446 } | 6402 } |
| 6447 } | 6403 } |
| 6448 // ensure that the currently computed maxDepth is unique, | 6404 // ensure that the currently computed maxDepth is unique, |
| 6449 // otherwise, decrement and test for uniqueness again | 6405 // otherwise, decrement and test for uniqueness again |
| 6450 for ( ; maxDepth >= 0; maxDepth--) { | 6406 for (; maxDepth >= 0; maxDepth--) { |
| 6451 int indexOfLeastUpperBound = -1; | 6407 int indexOfLeastUpperBound = -1; |
| 6452 int numberOfTypesAtMaxDepth = 0; | 6408 int numberOfTypesAtMaxDepth = 0; |
| 6453 for (int m = 0; m < depths.length; m++) { | 6409 for (int m = 0; m < depths.length; m++) { |
| 6454 if (depths[m] == maxDepth) { | 6410 if (depths[m] == maxDepth) { |
| 6455 numberOfTypesAtMaxDepth++; | 6411 numberOfTypesAtMaxDepth++; |
| 6456 indexOfLeastUpperBound = m; | 6412 indexOfLeastUpperBound = m; |
| 6457 } | 6413 } |
| 6458 } | 6414 } |
| 6459 if (numberOfTypesAtMaxDepth == 1) { | 6415 if (numberOfTypesAtMaxDepth == 1) { |
| 6460 return s[indexOfLeastUpperBound]; | 6416 return s[indexOfLeastUpperBound]; |
| 6461 } | 6417 } |
| 6462 } | 6418 } |
| 6463 // illegal state, log and return null- Object at maxDepth == 0 should always | 6419 // illegal state, log and return null- Object at maxDepth == 0 should always |
| 6464 // return itself as the least upper bound. | 6420 // return itself as the least upper bound. |
| 6465 // TODO (jwren) log the error state | 6421 // TODO (jwren) log the error state |
| 6466 return null; | 6422 return null; |
| 6467 } | 6423 } |
| 6468 | 6424 |
| 6469 @override | 6425 @override |
| 6470 MethodElement getMethod(String methodName) => | 6426 MethodElement getMethod(String methodName) => MethodMember.from( |
| 6471 MethodMember.from((element as ClassElementImpl).getMethod(methodName), thi
s); | 6427 (element as ClassElementImpl).getMethod(methodName), this); |
| 6472 | 6428 |
| 6473 @override | 6429 @override |
| 6474 PropertyAccessorElement getSetter(String setterName) => | 6430 PropertyAccessorElement getSetter(String setterName) => PropertyAccessorMember |
| 6475 PropertyAccessorMember.from( | 6431 .from((element as ClassElementImpl).getSetter(setterName), this); |
| 6476 (element as ClassElementImpl).getSetter(setterName), | |
| 6477 this); | |
| 6478 | 6432 |
| 6479 @override | 6433 @override |
| 6480 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) { | 6434 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) { |
| 6481 if (object is! InterfaceTypeImpl) { | 6435 if (object is! InterfaceTypeImpl) { |
| 6482 return false; | 6436 return false; |
| 6483 } | 6437 } |
| 6484 InterfaceTypeImpl otherType = object as InterfaceTypeImpl; | 6438 InterfaceTypeImpl otherType = object as InterfaceTypeImpl; |
| 6485 return (element == otherType.element) && | 6439 return (element == otherType.element) && |
| 6486 TypeImpl.equalArrays( | 6440 TypeImpl.equalArrays( |
| 6487 typeArguments, | 6441 typeArguments, otherType.typeArguments, visitedElementPairs); |
| 6488 otherType.typeArguments, | |
| 6489 visitedElementPairs); | |
| 6490 } | 6442 } |
| 6491 | 6443 |
| 6492 @override | 6444 @override |
| 6493 int internalHashCode(List<DartType> visitedTypes) => hashCode; | 6445 int internalHashCode(List<DartType> visitedTypes) => hashCode; |
| 6494 | 6446 |
| 6495 @override | 6447 @override |
| 6496 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, | 6448 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, |
| 6497 Set<TypeImpl_TypePair> visitedTypePairs) { | 6449 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 6498 // | 6450 // |
| 6499 // S is dynamic. | 6451 // S is dynamic. |
| 6500 // The test to determine whether S is dynamic is done here because dynamic | 6452 // The test to determine whether S is dynamic is done here because dynamic |
| 6501 // is not an instance of InterfaceType. | 6453 // is not an instance of InterfaceType. |
| 6502 // | 6454 // |
| 6503 if (type.isDynamic) { | 6455 if (type.isDynamic) { |
| 6504 return true; | 6456 return true; |
| 6505 } else if (type is UnionType) { | 6457 } else if (type is UnionType) { |
| 6506 return (type as UnionTypeImpl).internalUnionTypeIsLessSpecificThan( | 6458 return (type as UnionTypeImpl).internalUnionTypeIsLessSpecificThan( |
| 6507 this, | 6459 this, withDynamic, visitedTypePairs); |
| 6508 withDynamic, | |
| 6509 visitedTypePairs); | |
| 6510 } else if (type is! InterfaceType) { | 6460 } else if (type is! InterfaceType) { |
| 6511 return false; | 6461 return false; |
| 6512 } | 6462 } |
| 6513 return _isMoreSpecificThan( | 6463 return _isMoreSpecificThan(type as InterfaceType, |
| 6514 type as InterfaceType, | 6464 new HashSet<ClassElement>(), withDynamic, visitedTypePairs); |
| 6515 new HashSet<ClassElement>(), | |
| 6516 withDynamic, | |
| 6517 visitedTypePairs); | |
| 6518 } | 6465 } |
| 6519 | 6466 |
| 6520 @override | 6467 @override |
| 6521 bool internalIsSubtypeOf(DartType type, | 6468 bool internalIsSubtypeOf( |
| 6522 Set<TypeImpl_TypePair> visitedTypePairs) { | 6469 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 6523 // | 6470 // |
| 6524 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S | 6471 // T is a subtype of S, written T <: S, iff [bottom/dynamic]T << S |
| 6525 // | 6472 // |
| 6526 if (type.isDynamic) { | 6473 if (type.isDynamic) { |
| 6527 return true; | 6474 return true; |
| 6528 } else if (type is TypeParameterType) { | 6475 } else if (type is TypeParameterType) { |
| 6529 return false; | 6476 return false; |
| 6530 } else if (type is UnionType) { | 6477 } else if (type is UnionType) { |
| 6531 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf( | 6478 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf( |
| 6532 this, | 6479 this, visitedTypePairs); |
| 6533 visitedTypePairs); | |
| 6534 } else if (type is FunctionType) { | 6480 } else if (type is FunctionType) { |
| 6535 // This implementation assumes transitivity | 6481 // This implementation assumes transitivity |
| 6536 // for function type subtyping on the RHS, but a literal reading | 6482 // for function type subtyping on the RHS, but a literal reading |
| 6537 // of the spec does not specify this. More precisely: | 6483 // of the spec does not specify this. More precisely: |
| 6538 // if T <: F1 and F1 <: F2 and F1 and F2 are function types, | 6484 // if T <: F1 and F1 <: F2 and F1 and F2 are function types, |
| 6539 // then we assume T <: F2. | 6485 // then we assume T <: F2. |
| 6540 // | 6486 // |
| 6541 // From the Function Types section of the spec: | 6487 // From the Function Types section of the spec: |
| 6542 // | 6488 // |
| 6543 // If a type I includes an instance method named call(), and the type of | 6489 // If a type I includes an instance method named call(), and the type of |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6593 // (tools/test.py --mode release --compiler dartanalyzer --runtime none) | 6539 // (tools/test.py --mode release --compiler dartanalyzer --runtime none) |
| 6594 return callType.isSubtypeOf(type); | 6540 return callType.isSubtypeOf(type); |
| 6595 } | 6541 } |
| 6596 return false; | 6542 return false; |
| 6597 } else if (type is! InterfaceType) { | 6543 } else if (type is! InterfaceType) { |
| 6598 return false; | 6544 return false; |
| 6599 } else if (this == type) { | 6545 } else if (this == type) { |
| 6600 return true; | 6546 return true; |
| 6601 } | 6547 } |
| 6602 return _isSubtypeOf( | 6548 return _isSubtypeOf( |
| 6603 type as InterfaceType, | 6549 type as InterfaceType, new HashSet<ClassElement>(), visitedTypePairs); |
| 6604 new HashSet<ClassElement>(), | |
| 6605 visitedTypePairs); | |
| 6606 } | 6550 } |
| 6607 | 6551 |
| 6608 @override | 6552 @override |
| 6609 bool isDirectSupertypeOf(InterfaceType type) { | 6553 bool isDirectSupertypeOf(InterfaceType type) { |
| 6610 InterfaceType i = this; | 6554 InterfaceType i = this; |
| 6611 InterfaceType j = type; | 6555 InterfaceType j = type; |
| 6612 ClassElement jElement = j.element; | 6556 ClassElement jElement = j.element; |
| 6613 InterfaceType supertype = jElement.supertype; | 6557 InterfaceType supertype = jElement.supertype; |
| 6614 // | 6558 // |
| 6615 // If J has no direct supertype then it is Object, and Object has no direct | 6559 // If J has no direct supertype then it is Object, and Object has no direct |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6647 } | 6591 } |
| 6648 // | 6592 // |
| 6649 // J is a mixin application of the mixin of I. | 6593 // J is a mixin application of the mixin of I. |
| 6650 // | 6594 // |
| 6651 // TODO(brianwilkerson) Determine whether this needs to be implemented or | 6595 // TODO(brianwilkerson) Determine whether this needs to be implemented or |
| 6652 // whether it is covered by the case above. | 6596 // whether it is covered by the case above. |
| 6653 return false; | 6597 return false; |
| 6654 } | 6598 } |
| 6655 | 6599 |
| 6656 @override | 6600 @override |
| 6657 ConstructorElement lookUpConstructor(String constructorName, | 6601 ConstructorElement lookUpConstructor( |
| 6658 LibraryElement library) { | 6602 String constructorName, LibraryElement library) { |
| 6659 // prepare base ConstructorElement | 6603 // prepare base ConstructorElement |
| 6660 ConstructorElement constructorElement; | 6604 ConstructorElement constructorElement; |
| 6661 if (constructorName == null) { | 6605 if (constructorName == null) { |
| 6662 constructorElement = element.unnamedConstructor; | 6606 constructorElement = element.unnamedConstructor; |
| 6663 } else { | 6607 } else { |
| 6664 constructorElement = element.getNamedConstructor(constructorName); | 6608 constructorElement = element.getNamedConstructor(constructorName); |
| 6665 } | 6609 } |
| 6666 // not found or not accessible | 6610 // not found or not accessible |
| 6667 if (constructorElement == null || | 6611 if (constructorElement == null || |
| 6668 !constructorElement.isAccessibleIn(library)) { | 6612 !constructorElement.isAccessibleIn(library)) { |
| 6669 return null; | 6613 return null; |
| 6670 } | 6614 } |
| 6671 // return member | 6615 // return member |
| 6672 return ConstructorMember.from(constructorElement, this); | 6616 return ConstructorMember.from(constructorElement, this); |
| 6673 } | 6617 } |
| 6674 | 6618 |
| 6675 @override | 6619 @override |
| 6676 PropertyAccessorElement lookUpGetter(String getterName, | 6620 PropertyAccessorElement lookUpGetter( |
| 6677 LibraryElement library) { | 6621 String getterName, LibraryElement library) { |
| 6678 PropertyAccessorElement element = getGetter(getterName); | 6622 PropertyAccessorElement element = getGetter(getterName); |
| 6679 if (element != null && element.isAccessibleIn(library)) { | 6623 if (element != null && element.isAccessibleIn(library)) { |
| 6680 return element; | 6624 return element; |
| 6681 } | 6625 } |
| 6682 return lookUpGetterInSuperclass(getterName, library); | 6626 return lookUpGetterInSuperclass(getterName, library); |
| 6683 } | 6627 } |
| 6684 | 6628 |
| 6685 @override | 6629 @override |
| 6686 PropertyAccessorElement lookUpGetterInSuperclass(String getterName, | 6630 PropertyAccessorElement lookUpGetterInSuperclass( |
| 6687 LibraryElement library) { | 6631 String getterName, LibraryElement library) { |
| 6688 for (InterfaceType mixin in mixins.reversed) { | 6632 for (InterfaceType mixin in mixins.reversed) { |
| 6689 PropertyAccessorElement element = mixin.getGetter(getterName); | 6633 PropertyAccessorElement element = mixin.getGetter(getterName); |
| 6690 if (element != null && element.isAccessibleIn(library)) { | 6634 if (element != null && element.isAccessibleIn(library)) { |
| 6691 return element; | 6635 return element; |
| 6692 } | 6636 } |
| 6693 } | 6637 } |
| 6694 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); | 6638 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); |
| 6695 InterfaceType supertype = superclass; | 6639 InterfaceType supertype = superclass; |
| 6696 ClassElement supertypeElement = | 6640 ClassElement supertypeElement = |
| 6697 supertype == null ? null : supertype.element; | 6641 supertype == null ? null : supertype.element; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 6716 @override | 6660 @override |
| 6717 MethodElement lookUpMethod(String methodName, LibraryElement library) { | 6661 MethodElement lookUpMethod(String methodName, LibraryElement library) { |
| 6718 MethodElement element = getMethod(methodName); | 6662 MethodElement element = getMethod(methodName); |
| 6719 if (element != null && element.isAccessibleIn(library)) { | 6663 if (element != null && element.isAccessibleIn(library)) { |
| 6720 return element; | 6664 return element; |
| 6721 } | 6665 } |
| 6722 return lookUpMethodInSuperclass(methodName, library); | 6666 return lookUpMethodInSuperclass(methodName, library); |
| 6723 } | 6667 } |
| 6724 | 6668 |
| 6725 @override | 6669 @override |
| 6726 MethodElement lookUpMethodInSuperclass(String methodName, | 6670 MethodElement lookUpMethodInSuperclass( |
| 6727 LibraryElement library) { | 6671 String methodName, LibraryElement library) { |
| 6728 for (InterfaceType mixin in mixins.reversed) { | 6672 for (InterfaceType mixin in mixins.reversed) { |
| 6729 MethodElement element = mixin.getMethod(methodName); | 6673 MethodElement element = mixin.getMethod(methodName); |
| 6730 if (element != null && element.isAccessibleIn(library)) { | 6674 if (element != null && element.isAccessibleIn(library)) { |
| 6731 return element; | 6675 return element; |
| 6732 } | 6676 } |
| 6733 } | 6677 } |
| 6734 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); | 6678 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); |
| 6735 InterfaceType supertype = superclass; | 6679 InterfaceType supertype = superclass; |
| 6736 ClassElement supertypeElement = | 6680 ClassElement supertypeElement = |
| 6737 supertype == null ? null : supertype.element; | 6681 supertype == null ? null : supertype.element; |
| 6738 while (supertype != null && !visitedClasses.contains(supertypeElement)) { | 6682 while (supertype != null && !visitedClasses.contains(supertypeElement)) { |
| 6739 visitedClasses.add(supertypeElement); | 6683 visitedClasses.add(supertypeElement); |
| 6740 MethodElement element = supertype.getMethod(methodName); | 6684 MethodElement element = supertype.getMethod(methodName); |
| 6741 if (element != null && element.isAccessibleIn(library)) { | 6685 if (element != null && element.isAccessibleIn(library)) { |
| 6742 return element; | 6686 return element; |
| 6743 } | 6687 } |
| 6744 for (InterfaceType mixin in supertype.mixins.reversed) { | 6688 for (InterfaceType mixin in supertype.mixins.reversed) { |
| 6745 element = mixin.getMethod(methodName); | 6689 element = mixin.getMethod(methodName); |
| 6746 if (element != null && element.isAccessibleIn(library)) { | 6690 if (element != null && element.isAccessibleIn(library)) { |
| 6747 return element; | 6691 return element; |
| 6748 } | 6692 } |
| 6749 } | 6693 } |
| 6750 supertype = supertype.superclass; | 6694 supertype = supertype.superclass; |
| 6751 supertypeElement = supertype == null ? null : supertype.element; | 6695 supertypeElement = supertype == null ? null : supertype.element; |
| 6752 } | 6696 } |
| 6753 return null; | 6697 return null; |
| 6754 } | 6698 } |
| 6755 | 6699 |
| 6756 @override | 6700 @override |
| 6757 PropertyAccessorElement lookUpSetter(String setterName, | 6701 PropertyAccessorElement lookUpSetter( |
| 6758 LibraryElement library) { | 6702 String setterName, LibraryElement library) { |
| 6759 PropertyAccessorElement element = getSetter(setterName); | 6703 PropertyAccessorElement element = getSetter(setterName); |
| 6760 if (element != null && element.isAccessibleIn(library)) { | 6704 if (element != null && element.isAccessibleIn(library)) { |
| 6761 return element; | 6705 return element; |
| 6762 } | 6706 } |
| 6763 return lookUpSetterInSuperclass(setterName, library); | 6707 return lookUpSetterInSuperclass(setterName, library); |
| 6764 } | 6708 } |
| 6765 | 6709 |
| 6766 @override | 6710 @override |
| 6767 PropertyAccessorElement lookUpSetterInSuperclass(String setterName, | 6711 PropertyAccessorElement lookUpSetterInSuperclass( |
| 6768 LibraryElement library) { | 6712 String setterName, LibraryElement library) { |
| 6769 for (InterfaceType mixin in mixins.reversed) { | 6713 for (InterfaceType mixin in mixins.reversed) { |
| 6770 PropertyAccessorElement element = mixin.getSetter(setterName); | 6714 PropertyAccessorElement element = mixin.getSetter(setterName); |
| 6771 if (element != null && element.isAccessibleIn(library)) { | 6715 if (element != null && element.isAccessibleIn(library)) { |
| 6772 return element; | 6716 return element; |
| 6773 } | 6717 } |
| 6774 } | 6718 } |
| 6775 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); | 6719 HashSet<ClassElement> visitedClasses = new HashSet<ClassElement>(); |
| 6776 InterfaceType supertype = superclass; | 6720 InterfaceType supertype = superclass; |
| 6777 ClassElement supertypeElement = | 6721 ClassElement supertypeElement = |
| 6778 supertype == null ? null : supertype.element; | 6722 supertype == null ? null : supertype.element; |
| 6779 while (supertype != null && !visitedClasses.contains(supertypeElement)) { | 6723 while (supertype != null && !visitedClasses.contains(supertypeElement)) { |
| 6780 visitedClasses.add(supertypeElement); | 6724 visitedClasses.add(supertypeElement); |
| 6781 PropertyAccessorElement element = supertype.getSetter(setterName); | 6725 PropertyAccessorElement element = supertype.getSetter(setterName); |
| 6782 if (element != null && element.isAccessibleIn(library)) { | 6726 if (element != null && element.isAccessibleIn(library)) { |
| 6783 return element; | 6727 return element; |
| 6784 } | 6728 } |
| 6785 for (InterfaceType mixin in supertype.mixins.reversed) { | 6729 for (InterfaceType mixin in supertype.mixins.reversed) { |
| 6786 element = mixin.getSetter(setterName); | 6730 element = mixin.getSetter(setterName); |
| 6787 if (element != null && element.isAccessibleIn(library)) { | 6731 if (element != null && element.isAccessibleIn(library)) { |
| 6788 return element; | 6732 return element; |
| 6789 } | 6733 } |
| 6790 } | 6734 } |
| 6791 supertype = supertype.superclass; | 6735 supertype = supertype.superclass; |
| 6792 supertypeElement = supertype == null ? null : supertype.element; | 6736 supertypeElement = supertype == null ? null : supertype.element; |
| 6793 } | 6737 } |
| 6794 return null; | 6738 return null; |
| 6795 } | 6739 } |
| 6796 | 6740 |
| 6797 @override | 6741 @override |
| 6798 InterfaceTypeImpl substitute2(List<DartType> argumentTypes, | 6742 InterfaceTypeImpl substitute2( |
| 6799 List<DartType> parameterTypes) { | 6743 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 6800 if (argumentTypes.length != parameterTypes.length) { | 6744 if (argumentTypes.length != parameterTypes.length) { |
| 6801 throw new IllegalArgumentException( | 6745 throw new IllegalArgumentException( |
| 6802 "argumentTypes.length (${argumentTypes.length}) != parameterTypes.leng
th (${parameterTypes.length})"); | 6746 "argumentTypes.length (${argumentTypes.length}) != parameterTypes.leng
th (${parameterTypes.length})"); |
| 6803 } | 6747 } |
| 6804 if (argumentTypes.length == 0 || typeArguments.length == 0) { | 6748 if (argumentTypes.length == 0 || typeArguments.length == 0) { |
| 6805 return this; | 6749 return this; |
| 6806 } | 6750 } |
| 6807 List<DartType> newTypeArguments = | 6751 List<DartType> newTypeArguments = |
| 6808 TypeImpl.substitute(typeArguments, argumentTypes, parameterTypes); | 6752 TypeImpl.substitute(typeArguments, argumentTypes, parameterTypes); |
| 6809 if (JavaArrays.equals(newTypeArguments, typeArguments)) { | 6753 if (JavaArrays.equals(newTypeArguments, typeArguments)) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6845 ClassElement tElement = this.element; | 6789 ClassElement tElement = this.element; |
| 6846 ClassElement sElement = s.element; | 6790 ClassElement sElement = s.element; |
| 6847 if (tElement == sElement) { | 6791 if (tElement == sElement) { |
| 6848 List<DartType> tArguments = typeArguments; | 6792 List<DartType> tArguments = typeArguments; |
| 6849 List<DartType> sArguments = s.typeArguments; | 6793 List<DartType> sArguments = s.typeArguments; |
| 6850 if (tArguments.length != sArguments.length) { | 6794 if (tArguments.length != sArguments.length) { |
| 6851 return false; | 6795 return false; |
| 6852 } | 6796 } |
| 6853 for (int i = 0; i < tArguments.length; i++) { | 6797 for (int i = 0; i < tArguments.length; i++) { |
| 6854 if (!(tArguments[i] as TypeImpl).isMoreSpecificThan2( | 6798 if (!(tArguments[i] as TypeImpl).isMoreSpecificThan2( |
| 6855 sArguments[i], | 6799 sArguments[i], withDynamic, visitedTypePairs)) { |
| 6856 withDynamic, | |
| 6857 visitedTypePairs)) { | |
| 6858 return false; | 6800 return false; |
| 6859 } | 6801 } |
| 6860 } | 6802 } |
| 6861 return true; | 6803 return true; |
| 6862 } | 6804 } |
| 6863 // | 6805 // |
| 6864 // Transitivity: T << U and U << S. | 6806 // Transitivity: T << U and U << S. |
| 6865 // | 6807 // |
| 6866 // First check for infinite loops | 6808 // First check for infinite loops |
| 6867 ClassElement element = this.element; | 6809 ClassElement element = this.element; |
| 6868 if (element == null || visitedClasses.contains(element)) { | 6810 if (element == null || visitedClasses.contains(element)) { |
| 6869 return false; | 6811 return false; |
| 6870 } | 6812 } |
| 6871 visitedClasses.add(element); | 6813 visitedClasses.add(element); |
| 6872 // Iterate over all of the types U that are more specific than T because | 6814 // Iterate over all of the types U that are more specific than T because |
| 6873 // they are direct supertypes of T and return true if any of them are more | 6815 // they are direct supertypes of T and return true if any of them are more |
| 6874 // specific than S. | 6816 // specific than S. |
| 6875 InterfaceType supertype = superclass; | 6817 InterfaceType supertype = superclass; |
| 6876 if (supertype != null && | 6818 if (supertype != null && |
| 6877 (supertype as InterfaceTypeImpl)._isMoreSpecificThan( | 6819 (supertype as InterfaceTypeImpl)._isMoreSpecificThan( |
| 6878 s, | 6820 s, visitedClasses, withDynamic, visitedTypePairs)) { |
| 6879 visitedClasses, | |
| 6880 withDynamic, | |
| 6881 visitedTypePairs)) { | |
| 6882 return true; | 6821 return true; |
| 6883 } | 6822 } |
| 6884 for (InterfaceType interfaceType in interfaces) { | 6823 for (InterfaceType interfaceType in interfaces) { |
| 6885 if ((interfaceType as InterfaceTypeImpl)._isMoreSpecificThan( | 6824 if ((interfaceType as InterfaceTypeImpl)._isMoreSpecificThan( |
| 6886 s, | 6825 s, visitedClasses, withDynamic, visitedTypePairs)) { |
| 6887 visitedClasses, | |
| 6888 withDynamic, | |
| 6889 visitedTypePairs)) { | |
| 6890 return true; | 6826 return true; |
| 6891 } | 6827 } |
| 6892 } | 6828 } |
| 6893 for (InterfaceType mixinType in mixins) { | 6829 for (InterfaceType mixinType in mixins) { |
| 6894 if ((mixinType as InterfaceTypeImpl)._isMoreSpecificThan( | 6830 if ((mixinType as InterfaceTypeImpl)._isMoreSpecificThan( |
| 6895 s, | 6831 s, visitedClasses, withDynamic, visitedTypePairs)) { |
| 6896 visitedClasses, | |
| 6897 withDynamic, | |
| 6898 visitedTypePairs)) { | |
| 6899 return true; | 6832 return true; |
| 6900 } | 6833 } |
| 6901 } | 6834 } |
| 6902 return false; | 6835 return false; |
| 6903 } | 6836 } |
| 6904 | 6837 |
| 6905 bool _isSubtypeOf(InterfaceType type, HashSet<ClassElement> visitedClasses, | 6838 bool _isSubtypeOf(InterfaceType type, HashSet<ClassElement> visitedClasses, |
| 6906 Set<TypeImpl_TypePair> visitedTypePairs) { | 6839 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 6907 InterfaceType typeT = this; | 6840 InterfaceType typeT = this; |
| 6908 InterfaceType typeS = type; | 6841 InterfaceType typeS = type; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 6920 List<DartType> typeSArgs = typeS.typeArguments; | 6853 List<DartType> typeSArgs = typeS.typeArguments; |
| 6921 if (typeTArgs.length != typeSArgs.length) { | 6854 if (typeTArgs.length != typeSArgs.length) { |
| 6922 // This case covers the case where two objects are being compared that | 6855 // This case covers the case where two objects are being compared that |
| 6923 // have a different number of parameterized types. | 6856 // have a different number of parameterized types. |
| 6924 return false; | 6857 return false; |
| 6925 } | 6858 } |
| 6926 for (int i = 0; i < typeTArgs.length; i++) { | 6859 for (int i = 0; i < typeTArgs.length; i++) { |
| 6927 // Recursively call isSubtypeOf the type arguments and return false if | 6860 // Recursively call isSubtypeOf the type arguments and return false if |
| 6928 // the T argument is not a subtype of the S argument. | 6861 // the T argument is not a subtype of the S argument. |
| 6929 if (!(typeTArgs[i] as TypeImpl).isSubtypeOf2( | 6862 if (!(typeTArgs[i] as TypeImpl).isSubtypeOf2( |
| 6930 typeSArgs[i], | 6863 typeSArgs[i], visitedTypePairs)) { |
| 6931 visitedTypePairs)) { | |
| 6932 return false; | 6864 return false; |
| 6933 } | 6865 } |
| 6934 } | 6866 } |
| 6935 return true; | 6867 return true; |
| 6936 } else if (typeS.isDartCoreFunction && elementT.getMethod("call") != null) { | 6868 } else if (typeS.isDartCoreFunction && elementT.getMethod("call") != null) { |
| 6937 return true; | 6869 return true; |
| 6938 } | 6870 } |
| 6939 InterfaceType supertype = superclass; | 6871 InterfaceType supertype = superclass; |
| 6940 // The type is Object, return false. | 6872 // The type is Object, return false. |
| 6941 if (supertype != null && | 6873 if (supertype != null && |
| 6942 (supertype as InterfaceTypeImpl)._isSubtypeOf( | 6874 (supertype as InterfaceTypeImpl)._isSubtypeOf( |
| 6943 typeS, | 6875 typeS, visitedClasses, visitedTypePairs)) { |
| 6944 visitedClasses, | |
| 6945 visitedTypePairs)) { | |
| 6946 return true; | 6876 return true; |
| 6947 } | 6877 } |
| 6948 List<InterfaceType> interfaceTypes = interfaces; | 6878 List<InterfaceType> interfaceTypes = interfaces; |
| 6949 for (InterfaceType interfaceType in interfaceTypes) { | 6879 for (InterfaceType interfaceType in interfaceTypes) { |
| 6950 if ((interfaceType as InterfaceTypeImpl)._isSubtypeOf( | 6880 if ((interfaceType as InterfaceTypeImpl)._isSubtypeOf( |
| 6951 typeS, | 6881 typeS, visitedClasses, visitedTypePairs)) { |
| 6952 visitedClasses, | |
| 6953 visitedTypePairs)) { | |
| 6954 return true; | 6882 return true; |
| 6955 } | 6883 } |
| 6956 } | 6884 } |
| 6957 List<InterfaceType> mixinTypes = mixins; | 6885 List<InterfaceType> mixinTypes = mixins; |
| 6958 for (InterfaceType mixinType in mixinTypes) { | 6886 for (InterfaceType mixinType in mixinTypes) { |
| 6959 if ((mixinType as InterfaceTypeImpl)._isSubtypeOf( | 6887 if ((mixinType as InterfaceTypeImpl)._isSubtypeOf( |
| 6960 typeS, | 6888 typeS, visitedClasses, visitedTypePairs)) { |
| 6961 visitedClasses, | |
| 6962 visitedTypePairs)) { | |
| 6963 return true; | 6889 return true; |
| 6964 } | 6890 } |
| 6965 } | 6891 } |
| 6966 return false; | 6892 return false; |
| 6967 } | 6893 } |
| 6968 | 6894 |
| 6969 /** | 6895 /** |
| 6970 * This method computes the longest inheritance path from some passed [Type] t
o Object. | 6896 * This method computes the longest inheritance path from some passed [Type] t
o Object. |
| 6971 * | 6897 * |
| 6972 * @param type the [Type] to compute the longest inheritance path of from the
passed | 6898 * @param type the [Type] to compute the longest inheritance path of from the
passed |
| 6973 * [Type] to Object | 6899 * [Type] to Object |
| 6974 * @return the computed longest inheritance path to Object | 6900 * @return the computed longest inheritance path to Object |
| 6975 * See [InterfaceType.getLeastUpperBound]. | 6901 * See [InterfaceType.getLeastUpperBound]. |
| 6976 */ | 6902 */ |
| 6977 static int computeLongestInheritancePathToObject(InterfaceType type) => | 6903 static int computeLongestInheritancePathToObject(InterfaceType type) => |
| 6978 _computeLongestInheritancePathToObject(type, 0, new HashSet<ClassElement>(
)); | 6904 _computeLongestInheritancePathToObject( |
| 6905 type, 0, new HashSet<ClassElement>()); |
| 6979 | 6906 |
| 6980 /** | 6907 /** |
| 6981 * Returns the set of all superinterfaces of the passed [Type]. | 6908 * Returns the set of all superinterfaces of the passed [Type]. |
| 6982 * | 6909 * |
| 6983 * @param type the [Type] to compute the set of superinterfaces of | 6910 * @param type the [Type] to compute the set of superinterfaces of |
| 6984 * @return the [Set] of superinterfaces of the passed [Type] | 6911 * @return the [Set] of superinterfaces of the passed [Type] |
| 6985 * See [getLeastUpperBound]. | 6912 * See [getLeastUpperBound]. |
| 6986 */ | 6913 */ |
| 6987 static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) => | 6914 static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) => |
| 6988 _computeSuperinterfaceSet(type, new HashSet<InterfaceType>()); | 6915 _computeSuperinterfaceSet(type, new HashSet<InterfaceType>()); |
| 6989 | 6916 |
| 6990 /** | 6917 /** |
| 6991 * This method computes the longest inheritance path from some passed [Type] t
o Object. This | 6918 * This method computes the longest inheritance path from some passed [Type] t
o Object. This |
| 6992 * method calls itself recursively, callers should use the public method | 6919 * method calls itself recursively, callers should use the public method |
| 6993 * [computeLongestInheritancePathToObject]. | 6920 * [computeLongestInheritancePathToObject]. |
| 6994 * | 6921 * |
| 6995 * @param type the [Type] to compute the longest inheritance path of from the
passed | 6922 * @param type the [Type] to compute the longest inheritance path of from the
passed |
| 6996 * [Type] to Object | 6923 * [Type] to Object |
| 6997 * @param depth a field used recursively | 6924 * @param depth a field used recursively |
| 6998 * @param visitedClasses the classes that have already been visited | 6925 * @param visitedClasses the classes that have already been visited |
| 6999 * @return the computed longest inheritance path to Object | 6926 * @return the computed longest inheritance path to Object |
| 7000 * See [computeLongestInheritancePathToObject], and [getLeastUpperBound]. | 6927 * See [computeLongestInheritancePathToObject], and [getLeastUpperBound]. |
| 7001 */ | 6928 */ |
| 7002 static int _computeLongestInheritancePathToObject(InterfaceType type, | 6929 static int _computeLongestInheritancePathToObject( |
| 7003 int depth, HashSet<ClassElement> visitedClasses) { | 6930 InterfaceType type, int depth, HashSet<ClassElement> visitedClasses) { |
| 7004 ClassElement classElement = type.element; | 6931 ClassElement classElement = type.element; |
| 7005 // Object case | 6932 // Object case |
| 7006 if (classElement.supertype == null || | 6933 if (classElement.supertype == null || |
| 7007 visitedClasses.contains(classElement)) { | 6934 visitedClasses.contains(classElement)) { |
| 7008 return depth; | 6935 return depth; |
| 7009 } | 6936 } |
| 7010 int longestPath = 1; | 6937 int longestPath = 1; |
| 7011 try { | 6938 try { |
| 7012 visitedClasses.add(classElement); | 6939 visitedClasses.add(classElement); |
| 7013 List<InterfaceType> superinterfaces = classElement.interfaces; | 6940 List<InterfaceType> superinterfaces = classElement.interfaces; |
| 7014 int pathLength; | 6941 int pathLength; |
| 7015 if (superinterfaces.length > 0) { | 6942 if (superinterfaces.length > 0) { |
| 7016 // loop through each of the superinterfaces recursively calling this | 6943 // loop through each of the superinterfaces recursively calling this |
| 7017 // method and keeping track of the longest path to return | 6944 // method and keeping track of the longest path to return |
| 7018 for (InterfaceType superinterface in superinterfaces) { | 6945 for (InterfaceType superinterface in superinterfaces) { |
| 7019 pathLength = _computeLongestInheritancePathToObject( | 6946 pathLength = _computeLongestInheritancePathToObject( |
| 7020 superinterface, | 6947 superinterface, depth + 1, visitedClasses); |
| 7021 depth + 1, | |
| 7022 visitedClasses); | |
| 7023 if (pathLength > longestPath) { | 6948 if (pathLength > longestPath) { |
| 7024 longestPath = pathLength; | 6949 longestPath = pathLength; |
| 7025 } | 6950 } |
| 7026 } | 6951 } |
| 7027 } | 6952 } |
| 7028 // finally, perform this same check on the super type | 6953 // finally, perform this same check on the super type |
| 7029 // TODO(brianwilkerson) Does this also need to add in the number of mixin | 6954 // TODO(brianwilkerson) Does this also need to add in the number of mixin |
| 7030 // classes? | 6955 // classes? |
| 7031 InterfaceType supertype = classElement.supertype; | 6956 InterfaceType supertype = classElement.supertype; |
| 7032 pathLength = | 6957 pathLength = _computeLongestInheritancePathToObject( |
| 7033 _computeLongestInheritancePathToObject(supertype, depth + 1, visitedCl
asses); | 6958 supertype, depth + 1, visitedClasses); |
| 7034 if (pathLength > longestPath) { | 6959 if (pathLength > longestPath) { |
| 7035 longestPath = pathLength; | 6960 longestPath = pathLength; |
| 7036 } | 6961 } |
| 7037 } finally { | 6962 } finally { |
| 7038 visitedClasses.remove(classElement); | 6963 visitedClasses.remove(classElement); |
| 7039 } | 6964 } |
| 7040 return longestPath; | 6965 return longestPath; |
| 7041 } | 6966 } |
| 7042 | 6967 |
| 7043 /** | 6968 /** |
| 7044 * Returns the set of all superinterfaces of the passed [Type]. This is a recu
rsive method, | 6969 * Returns the set of all superinterfaces of the passed [Type]. This is a recu
rsive method, |
| 7045 * callers should call the public [computeSuperinterfaceSet]. | 6970 * callers should call the public [computeSuperinterfaceSet]. |
| 7046 * | 6971 * |
| 7047 * @param type the [Type] to compute the set of superinterfaces of | 6972 * @param type the [Type] to compute the set of superinterfaces of |
| 7048 * @param set a [HashSet] used recursively by this method | 6973 * @param set a [HashSet] used recursively by this method |
| 7049 * @return the [Set] of superinterfaces of the passed [Type] | 6974 * @return the [Set] of superinterfaces of the passed [Type] |
| 7050 * See [computeSuperinterfaceSet], and [getLeastUpperBound]. | 6975 * See [computeSuperinterfaceSet], and [getLeastUpperBound]. |
| 7051 */ | 6976 */ |
| 7052 static Set<InterfaceType> _computeSuperinterfaceSet(InterfaceType type, | 6977 static Set<InterfaceType> _computeSuperinterfaceSet( |
| 7053 HashSet<InterfaceType> set) { | 6978 InterfaceType type, HashSet<InterfaceType> set) { |
| 7054 Element element = type.element; | 6979 Element element = type.element; |
| 7055 if (element != null) { | 6980 if (element != null) { |
| 7056 List<InterfaceType> superinterfaces = type.interfaces; | 6981 List<InterfaceType> superinterfaces = type.interfaces; |
| 7057 for (InterfaceType superinterface in superinterfaces) { | 6982 for (InterfaceType superinterface in superinterfaces) { |
| 7058 if (set.add(superinterface)) { | 6983 if (set.add(superinterface)) { |
| 7059 _computeSuperinterfaceSet(superinterface, set); | 6984 _computeSuperinterfaceSet(superinterface, set); |
| 7060 } | 6985 } |
| 7061 } | 6986 } |
| 7062 InterfaceType supertype = type.superclass; | 6987 InterfaceType supertype = type.superclass; |
| 7063 if (supertype != null) { | 6988 if (supertype != null) { |
| 7064 if (set.add(supertype)) { | 6989 if (set.add(supertype)) { |
| 7065 _computeSuperinterfaceSet(supertype, set); | 6990 _computeSuperinterfaceSet(supertype, set); |
| 7066 } | 6991 } |
| 7067 } | 6992 } |
| 7068 } | 6993 } |
| 7069 return set; | 6994 return set; |
| 7070 } | 6995 } |
| 7071 | 6996 |
| 7072 /** | 6997 /** |
| 7073 * Return the intersection of the given sets of types, where intersection is b
ased on the equality | 6998 * Return the intersection of the given sets of types, where intersection is b
ased on the equality |
| 7074 * of the types themselves. | 6999 * of the types themselves. |
| 7075 * | 7000 * |
| 7076 * @param first the first set of types to be intersected | 7001 * @param first the first set of types to be intersected |
| 7077 * @param second the second set of types to be intersected | 7002 * @param second the second set of types to be intersected |
| 7078 * @return the intersection of the given sets of types | 7003 * @return the intersection of the given sets of types |
| 7079 */ | 7004 */ |
| 7080 static List<InterfaceType> _intersection(Set<InterfaceType> first, | 7005 static List<InterfaceType> _intersection( |
| 7081 Set<InterfaceType> second) { | 7006 Set<InterfaceType> first, Set<InterfaceType> second) { |
| 7082 Set<InterfaceType> result = new HashSet<InterfaceType>.from(first); | 7007 Set<InterfaceType> result = new HashSet<InterfaceType>.from(first); |
| 7083 result.retainAll(second); | 7008 result.retainAll(second); |
| 7084 return new List.from(result); | 7009 return new List.from(result); |
| 7085 } | 7010 } |
| 7086 } | 7011 } |
| 7087 | 7012 |
| 7088 /** | 7013 /** |
| 7089 * The interface `LabelElement` defines the behavior of elements representing a
label | 7014 * The interface `LabelElement` defines the behavior of elements representing a
label |
| 7090 * associated with a statement. | 7015 * associated with a statement. |
| 7091 */ | 7016 */ |
| (...skipping 28 matching lines...) Expand all Loading... |
| 7120 final bool _onSwitchMember; | 7045 final bool _onSwitchMember; |
| 7121 | 7046 |
| 7122 /** | 7047 /** |
| 7123 * Initialize a newly created label element to have the given name. | 7048 * Initialize a newly created label element to have the given name. |
| 7124 * | 7049 * |
| 7125 * @param name the name of this element | 7050 * @param name the name of this element |
| 7126 * @param onSwitchStatement `true` if this label is associated with a `switch` | 7051 * @param onSwitchStatement `true` if this label is associated with a `switch` |
| 7127 * statement | 7052 * statement |
| 7128 * @param onSwitchMember `true` if this label is associated with a `switch` me
mber | 7053 * @param onSwitchMember `true` if this label is associated with a `switch` me
mber |
| 7129 */ | 7054 */ |
| 7130 LabelElementImpl(Identifier name, this._onSwitchStatement, | 7055 LabelElementImpl( |
| 7131 this._onSwitchMember) | 7056 Identifier name, this._onSwitchStatement, this._onSwitchMember) |
| 7132 : super.forNode(name); | 7057 : super.forNode(name); |
| 7133 | 7058 |
| 7134 @override | 7059 @override |
| 7135 ExecutableElement get enclosingElement => | 7060 ExecutableElement get enclosingElement => |
| 7136 super.enclosingElement as ExecutableElement; | 7061 super.enclosingElement as ExecutableElement; |
| 7137 | 7062 |
| 7138 /** | 7063 /** |
| 7139 * Return `true` if this label is associated with a `switch` member (`case` or | 7064 * Return `true` if this label is associated with a `switch` member (`case` or |
| 7140 * `default`). | 7065 * `default`). |
| 7141 * | 7066 * |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7374 | 7299 |
| 7375 @override | 7300 @override |
| 7376 CompilationUnitElement get definingCompilationUnit => | 7301 CompilationUnitElement get definingCompilationUnit => |
| 7377 _definingCompilationUnit; | 7302 _definingCompilationUnit; |
| 7378 | 7303 |
| 7379 /** | 7304 /** |
| 7380 * Set the compilation unit that defines this library to the given compilation
unit. | 7305 * Set the compilation unit that defines this library to the given compilation
unit. |
| 7381 * | 7306 * |
| 7382 * @param definingCompilationUnit the compilation unit that defines this libra
ry | 7307 * @param definingCompilationUnit the compilation unit that defines this libra
ry |
| 7383 */ | 7308 */ |
| 7384 void set | 7309 void set definingCompilationUnit( |
| 7385 definingCompilationUnit(CompilationUnitElement definingCompilationUnit) { | 7310 CompilationUnitElement definingCompilationUnit) { |
| 7386 (definingCompilationUnit as CompilationUnitElementImpl).enclosingElement = | 7311 (definingCompilationUnit as CompilationUnitElementImpl).enclosingElement = |
| 7387 this; | 7312 this; |
| 7388 this._definingCompilationUnit = definingCompilationUnit; | 7313 this._definingCompilationUnit = definingCompilationUnit; |
| 7389 } | 7314 } |
| 7390 | 7315 |
| 7391 @override | 7316 @override |
| 7392 List<LibraryElement> get exportedLibraries { | 7317 List<LibraryElement> get exportedLibraries { |
| 7393 HashSet<LibraryElement> libraries = new HashSet<LibraryElement>(); | 7318 HashSet<LibraryElement> libraries = new HashSet<LibraryElement>(); |
| 7394 for (ExportElement element in _exports) { | 7319 for (ExportElement element in _exports) { |
| 7395 LibraryElement library = element.exportedLibrary; | 7320 LibraryElement library = element.exportedLibrary; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7540 /** | 7465 /** |
| 7541 * Return the object representing the type "Future" from the dart:async librar
y, or the type | 7466 * Return the object representing the type "Future" from the dart:async librar
y, or the type |
| 7542 * "void" if the type "Future" cannot be accessed. | 7467 * "void" if the type "Future" cannot be accessed. |
| 7543 * | 7468 * |
| 7544 * @return the type "Future" from the dart:async library | 7469 * @return the type "Future" from the dart:async library |
| 7545 */ | 7470 */ |
| 7546 DartType get loadLibraryReturnType { | 7471 DartType get loadLibraryReturnType { |
| 7547 try { | 7472 try { |
| 7548 Source asyncSource = context.sourceFactory.forUri(DartSdk.DART_ASYNC); | 7473 Source asyncSource = context.sourceFactory.forUri(DartSdk.DART_ASYNC); |
| 7549 if (asyncSource == null) { | 7474 if (asyncSource == null) { |
| 7550 AnalysisEngine.instance.logger.logError( | 7475 AnalysisEngine.instance.logger |
| 7551 "Could not create a source for dart:async"); | 7476 .logError("Could not create a source for dart:async"); |
| 7552 return VoidTypeImpl.instance; | 7477 return VoidTypeImpl.instance; |
| 7553 } | 7478 } |
| 7554 LibraryElement asyncElement = context.computeLibraryElement(asyncSource); | 7479 LibraryElement asyncElement = context.computeLibraryElement(asyncSource); |
| 7555 if (asyncElement == null) { | 7480 if (asyncElement == null) { |
| 7556 AnalysisEngine.instance.logger.logError( | 7481 AnalysisEngine.instance.logger |
| 7557 "Could not build the element model for dart:async"); | 7482 .logError("Could not build the element model for dart:async"); |
| 7558 return VoidTypeImpl.instance; | 7483 return VoidTypeImpl.instance; |
| 7559 } | 7484 } |
| 7560 ClassElement futureElement = asyncElement.getType("Future"); | 7485 ClassElement futureElement = asyncElement.getType("Future"); |
| 7561 if (futureElement == null) { | 7486 if (futureElement == null) { |
| 7562 AnalysisEngine.instance.logger.logError( | 7487 AnalysisEngine.instance.logger |
| 7563 "Could not find type Future in dart:async"); | 7488 .logError("Could not find type Future in dart:async"); |
| 7564 return VoidTypeImpl.instance; | 7489 return VoidTypeImpl.instance; |
| 7565 } | 7490 } |
| 7566 InterfaceType futureType = futureElement.type; | 7491 InterfaceType futureType = futureElement.type; |
| 7567 return futureType.substitute4(<DartType>[DynamicTypeImpl.instance]); | 7492 return futureType.substitute4(<DartType>[DynamicTypeImpl.instance]); |
| 7568 } on AnalysisException catch (exception, stackTrace) { | 7493 } on AnalysisException catch (exception, stackTrace) { |
| 7569 AnalysisEngine.instance.logger.logError( | 7494 AnalysisEngine.instance.logger.logError( |
| 7570 "Could not build the element model for dart:async", | 7495 "Could not build the element model for dart:async", |
| 7571 new CaughtException(exception, stackTrace)); | 7496 new CaughtException(exception, stackTrace)); |
| 7572 return VoidTypeImpl.instance; | 7497 return VoidTypeImpl.instance; |
| 7573 } | 7498 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7619 } | 7544 } |
| 7620 | 7545 |
| 7621 @override | 7546 @override |
| 7622 List<LibraryElement> get visibleLibraries { | 7547 List<LibraryElement> get visibleLibraries { |
| 7623 Set<LibraryElement> visibleLibraries = new Set(); | 7548 Set<LibraryElement> visibleLibraries = new Set(); |
| 7624 _addVisibleLibraries(visibleLibraries, false); | 7549 _addVisibleLibraries(visibleLibraries, false); |
| 7625 return new List.from(visibleLibraries); | 7550 return new List.from(visibleLibraries); |
| 7626 } | 7551 } |
| 7627 | 7552 |
| 7628 @override | 7553 @override |
| 7629 bool operator ==(Object object) => | 7554 bool operator ==(Object object) => object is LibraryElementImpl && |
| 7630 object is LibraryElementImpl && | 7555 _definingCompilationUnit == object.definingCompilationUnit; |
| 7631 _definingCompilationUnit == object.definingCompilationUnit; | |
| 7632 | 7556 |
| 7633 @override | 7557 @override |
| 7634 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); | 7558 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); |
| 7635 | 7559 |
| 7636 @override | 7560 @override |
| 7637 ElementImpl getChild(String identifier) { | 7561 ElementImpl getChild(String identifier) { |
| 7638 if ((_definingCompilationUnit as CompilationUnitElementImpl).identifier == | 7562 if ((_definingCompilationUnit as CompilationUnitElementImpl).identifier == |
| 7639 identifier) { | 7563 identifier) { |
| 7640 return _definingCompilationUnit as CompilationUnitElementImpl; | 7564 return _definingCompilationUnit as CompilationUnitElementImpl; |
| 7641 } | 7565 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7695 super.visitChildren(visitor); | 7619 super.visitChildren(visitor); |
| 7696 safelyVisitChild(_definingCompilationUnit, visitor); | 7620 safelyVisitChild(_definingCompilationUnit, visitor); |
| 7697 safelyVisitChildren(_exports, visitor); | 7621 safelyVisitChildren(_exports, visitor); |
| 7698 safelyVisitChildren(_imports, visitor); | 7622 safelyVisitChildren(_imports, visitor); |
| 7699 safelyVisitChildren(_parts, visitor); | 7623 safelyVisitChildren(_parts, visitor); |
| 7700 } | 7624 } |
| 7701 | 7625 |
| 7702 /** | 7626 /** |
| 7703 * Recursively fills set of visible libraries for [getVisibleElementsLibraries
]. | 7627 * Recursively fills set of visible libraries for [getVisibleElementsLibraries
]. |
| 7704 */ | 7628 */ |
| 7705 void _addVisibleLibraries(Set<LibraryElement> visibleLibraries, | 7629 void _addVisibleLibraries( |
| 7706 bool includeExports) { | 7630 Set<LibraryElement> visibleLibraries, bool includeExports) { |
| 7707 // maybe already processed | 7631 // maybe already processed |
| 7708 if (!visibleLibraries.add(this)) { | 7632 if (!visibleLibraries.add(this)) { |
| 7709 return; | 7633 return; |
| 7710 } | 7634 } |
| 7711 // add imported libraries | 7635 // add imported libraries |
| 7712 for (ImportElement importElement in _imports) { | 7636 for (ImportElement importElement in _imports) { |
| 7713 LibraryElement importedLibrary = importElement.importedLibrary; | 7637 LibraryElement importedLibrary = importElement.importedLibrary; |
| 7714 if (importedLibrary != null) { | 7638 if (importedLibrary != null) { |
| 7715 (importedLibrary as LibraryElementImpl)._addVisibleLibraries( | 7639 (importedLibrary as LibraryElementImpl)._addVisibleLibraries( |
| 7716 visibleLibraries, | 7640 visibleLibraries, true); |
| 7717 true); | |
| 7718 } | 7641 } |
| 7719 } | 7642 } |
| 7720 // add exported libraries | 7643 // add exported libraries |
| 7721 if (includeExports) { | 7644 if (includeExports) { |
| 7722 for (ExportElement exportElement in _exports) { | 7645 for (ExportElement exportElement in _exports) { |
| 7723 LibraryElement exportedLibrary = exportElement.exportedLibrary; | 7646 LibraryElement exportedLibrary = exportElement.exportedLibrary; |
| 7724 if (exportedLibrary != null) { | 7647 if (exportedLibrary != null) { |
| 7725 (exportedLibrary as LibraryElementImpl)._addVisibleLibraries( | 7648 (exportedLibrary as LibraryElementImpl)._addVisibleLibraries( |
| 7726 visibleLibraries, | 7649 visibleLibraries, true); |
| 7727 true); | |
| 7728 } | 7650 } |
| 7729 } | 7651 } |
| 7730 } | 7652 } |
| 7731 } | 7653 } |
| 7732 | 7654 |
| 7733 /** | 7655 /** |
| 7734 * Determine if the given library is up to date with respect to the given time
stamp. | 7656 * Determine if the given library is up to date with respect to the given time
stamp. |
| 7735 * | 7657 * |
| 7736 * @param library the library to process | 7658 * @param library the library to process |
| 7737 * @param timeStamp the time stamp to check against | 7659 * @param timeStamp the time stamp to check against |
| 7738 * @param visitedLibraries the set of visited libraries | 7660 * @param visitedLibraries the set of visited libraries |
| 7739 */ | 7661 */ |
| 7740 static bool _safeIsUpToDate(LibraryElement library, int timeStamp, | 7662 static bool _safeIsUpToDate(LibraryElement library, int timeStamp, |
| 7741 Set<LibraryElement> visitedLibraries) { | 7663 Set<LibraryElement> visitedLibraries) { |
| 7742 if (!visitedLibraries.contains(library)) { | 7664 if (!visitedLibraries.contains(library)) { |
| 7743 visitedLibraries.add(library); | 7665 visitedLibraries.add(library); |
| 7744 AnalysisContext context = library.context; | 7666 AnalysisContext context = library.context; |
| 7745 // Check the defining compilation unit. | 7667 // Check the defining compilation unit. |
| 7746 if (timeStamp < | 7668 if (timeStamp < |
| 7747 context.getModificationStamp(library.definingCompilationUnit.source))
{ | 7669 context |
| 7670 .getModificationStamp(library.definingCompilationUnit.source)) { |
| 7748 return false; | 7671 return false; |
| 7749 } | 7672 } |
| 7750 // Check the parted compilation units. | 7673 // Check the parted compilation units. |
| 7751 for (CompilationUnitElement element in library.parts) { | 7674 for (CompilationUnitElement element in library.parts) { |
| 7752 if (timeStamp < context.getModificationStamp(element.source)) { | 7675 if (timeStamp < context.getModificationStamp(element.source)) { |
| 7753 return false; | 7676 return false; |
| 7754 } | 7677 } |
| 7755 } | 7678 } |
| 7756 // Check the imported libraries. | 7679 // Check the imported libraries. |
| 7757 for (LibraryElement importedLibrary in library.importedLibraries) { | 7680 for (LibraryElement importedLibrary in library.importedLibraries) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7790 * | 7713 * |
| 7791 * @return the range of characters in which the name of this element is visibl
e | 7714 * @return the range of characters in which the name of this element is visibl
e |
| 7792 */ | 7715 */ |
| 7793 SourceRange get visibleRange; | 7716 SourceRange get visibleRange; |
| 7794 } | 7717 } |
| 7795 | 7718 |
| 7796 /** | 7719 /** |
| 7797 * The interface `LocalVariableElement` defines the behavior common to elements
that represent | 7720 * The interface `LocalVariableElement` defines the behavior common to elements
that represent |
| 7798 * a local variable. | 7721 * a local variable. |
| 7799 */ | 7722 */ |
| 7800 abstract class LocalVariableElement implements LocalElement, VariableElement { | 7723 abstract class LocalVariableElement implements LocalElement, VariableElement {} |
| 7801 } | |
| 7802 | 7724 |
| 7803 /** | 7725 /** |
| 7804 * Instances of the class `LocalVariableElementImpl` implement a `LocalVariableE
lement`. | 7726 * Instances of the class `LocalVariableElementImpl` implement a `LocalVariableE
lement`. |
| 7805 */ | 7727 */ |
| 7806 class LocalVariableElementImpl extends VariableElementImpl implements | 7728 class LocalVariableElementImpl extends VariableElementImpl |
| 7807 LocalVariableElement { | 7729 implements LocalVariableElement { |
| 7808 /** | 7730 /** |
| 7809 * An empty list of field elements. | 7731 * An empty list of field elements. |
| 7810 */ | 7732 */ |
| 7811 static const List<LocalVariableElement> EMPTY_ARRAY = const | 7733 static const List<LocalVariableElement> EMPTY_ARRAY = |
| 7812 <LocalVariableElement>[ | 7734 const <LocalVariableElement>[]; |
| 7813 ]; | |
| 7814 | 7735 |
| 7815 /** | 7736 /** |
| 7816 * The offset to the beginning of the visible range for this element. | 7737 * The offset to the beginning of the visible range for this element. |
| 7817 */ | 7738 */ |
| 7818 int _visibleRangeOffset = 0; | 7739 int _visibleRangeOffset = 0; |
| 7819 | 7740 |
| 7820 /** | 7741 /** |
| 7821 * The length of the visible range for this element, or `-1` if this element d
oes not have a | 7742 * The length of the visible range for this element, or `-1` if this element d
oes not have a |
| 7822 * visible range. | 7743 * visible range. |
| 7823 */ | 7744 */ |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8260 * If the given method's type is different when any type parameters from the d
efining type's | 8181 * If the given method's type is different when any type parameters from the d
efining type's |
| 8261 * declaration are replaced with the actual type arguments from the defining t
ype, create a method | 8182 * declaration are replaced with the actual type arguments from the defining t
ype, create a method |
| 8262 * member representing the given method. Return the member that was created, o
r the base method if | 8183 * member representing the given method. Return the member that was created, o
r the base method if |
| 8263 * no member was created. | 8184 * no member was created. |
| 8264 * | 8185 * |
| 8265 * @param baseMethod the base method for which a member might be created | 8186 * @param baseMethod the base method for which a member might be created |
| 8266 * @param definingType the type defining the parameters and arguments to be us
ed in the | 8187 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 8267 * substitution | 8188 * substitution |
| 8268 * @return the method element that will return the correctly substituted types | 8189 * @return the method element that will return the correctly substituted types |
| 8269 */ | 8190 */ |
| 8270 static MethodElement from(MethodElement baseMethod, | 8191 static MethodElement from( |
| 8271 InterfaceType definingType) { | 8192 MethodElement baseMethod, InterfaceType definingType) { |
| 8272 if (baseMethod == null || definingType.typeArguments.length == 0) { | 8193 if (baseMethod == null || definingType.typeArguments.length == 0) { |
| 8273 return baseMethod; | 8194 return baseMethod; |
| 8274 } | 8195 } |
| 8275 FunctionType baseType = baseMethod.type; | 8196 FunctionType baseType = baseMethod.type; |
| 8276 List<DartType> argumentTypes = definingType.typeArguments; | 8197 List<DartType> argumentTypes = definingType.typeArguments; |
| 8277 List<DartType> parameterTypes = definingType.element.type.typeArguments; | 8198 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 8278 FunctionType substitutedType = | 8199 FunctionType substitutedType = |
| 8279 baseType.substitute2(argumentTypes, parameterTypes); | 8200 baseType.substitute2(argumentTypes, parameterTypes); |
| 8280 if (baseType == substitutedType) { | 8201 if (baseType == substitutedType) { |
| 8281 return baseMethod; | 8202 return baseMethod; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8390 */ | 8311 */ |
| 8391 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 17); | 8312 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 17); |
| 8392 | 8313 |
| 8393 /** | 8314 /** |
| 8394 * Indicates that a class was defined using an alias. TODO(brianwilkerson) Thi
s should be renamed | 8315 * Indicates that a class was defined using an alias. TODO(brianwilkerson) Thi
s should be renamed |
| 8395 * to 'ALIAS'. | 8316 * to 'ALIAS'. |
| 8396 */ | 8317 */ |
| 8397 static const Modifier TYPEDEF = const Modifier('TYPEDEF', 18); | 8318 static const Modifier TYPEDEF = const Modifier('TYPEDEF', 18); |
| 8398 | 8319 |
| 8399 static const List<Modifier> values = const [ | 8320 static const List<Modifier> values = const [ |
| 8400 ABSTRACT, | 8321 ABSTRACT, |
| 8401 ASYNCHRONOUS, | 8322 ASYNCHRONOUS, |
| 8402 CONST, | 8323 CONST, |
| 8403 DEFERRED, | 8324 DEFERRED, |
| 8404 ENUM, | 8325 ENUM, |
| 8405 FACTORY, | 8326 FACTORY, |
| 8406 FINAL, | 8327 FINAL, |
| 8407 GENERATOR, | 8328 GENERATOR, |
| 8408 GETTER, | 8329 GETTER, |
| 8409 HAS_EXT_URI, | 8330 HAS_EXT_URI, |
| 8410 MIXIN, | 8331 MIXIN, |
| 8411 MIXIN_ERRORS_REPORTED, | 8332 MIXIN_ERRORS_REPORTED, |
| 8412 POTENTIALLY_MUTATED_IN_CONTEXT, | 8333 POTENTIALLY_MUTATED_IN_CONTEXT, |
| 8413 POTENTIALLY_MUTATED_IN_SCOPE, | 8334 POTENTIALLY_MUTATED_IN_SCOPE, |
| 8414 REFERENCES_SUPER, | 8335 REFERENCES_SUPER, |
| 8415 SETTER, | 8336 SETTER, |
| 8416 STATIC, | 8337 STATIC, |
| 8417 SYNTHETIC, | 8338 SYNTHETIC, |
| 8418 TYPEDEF]; | 8339 TYPEDEF |
| 8340 ]; |
| 8419 | 8341 |
| 8420 const Modifier(String name, int ordinal) : super(name, ordinal); | 8342 const Modifier(String name, int ordinal) : super(name, ordinal); |
| 8421 } | 8343 } |
| 8422 | 8344 |
| 8423 /** | 8345 /** |
| 8424 * The interface `MultiplyDefinedElement` defines the behavior of pseudo-element
s that | 8346 * The interface `MultiplyDefinedElement` defines the behavior of pseudo-element
s that |
| 8425 * represent multiple elements defined within a single scope that have the same
name. This situation | 8347 * represent multiple elements defined within a single scope that have the same
name. This situation |
| 8426 * is not allowed by the language, so objects implementing this interface always
represent an error. | 8348 * is not allowed by the language, so objects implementing this interface always
represent an error. |
| 8427 * As a result, most of the normal operations on elements do not make sense and
will return useless | 8349 * As a result, most of the normal operations on elements do not make sense and
will return useless |
| 8428 * results. | 8350 * results. |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8583 // There are no children to visit | 8505 // There are no children to visit |
| 8584 } | 8506 } |
| 8585 | 8507 |
| 8586 /** | 8508 /** |
| 8587 * Return an element that represents the given conflicting elements. | 8509 * Return an element that represents the given conflicting elements. |
| 8588 * | 8510 * |
| 8589 * @param context the analysis context in which the multiply defined elements
are defined | 8511 * @param context the analysis context in which the multiply defined elements
are defined |
| 8590 * @param firstElement the first element that conflicts | 8512 * @param firstElement the first element that conflicts |
| 8591 * @param secondElement the second element that conflicts | 8513 * @param secondElement the second element that conflicts |
| 8592 */ | 8514 */ |
| 8593 static Element fromElements(AnalysisContext context, Element firstElement, | 8515 static Element fromElements( |
| 8594 Element secondElement) { | 8516 AnalysisContext context, Element firstElement, Element secondElement) { |
| 8595 List<Element> conflictingElements = | 8517 List<Element> conflictingElements = |
| 8596 _computeConflictingElements(firstElement, secondElement); | 8518 _computeConflictingElements(firstElement, secondElement); |
| 8597 int length = conflictingElements.length; | 8519 int length = conflictingElements.length; |
| 8598 if (length == 0) { | 8520 if (length == 0) { |
| 8599 return null; | 8521 return null; |
| 8600 } else if (length == 1) { | 8522 } else if (length == 1) { |
| 8601 return conflictingElements[0]; | 8523 return conflictingElements[0]; |
| 8602 } | 8524 } |
| 8603 return new MultiplyDefinedElementImpl(context, conflictingElements); | 8525 return new MultiplyDefinedElementImpl(context, conflictingElements); |
| 8604 } | 8526 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8622 | 8544 |
| 8623 /** | 8545 /** |
| 8624 * Use the given elements to construct an array of conflicting elements. If ei
ther of the given | 8546 * Use the given elements to construct an array of conflicting elements. If ei
ther of the given |
| 8625 * elements are multiply-defined elements then the conflicting elements they r
epresent will be | 8547 * elements are multiply-defined elements then the conflicting elements they r
epresent will be |
| 8626 * included in the array. Otherwise, the element itself will be included. | 8548 * included in the array. Otherwise, the element itself will be included. |
| 8627 * | 8549 * |
| 8628 * @param firstElement the first element to be included | 8550 * @param firstElement the first element to be included |
| 8629 * @param secondElement the second element to be included | 8551 * @param secondElement the second element to be included |
| 8630 * @return an array containing all of the conflicting elements | 8552 * @return an array containing all of the conflicting elements |
| 8631 */ | 8553 */ |
| 8632 static List<Element> _computeConflictingElements(Element firstElement, | 8554 static List<Element> _computeConflictingElements( |
| 8633 Element secondElement) { | 8555 Element firstElement, Element secondElement) { |
| 8634 HashSet<Element> elements = new HashSet<Element>(); | 8556 HashSet<Element> elements = new HashSet<Element>(); |
| 8635 _add(elements, firstElement); | 8557 _add(elements, firstElement); |
| 8636 _add(elements, secondElement); | 8558 _add(elements, secondElement); |
| 8637 return new List.from(elements); | 8559 return new List.from(elements); |
| 8638 } | 8560 } |
| 8639 } | 8561 } |
| 8640 | 8562 |
| 8641 /** | 8563 /** |
| 8642 * The interface [MultiplyInheritedExecutableElement] defines all of the behavio
r of an | 8564 * The interface [MultiplyInheritedExecutableElement] defines all of the behavio
r of an |
| 8643 * [ExecutableElement], with the additional information of an array of | 8565 * [ExecutableElement], with the additional information of an array of |
| 8644 * [ExecutableElement]s from which this element was composed. | 8566 * [ExecutableElement]s from which this element was composed. |
| 8645 */ | 8567 */ |
| 8646 abstract class MultiplyInheritedExecutableElement implements ExecutableElement { | 8568 abstract class MultiplyInheritedExecutableElement implements ExecutableElement { |
| 8647 /** | 8569 /** |
| 8648 * Return an array containing all of the executable elements defined within th
is executable | 8570 * Return an array containing all of the executable elements defined within th
is executable |
| 8649 * element. | 8571 * element. |
| 8650 * | 8572 * |
| 8651 * @return the elements defined within this executable element | 8573 * @return the elements defined within this executable element |
| 8652 */ | 8574 */ |
| 8653 List<ExecutableElement> get inheritedElements; | 8575 List<ExecutableElement> get inheritedElements; |
| 8654 } | 8576 } |
| 8655 | 8577 |
| 8656 /** | 8578 /** |
| 8657 * The interface [MultiplyInheritedMethodElementImpl] defines all of the behavio
r of an | 8579 * The interface [MultiplyInheritedMethodElementImpl] defines all of the behavio
r of an |
| 8658 * [MethodElementImpl], with the additional information of an array of | 8580 * [MethodElementImpl], with the additional information of an array of |
| 8659 * [ExecutableElement]s from which this element was composed. | 8581 * [ExecutableElement]s from which this element was composed. |
| 8660 */ | 8582 */ |
| 8661 class MultiplyInheritedMethodElementImpl extends MethodElementImpl implements | 8583 class MultiplyInheritedMethodElementImpl extends MethodElementImpl |
| 8662 MultiplyInheritedExecutableElement { | 8584 implements MultiplyInheritedExecutableElement { |
| 8663 /** | 8585 /** |
| 8664 * An array the array of executable elements that were used to compose this el
ement. | 8586 * An array the array of executable elements that were used to compose this el
ement. |
| 8665 */ | 8587 */ |
| 8666 List<ExecutableElement> _elements = MethodElementImpl.EMPTY_ARRAY; | 8588 List<ExecutableElement> _elements = MethodElementImpl.EMPTY_ARRAY; |
| 8667 | 8589 |
| 8668 MultiplyInheritedMethodElementImpl(Identifier name) : super.forNode(name) { | 8590 MultiplyInheritedMethodElementImpl(Identifier name) : super.forNode(name) { |
| 8669 synthetic = true; | 8591 synthetic = true; |
| 8670 } | 8592 } |
| 8671 | 8593 |
| 8672 @override | 8594 @override |
| 8673 List<ExecutableElement> get inheritedElements => _elements; | 8595 List<ExecutableElement> get inheritedElements => _elements; |
| 8674 | 8596 |
| 8675 void set inheritedElements(List<ExecutableElement> elements) { | 8597 void set inheritedElements(List<ExecutableElement> elements) { |
| 8676 this._elements = elements; | 8598 this._elements = elements; |
| 8677 } | 8599 } |
| 8678 } | 8600 } |
| 8679 | 8601 |
| 8680 /** | 8602 /** |
| 8681 * The interface [MultiplyInheritedPropertyAccessorElementImpl] defines all of t
he behavior of | 8603 * The interface [MultiplyInheritedPropertyAccessorElementImpl] defines all of t
he behavior of |
| 8682 * an [PropertyAccessorElementImpl], with the additional information of an array
of | 8604 * an [PropertyAccessorElementImpl], with the additional information of an array
of |
| 8683 * [ExecutableElement]s from which this element was composed. | 8605 * [ExecutableElement]s from which this element was composed. |
| 8684 */ | 8606 */ |
| 8685 class MultiplyInheritedPropertyAccessorElementImpl extends | 8607 class MultiplyInheritedPropertyAccessorElementImpl |
| 8686 PropertyAccessorElementImpl implements MultiplyInheritedExecutableElement { | 8608 extends PropertyAccessorElementImpl |
| 8609 implements MultiplyInheritedExecutableElement { |
| 8687 /** | 8610 /** |
| 8688 * An array the array of executable elements that were used to compose this el
ement. | 8611 * An array the array of executable elements that were used to compose this el
ement. |
| 8689 */ | 8612 */ |
| 8690 List<ExecutableElement> _elements = PropertyAccessorElementImpl.EMPTY_ARRAY; | 8613 List<ExecutableElement> _elements = PropertyAccessorElementImpl.EMPTY_ARRAY; |
| 8691 | 8614 |
| 8692 MultiplyInheritedPropertyAccessorElementImpl(Identifier name) | 8615 MultiplyInheritedPropertyAccessorElementImpl(Identifier name) |
| 8693 : super.forNode(name) { | 8616 : super.forNode(name) { |
| 8694 synthetic = true; | 8617 synthetic = true; |
| 8695 } | 8618 } |
| 8696 | 8619 |
| 8697 @override | 8620 @override |
| 8698 List<ExecutableElement> get inheritedElements => _elements; | 8621 List<ExecutableElement> get inheritedElements => _elements; |
| 8699 | 8622 |
| 8700 void set inheritedElements(List<ExecutableElement> elements) { | 8623 void set inheritedElements(List<ExecutableElement> elements) { |
| 8701 this._elements = elements; | 8624 this._elements = elements; |
| 8702 } | 8625 } |
| 8703 } | 8626 } |
| 8704 | 8627 |
| 8705 /** | 8628 /** |
| 8706 * The interface `NamespaceCombinator` defines the behavior common to objects th
at control how | 8629 * The interface `NamespaceCombinator` defines the behavior common to objects th
at control how |
| 8707 * namespaces are combined. | 8630 * namespaces are combined. |
| 8708 */ | 8631 */ |
| 8709 abstract class NamespaceCombinator { | 8632 abstract class NamespaceCombinator { |
| 8710 /** | 8633 /** |
| 8711 * An empty list of namespace combinators. | 8634 * An empty list of namespace combinators. |
| 8712 */ | 8635 */ |
| 8713 static const List<NamespaceCombinator> EMPTY_ARRAY = const | 8636 static const List<NamespaceCombinator> EMPTY_ARRAY = |
| 8714 <NamespaceCombinator>[ | 8637 const <NamespaceCombinator>[]; |
| 8715 ]; | |
| 8716 } | 8638 } |
| 8717 | 8639 |
| 8718 /** | 8640 /** |
| 8719 * The interface `ParameterElement` defines the behavior of elements representin
g a parameter | 8641 * The interface `ParameterElement` defines the behavior of elements representin
g a parameter |
| 8720 * defined within an executable element. | 8642 * defined within an executable element. |
| 8721 */ | 8643 */ |
| 8722 abstract class ParameterElement implements LocalElement, VariableElement { | 8644 abstract class ParameterElement implements LocalElement, VariableElement { |
| 8723 /** | 8645 /** |
| 8724 * Return the Dart code of the default value, or `null` if no default value. | 8646 * Return the Dart code of the default value, or `null` if no default value. |
| 8725 * | 8647 * |
| (...skipping 20 matching lines...) Expand all Loading... |
| 8746 * only define other parameters if it is a function typed parameter. | 8668 * only define other parameters if it is a function typed parameter. |
| 8747 * | 8669 * |
| 8748 * @return the parameters defined by this parameter element | 8670 * @return the parameters defined by this parameter element |
| 8749 */ | 8671 */ |
| 8750 List<ParameterElement> get parameters; | 8672 List<ParameterElement> get parameters; |
| 8751 } | 8673 } |
| 8752 | 8674 |
| 8753 /** | 8675 /** |
| 8754 * Instances of the class `ParameterElementImpl` implement a `ParameterElement`. | 8676 * Instances of the class `ParameterElementImpl` implement a `ParameterElement`. |
| 8755 */ | 8677 */ |
| 8756 class ParameterElementImpl extends VariableElementImpl implements | 8678 class ParameterElementImpl extends VariableElementImpl |
| 8757 ParameterElement { | 8679 implements ParameterElement { |
| 8758 /** | 8680 /** |
| 8759 * An empty list of field elements. | 8681 * An empty list of field elements. |
| 8760 */ | 8682 */ |
| 8761 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[]; | 8683 static const List<ParameterElement> EMPTY_ARRAY = const <ParameterElement>[]; |
| 8762 | 8684 |
| 8763 /** | 8685 /** |
| 8764 * An array containing all of the parameters defined by this parameter element
. There will only be | 8686 * An array containing all of the parameters defined by this parameter element
. There will only be |
| 8765 * parameters if this parameter is a function typed parameter. | 8687 * parameters if this parameter is a function typed parameter. |
| 8766 */ | 8688 */ |
| 8767 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; | 8689 List<ParameterElement> _parameters = ParameterElementImpl.EMPTY_ARRAY; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8857 void appendTo(StringBuffer buffer) { | 8779 void appendTo(StringBuffer buffer) { |
| 8858 String left = ""; | 8780 String left = ""; |
| 8859 String right = ""; | 8781 String right = ""; |
| 8860 while (true) { | 8782 while (true) { |
| 8861 if (parameterKind == ParameterKind.NAMED) { | 8783 if (parameterKind == ParameterKind.NAMED) { |
| 8862 left = "{"; | 8784 left = "{"; |
| 8863 right = "}"; | 8785 right = "}"; |
| 8864 } else if (parameterKind == ParameterKind.POSITIONAL) { | 8786 } else if (parameterKind == ParameterKind.POSITIONAL) { |
| 8865 left = "["; | 8787 left = "["; |
| 8866 right = "]"; | 8788 right = "]"; |
| 8867 } else if (parameterKind == ParameterKind.REQUIRED) { | 8789 } else if (parameterKind == ParameterKind.REQUIRED) {} |
| 8868 } | |
| 8869 break; | 8790 break; |
| 8870 } | 8791 } |
| 8871 buffer.write(left); | 8792 buffer.write(left); |
| 8872 appendToWithoutDelimiters(buffer); | 8793 appendToWithoutDelimiters(buffer); |
| 8873 buffer.write(right); | 8794 buffer.write(right); |
| 8874 } | 8795 } |
| 8875 | 8796 |
| 8876 /** | 8797 /** |
| 8877 * Append the type and name of this parameter to the given builder. | 8798 * Append the type and name of this parameter to the given builder. |
| 8878 * | 8799 * |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9034 ParameterElement baseElement = this.baseElement; | 8955 ParameterElement baseElement = this.baseElement; |
| 9035 String left = ""; | 8956 String left = ""; |
| 9036 String right = ""; | 8957 String right = ""; |
| 9037 while (true) { | 8958 while (true) { |
| 9038 if (baseElement.parameterKind == ParameterKind.NAMED) { | 8959 if (baseElement.parameterKind == ParameterKind.NAMED) { |
| 9039 left = "{"; | 8960 left = "{"; |
| 9040 right = "}"; | 8961 right = "}"; |
| 9041 } else if (baseElement.parameterKind == ParameterKind.POSITIONAL) { | 8962 } else if (baseElement.parameterKind == ParameterKind.POSITIONAL) { |
| 9042 left = "["; | 8963 left = "["; |
| 9043 right = "]"; | 8964 right = "]"; |
| 9044 } else if (baseElement.parameterKind == ParameterKind.REQUIRED) { | 8965 } else if (baseElement.parameterKind == ParameterKind.REQUIRED) {} |
| 9045 } | |
| 9046 break; | 8966 break; |
| 9047 } | 8967 } |
| 9048 return '$left$type ${baseElement.displayName}$right'; | 8968 return '$left$type ${baseElement.displayName}$right'; |
| 9049 } | 8969 } |
| 9050 | 8970 |
| 9051 @override | 8971 @override |
| 9052 void visitChildren(ElementVisitor visitor) { | 8972 void visitChildren(ElementVisitor visitor) { |
| 9053 super.visitChildren(visitor); | 8973 super.visitChildren(visitor); |
| 9054 safelyVisitChildren(parameters, visitor); | 8974 safelyVisitChildren(parameters, visitor); |
| 9055 } | 8975 } |
| 9056 | 8976 |
| 9057 /** | 8977 /** |
| 9058 * If the given parameter's type is different when any type parameters from th
e defining type's | 8978 * If the given parameter's type is different when any type parameters from th
e defining type's |
| 9059 * declaration are replaced with the actual type arguments from the defining t
ype, create a | 8979 * declaration are replaced with the actual type arguments from the defining t
ype, create a |
| 9060 * parameter member representing the given parameter. Return the member that w
as created, or the | 8980 * parameter member representing the given parameter. Return the member that w
as created, or the |
| 9061 * base parameter if no member was created. | 8981 * base parameter if no member was created. |
| 9062 * | 8982 * |
| 9063 * @param baseParameter the base parameter for which a member might be created | 8983 * @param baseParameter the base parameter for which a member might be created |
| 9064 * @param definingType the type defining the parameters and arguments to be us
ed in the | 8984 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 9065 * substitution | 8985 * substitution |
| 9066 * @return the parameter element that will return the correctly substituted ty
pes | 8986 * @return the parameter element that will return the correctly substituted ty
pes |
| 9067 */ | 8987 */ |
| 9068 static ParameterElement from(ParameterElement baseParameter, | 8988 static ParameterElement from( |
| 9069 ParameterizedType definingType) { | 8989 ParameterElement baseParameter, ParameterizedType definingType) { |
| 9070 if (baseParameter == null || definingType.typeArguments.length == 0) { | 8990 if (baseParameter == null || definingType.typeArguments.length == 0) { |
| 9071 return baseParameter; | 8991 return baseParameter; |
| 9072 } | 8992 } |
| 9073 // Check if parameter type depends on defining type type arguments. | 8993 // Check if parameter type depends on defining type type arguments. |
| 9074 // It is possible that we did not resolve field formal parameter yet, | 8994 // It is possible that we did not resolve field formal parameter yet, |
| 9075 // so skip this check for it. | 8995 // so skip this check for it. |
| 9076 bool isFieldFormal = baseParameter is FieldFormalParameterElement; | 8996 bool isFieldFormal = baseParameter is FieldFormalParameterElement; |
| 9077 if (!isFieldFormal) { | 8997 if (!isFieldFormal) { |
| 9078 DartType baseType = baseParameter.type; | 8998 DartType baseType = baseParameter.type; |
| 9079 List<DartType> argumentTypes = definingType.typeArguments; | 8999 List<DartType> argumentTypes = definingType.typeArguments; |
| 9080 List<DartType> parameterTypes = | 9000 List<DartType> parameterTypes = |
| 9081 TypeParameterTypeImpl.getTypes(definingType.typeParameters); | 9001 TypeParameterTypeImpl.getTypes(definingType.typeParameters); |
| 9082 DartType substitutedType = | 9002 DartType substitutedType = |
| 9083 baseType.substitute2(argumentTypes, parameterTypes); | 9003 baseType.substitute2(argumentTypes, parameterTypes); |
| 9084 if (baseType == substitutedType) { | 9004 if (baseType == substitutedType) { |
| 9085 return baseParameter; | 9005 return baseParameter; |
| 9086 } | 9006 } |
| 9087 } | 9007 } |
| 9088 // TODO(brianwilkerson) Consider caching the substituted type in the | 9008 // TODO(brianwilkerson) Consider caching the substituted type in the |
| 9089 // instance. It would use more memory but speed up some operations. | 9009 // instance. It would use more memory but speed up some operations. |
| 9090 // We need to see how often the type is being re-computed. | 9010 // We need to see how often the type is being re-computed. |
| 9091 if (isFieldFormal) { | 9011 if (isFieldFormal) { |
| 9092 return new FieldFormalParameterMember( | 9012 return new FieldFormalParameterMember( |
| 9093 baseParameter as FieldFormalParameterElement, | 9013 baseParameter as FieldFormalParameterElement, definingType); |
| 9094 definingType); | |
| 9095 } | 9014 } |
| 9096 return new ParameterMember(baseParameter, definingType); | 9015 return new ParameterMember(baseParameter, definingType); |
| 9097 } | 9016 } |
| 9098 } | 9017 } |
| 9099 | 9018 |
| 9100 /** | 9019 /** |
| 9101 * The interface `PrefixElement` defines the behavior common to elements that re
present a | 9020 * The interface `PrefixElement` defines the behavior common to elements that re
present a |
| 9102 * prefix used to import one or more libraries into another library. | 9021 * prefix used to import one or more libraries into another library. |
| 9103 */ | 9022 */ |
| 9104 abstract class PrefixElement implements Element { | 9023 abstract class PrefixElement implements Element { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9243 * | 9162 * |
| 9244 * @return the variable associated with this accessor | 9163 * @return the variable associated with this accessor |
| 9245 */ | 9164 */ |
| 9246 PropertyInducingElement get variable; | 9165 PropertyInducingElement get variable; |
| 9247 } | 9166 } |
| 9248 | 9167 |
| 9249 /** | 9168 /** |
| 9250 * Instances of the class `PropertyAccessorElementImpl` implement a | 9169 * Instances of the class `PropertyAccessorElementImpl` implement a |
| 9251 * `PropertyAccessorElement`. | 9170 * `PropertyAccessorElement`. |
| 9252 */ | 9171 */ |
| 9253 class PropertyAccessorElementImpl extends ExecutableElementImpl implements | 9172 class PropertyAccessorElementImpl extends ExecutableElementImpl |
| 9254 PropertyAccessorElement { | 9173 implements PropertyAccessorElement { |
| 9255 /** | 9174 /** |
| 9256 * An empty list of property accessor elements. | 9175 * An empty list of property accessor elements. |
| 9257 */ | 9176 */ |
| 9258 static const List<PropertyAccessorElement> EMPTY_ARRAY = const | 9177 static const List<PropertyAccessorElement> EMPTY_ARRAY = |
| 9259 <PropertyAccessorElement>[ | 9178 const <PropertyAccessorElement>[]; |
| 9260 ]; | |
| 9261 | 9179 |
| 9262 /** | 9180 /** |
| 9263 * The variable associated with this accessor. | 9181 * The variable associated with this accessor. |
| 9264 */ | 9182 */ |
| 9265 PropertyInducingElement variable; | 9183 PropertyInducingElement variable; |
| 9266 | 9184 |
| 9267 /** | 9185 /** |
| 9268 * Initialize a newly created property accessor element to have the given name
. | 9186 * Initialize a newly created property accessor element to have the given name
. |
| 9269 * | 9187 * |
| 9270 * @param name the name of this element | 9188 * @param name the name of this element |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9382 /** | 9300 /** |
| 9383 * Set whether this accessor is static to correspond to the given value. | 9301 * Set whether this accessor is static to correspond to the given value. |
| 9384 * | 9302 * |
| 9385 * @param isStatic `true` if the accessor is static | 9303 * @param isStatic `true` if the accessor is static |
| 9386 */ | 9304 */ |
| 9387 void set static(bool isStatic) { | 9305 void set static(bool isStatic) { |
| 9388 setModifier(Modifier.STATIC, isStatic); | 9306 setModifier(Modifier.STATIC, isStatic); |
| 9389 } | 9307 } |
| 9390 | 9308 |
| 9391 @override | 9309 @override |
| 9392 bool operator ==(Object object) => | 9310 bool operator ==(Object object) => super == object && |
| 9393 super == object && isGetter == (object as PropertyAccessorElement).isGette
r; | 9311 isGetter == (object as PropertyAccessorElement).isGetter; |
| 9394 | 9312 |
| 9395 @override | 9313 @override |
| 9396 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); | 9314 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); |
| 9397 | 9315 |
| 9398 @override | 9316 @override |
| 9399 void appendTo(StringBuffer buffer) { | 9317 void appendTo(StringBuffer buffer) { |
| 9400 buffer.write(isGetter ? "get " : "set "); | 9318 buffer.write(isGetter ? "get " : "set "); |
| 9401 buffer.write(variable.displayName); | 9319 buffer.write(variable.displayName); |
| 9402 super.appendTo(buffer); | 9320 super.appendTo(buffer); |
| 9403 } | 9321 } |
| 9404 } | 9322 } |
| 9405 | 9323 |
| 9406 /** | 9324 /** |
| 9407 * Instances of the class `PropertyAccessorMember` represent a property accessor
element | 9325 * Instances of the class `PropertyAccessorMember` represent a property accessor
element |
| 9408 * defined in a parameterized type where the values of the type parameters are k
nown. | 9326 * defined in a parameterized type where the values of the type parameters are k
nown. |
| 9409 */ | 9327 */ |
| 9410 class PropertyAccessorMember extends ExecutableMember implements | 9328 class PropertyAccessorMember extends ExecutableMember |
| 9411 PropertyAccessorElement { | 9329 implements PropertyAccessorElement { |
| 9412 /** | 9330 /** |
| 9413 * Initialize a newly created element to represent a property accessor of the
given parameterized | 9331 * Initialize a newly created element to represent a property accessor of the
given parameterized |
| 9414 * type. | 9332 * type. |
| 9415 * | 9333 * |
| 9416 * @param baseElement the element on which the parameterized element was creat
ed | 9334 * @param baseElement the element on which the parameterized element was creat
ed |
| 9417 * @param definingType the type in which the element is defined | 9335 * @param definingType the type in which the element is defined |
| 9418 */ | 9336 */ |
| 9419 PropertyAccessorMember(PropertyAccessorElement baseElement, | 9337 PropertyAccessorMember( |
| 9420 InterfaceType definingType) | 9338 PropertyAccessorElement baseElement, InterfaceType definingType) |
| 9421 : super(baseElement, definingType); | 9339 : super(baseElement, definingType); |
| 9422 | 9340 |
| 9423 @override | 9341 @override |
| 9424 PropertyAccessorElement get baseElement => | 9342 PropertyAccessorElement get baseElement => |
| 9425 super.baseElement as PropertyAccessorElement; | 9343 super.baseElement as PropertyAccessorElement; |
| 9426 | 9344 |
| 9427 @override | 9345 @override |
| 9428 PropertyAccessorElement get correspondingGetter => | 9346 PropertyAccessorElement get correspondingGetter => |
| 9429 from(baseElement.correspondingGetter, definingType); | 9347 from(baseElement.correspondingGetter, definingType); |
| 9430 | 9348 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9493 * If the given property accessor's type is different when any type parameters
from the defining | 9411 * If the given property accessor's type is different when any type parameters
from the defining |
| 9494 * type's declaration are replaced with the actual type arguments from the def
ining type, create a | 9412 * type's declaration are replaced with the actual type arguments from the def
ining type, create a |
| 9495 * property accessor member representing the given property accessor. Return t
he member that was | 9413 * property accessor member representing the given property accessor. Return t
he member that was |
| 9496 * created, or the base accessor if no member was created. | 9414 * created, or the base accessor if no member was created. |
| 9497 * | 9415 * |
| 9498 * @param baseAccessor the base property accessor for which a member might be
created | 9416 * @param baseAccessor the base property accessor for which a member might be
created |
| 9499 * @param definingType the type defining the parameters and arguments to be us
ed in the | 9417 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 9500 * substitution | 9418 * substitution |
| 9501 * @return the property accessor element that will return the correctly substi
tuted types | 9419 * @return the property accessor element that will return the correctly substi
tuted types |
| 9502 */ | 9420 */ |
| 9503 static PropertyAccessorElement from(PropertyAccessorElement baseAccessor, | 9421 static PropertyAccessorElement from( |
| 9504 InterfaceType definingType) { | 9422 PropertyAccessorElement baseAccessor, InterfaceType definingType) { |
| 9505 if (!_isChangedByTypeSubstitution(baseAccessor, definingType)) { | 9423 if (!_isChangedByTypeSubstitution(baseAccessor, definingType)) { |
| 9506 return baseAccessor; | 9424 return baseAccessor; |
| 9507 } | 9425 } |
| 9508 // TODO(brianwilkerson) Consider caching the substituted type in the | 9426 // TODO(brianwilkerson) Consider caching the substituted type in the |
| 9509 // instance. It would use more memory but speed up some operations. | 9427 // instance. It would use more memory but speed up some operations. |
| 9510 // We need to see how often the type is being re-computed. | 9428 // We need to see how often the type is being re-computed. |
| 9511 return new PropertyAccessorMember(baseAccessor, definingType); | 9429 return new PropertyAccessorMember(baseAccessor, definingType); |
| 9512 } | 9430 } |
| 9513 | 9431 |
| 9514 /** | 9432 /** |
| 9515 * Determine whether the given property accessor's type is changed when type p
arameters from the | 9433 * Determine whether the given property accessor's type is changed when type p
arameters from the |
| 9516 * defining type's declaration are replaced with the actual type arguments fro
m the defining type. | 9434 * defining type's declaration are replaced with the actual type arguments fro
m the defining type. |
| 9517 * | 9435 * |
| 9518 * @param baseAccessor the base property accessor | 9436 * @param baseAccessor the base property accessor |
| 9519 * @param definingType the type defining the parameters and arguments to be us
ed in the | 9437 * @param definingType the type defining the parameters and arguments to be us
ed in the |
| 9520 * substitution | 9438 * substitution |
| 9521 * @return true if the type is changed by type substitution. | 9439 * @return true if the type is changed by type substitution. |
| 9522 */ | 9440 */ |
| 9523 static bool _isChangedByTypeSubstitution(PropertyAccessorElement baseAccessor, | 9441 static bool _isChangedByTypeSubstitution( |
| 9524 InterfaceType definingType) { | 9442 PropertyAccessorElement baseAccessor, InterfaceType definingType) { |
| 9525 List<DartType> argumentTypes = definingType.typeArguments; | 9443 List<DartType> argumentTypes = definingType.typeArguments; |
| 9526 if (baseAccessor != null && argumentTypes.length != 0) { | 9444 if (baseAccessor != null && argumentTypes.length != 0) { |
| 9527 FunctionType baseType = baseAccessor.type; | 9445 FunctionType baseType = baseAccessor.type; |
| 9528 if (baseType == null) { | 9446 if (baseType == null) { |
| 9529 AnalysisEngine.instance.logger.logInformation( | 9447 AnalysisEngine.instance.logger.logInformation( |
| 9530 'Type of $baseAccessor is null in PropertyAccessorMember._isChangedB
yTypeSubstitution'); | 9448 'Type of $baseAccessor is null in PropertyAccessorMember._isChangedB
yTypeSubstitution'); |
| 9531 return false; | 9449 return false; |
| 9532 } | 9450 } |
| 9533 List<DartType> parameterTypes = definingType.element.type.typeArguments; | 9451 List<DartType> parameterTypes = definingType.element.type.typeArguments; |
| 9534 FunctionType substitutedType = | 9452 FunctionType substitutedType = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9608 | 9526 |
| 9609 /** | 9527 /** |
| 9610 * Instances of the class `PropertyInducingElementImpl` implement a | 9528 * Instances of the class `PropertyInducingElementImpl` implement a |
| 9611 * `PropertyInducingElement`. | 9529 * `PropertyInducingElement`. |
| 9612 */ | 9530 */ |
| 9613 abstract class PropertyInducingElementImpl extends VariableElementImpl | 9531 abstract class PropertyInducingElementImpl extends VariableElementImpl |
| 9614 implements PropertyInducingElement { | 9532 implements PropertyInducingElement { |
| 9615 /** | 9533 /** |
| 9616 * An empty list of elements. | 9534 * An empty list of elements. |
| 9617 */ | 9535 */ |
| 9618 static const List<PropertyInducingElement> EMPTY_ARRAY = const | 9536 static const List<PropertyInducingElement> EMPTY_ARRAY = |
| 9619 <PropertyInducingElement>[ | 9537 const <PropertyInducingElement>[]; |
| 9620 ]; | |
| 9621 | 9538 |
| 9622 /** | 9539 /** |
| 9623 * The getter associated with this element. | 9540 * The getter associated with this element. |
| 9624 */ | 9541 */ |
| 9625 PropertyAccessorElement getter; | 9542 PropertyAccessorElement getter; |
| 9626 | 9543 |
| 9627 /** | 9544 /** |
| 9628 * The setter associated with this element, or `null` if the element is effect
ively | 9545 * The setter associated with this element, or `null` if the element is effect
ively |
| 9629 * `final` and therefore does not have a setter associated with it. | 9546 * `final` and therefore does not have a setter associated with it. |
| 9630 */ | 9547 */ |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9934 R visitTopLevelVariableElement(TopLevelVariableElement element) => null; | 9851 R visitTopLevelVariableElement(TopLevelVariableElement element) => null; |
| 9935 | 9852 |
| 9936 @override | 9853 @override |
| 9937 R visitTypeParameterElement(TypeParameterElement element) => null; | 9854 R visitTypeParameterElement(TypeParameterElement element) => null; |
| 9938 } | 9855 } |
| 9939 | 9856 |
| 9940 /** | 9857 /** |
| 9941 * The interface `TopLevelVariableElement` defines the behavior of elements repr
esenting a | 9858 * The interface `TopLevelVariableElement` defines the behavior of elements repr
esenting a |
| 9942 * top-level variable. | 9859 * top-level variable. |
| 9943 */ | 9860 */ |
| 9944 abstract class TopLevelVariableElement implements PropertyInducingElement { | 9861 abstract class TopLevelVariableElement implements PropertyInducingElement {} |
| 9945 } | |
| 9946 | 9862 |
| 9947 /** | 9863 /** |
| 9948 * Instances of the class `TopLevelVariableElementImpl` implement a | 9864 * Instances of the class `TopLevelVariableElementImpl` implement a |
| 9949 * `TopLevelVariableElement`. | 9865 * `TopLevelVariableElement`. |
| 9950 */ | 9866 */ |
| 9951 class TopLevelVariableElementImpl extends PropertyInducingElementImpl implements | 9867 class TopLevelVariableElementImpl extends PropertyInducingElementImpl |
| 9952 TopLevelVariableElement { | 9868 implements TopLevelVariableElement { |
| 9953 /** | 9869 /** |
| 9954 * An empty list of top-level variable elements. | 9870 * An empty list of top-level variable elements. |
| 9955 */ | 9871 */ |
| 9956 static const List<TopLevelVariableElement> EMPTY_ARRAY = const | 9872 static const List<TopLevelVariableElement> EMPTY_ARRAY = |
| 9957 <TopLevelVariableElement>[ | 9873 const <TopLevelVariableElement>[]; |
| 9958 ]; | |
| 9959 | 9874 |
| 9960 /** | 9875 /** |
| 9961 * Initialize a newly created synthetic top-level variable element to have the
given name. | 9876 * Initialize a newly created synthetic top-level variable element to have the
given name. |
| 9962 * | 9877 * |
| 9963 * @param name the name of this element | 9878 * @param name the name of this element |
| 9964 * @param nameOffset the offset of the name of this element in the file that c
ontains the | 9879 * @param nameOffset the offset of the name of this element in the file that c
ontains the |
| 9965 * declaration of this element | 9880 * declaration of this element |
| 9966 */ | 9881 */ |
| 9967 TopLevelVariableElementImpl(String name, int nameOffset) | 9882 TopLevelVariableElementImpl(String name, int nameOffset) |
| 9968 : super(name, nameOffset); | 9883 : super(name, nameOffset); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10053 } | 9968 } |
| 10054 } | 9969 } |
| 10055 | 9970 |
| 10056 @override | 9971 @override |
| 10057 DartType getLeastUpperBound(DartType type) => null; | 9972 DartType getLeastUpperBound(DartType type) => null; |
| 10058 | 9973 |
| 10059 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs); | 9974 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs); |
| 10060 | 9975 |
| 10061 int internalHashCode(List<DartType> visitedTypes); | 9976 int internalHashCode(List<DartType> visitedTypes); |
| 10062 | 9977 |
| 10063 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, | 9978 bool internalIsMoreSpecificThan( |
| 10064 Set<TypeImpl_TypePair> visitedTypePairs); | 9979 DartType type, bool withDynamic, Set<TypeImpl_TypePair> visitedTypePairs); |
| 10065 | 9980 |
| 10066 bool internalIsSubtypeOf(DartType type, | 9981 bool internalIsSubtypeOf( |
| 10067 Set<TypeImpl_TypePair> visitedTypePairs); | 9982 DartType type, Set<TypeImpl_TypePair> visitedTypePairs); |
| 10068 | 9983 |
| 10069 @override | 9984 @override |
| 10070 bool isAssignableTo(DartType type) => | 9985 bool isAssignableTo(DartType type) => |
| 10071 isAssignableTo2(type, new HashSet<TypeImpl_TypePair>()); | 9986 isAssignableTo2(type, new HashSet<TypeImpl_TypePair>()); |
| 10072 | 9987 |
| 10073 /** | 9988 /** |
| 10074 * Return `true` if this type is assignable to the given type. A type <i>T</i>
may be | 9989 * Return `true` if this type is assignable to the given type. A type <i>T</i>
may be |
| 10075 * assigned to a type <i>S</i>, written <i>T</i> ⇔ <i>S</i>, iff either <
i>T</i> <: <i>S</i> | 9990 * assigned to a type <i>S</i>, written <i>T</i> ⇔ <i>S</i>, iff either <
i>T</i> <: <i>S</i> |
| 10076 * or <i>S</i> <: <i>T</i> (Interface Types section of spec). | 9991 * or <i>S</i> <: <i>T</i> (Interface Types section of spec). |
| 10077 * | 9992 * |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10196 * of type arguments are all equal. Use the set of [visitedElementPairs] to | 10111 * of type arguments are all equal. Use the set of [visitedElementPairs] to |
| 10197 * prevent infinite loops when the types are recursively defined. | 10112 * prevent infinite loops when the types are recursively defined. |
| 10198 */ | 10113 */ |
| 10199 static bool equalArrays(List<DartType> first, List<DartType> second, | 10114 static bool equalArrays(List<DartType> first, List<DartType> second, |
| 10200 Set<ElementPair> visitedElementPairs) { | 10115 Set<ElementPair> visitedElementPairs) { |
| 10201 if (first.length != second.length) { | 10116 if (first.length != second.length) { |
| 10202 return false; | 10117 return false; |
| 10203 } | 10118 } |
| 10204 for (int i = 0; i < first.length; i++) { | 10119 for (int i = 0; i < first.length; i++) { |
| 10205 if (first[i] == null) { | 10120 if (first[i] == null) { |
| 10206 AnalysisEngine.instance.logger.logInformation( | 10121 AnalysisEngine.instance.logger |
| 10207 'Found null type argument in TypeImpl.equalArrays'); | 10122 .logInformation('Found null type argument in TypeImpl.equalArrays'); |
| 10208 return second[i] == null; | 10123 return second[i] == null; |
| 10209 } else if (second[i] == null) { | 10124 } else if (second[i] == null) { |
| 10210 AnalysisEngine.instance.logger.logInformation( | 10125 AnalysisEngine.instance.logger |
| 10211 'Found null type argument in TypeImpl.equalArrays'); | 10126 .logInformation('Found null type argument in TypeImpl.equalArrays'); |
| 10212 return false; | 10127 return false; |
| 10213 } | 10128 } |
| 10214 if (!(first[i] as TypeImpl).internalEquals( | 10129 if (!(first[i] as TypeImpl).internalEquals( |
| 10215 second[i], | 10130 second[i], visitedElementPairs)) { |
| 10216 visitedElementPairs)) { | |
| 10217 return false; | 10131 return false; |
| 10218 } | 10132 } |
| 10219 } | 10133 } |
| 10220 return true; | 10134 return true; |
| 10221 } | 10135 } |
| 10222 | 10136 |
| 10223 /** | 10137 /** |
| 10224 * Return an array containing the results of using the given argument types an
d parameter types to | 10138 * Return an array containing the results of using the given argument types an
d parameter types to |
| 10225 * perform a substitution on all of the given types. | 10139 * perform a substitution on all of the given types. |
| 10226 * | 10140 * |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10302 * Return the type defined by this type parameter. | 10216 * Return the type defined by this type parameter. |
| 10303 * | 10217 * |
| 10304 * @return the type defined by this type parameter | 10218 * @return the type defined by this type parameter |
| 10305 */ | 10219 */ |
| 10306 TypeParameterType get type; | 10220 TypeParameterType get type; |
| 10307 } | 10221 } |
| 10308 | 10222 |
| 10309 /** | 10223 /** |
| 10310 * Instances of the class `TypeParameterElementImpl` implement a [TypeParameterE
lement]. | 10224 * Instances of the class `TypeParameterElementImpl` implement a [TypeParameterE
lement]. |
| 10311 */ | 10225 */ |
| 10312 class TypeParameterElementImpl extends ElementImpl implements | 10226 class TypeParameterElementImpl extends ElementImpl |
| 10313 TypeParameterElement { | 10227 implements TypeParameterElement { |
| 10314 /** | 10228 /** |
| 10315 * An empty list of type parameter elements. | 10229 * An empty list of type parameter elements. |
| 10316 */ | 10230 */ |
| 10317 static const List<TypeParameterElement> EMPTY_ARRAY = const | 10231 static const List<TypeParameterElement> EMPTY_ARRAY = |
| 10318 <TypeParameterElement>[ | 10232 const <TypeParameterElement>[]; |
| 10319 ]; | |
| 10320 | 10233 |
| 10321 /** | 10234 /** |
| 10322 * The type defined by this type parameter. | 10235 * The type defined by this type parameter. |
| 10323 */ | 10236 */ |
| 10324 TypeParameterType type; | 10237 TypeParameterType type; |
| 10325 | 10238 |
| 10326 /** | 10239 /** |
| 10327 * The type representing the bound associated with this parameter, or `null` i
f this | 10240 * The type representing the bound associated with this parameter, or `null` i
f this |
| 10328 * parameter does not have an explicit bound. | 10241 * parameter does not have an explicit bound. |
| 10329 */ | 10242 */ |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10373 | 10286 |
| 10374 /** | 10287 /** |
| 10375 * Instances of the class `TypeParameterTypeImpl` defines the behavior of object
s representing | 10288 * Instances of the class `TypeParameterTypeImpl` defines the behavior of object
s representing |
| 10376 * the type introduced by a type parameter. | 10289 * the type introduced by a type parameter. |
| 10377 */ | 10290 */ |
| 10378 class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType { | 10291 class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType { |
| 10379 /** | 10292 /** |
| 10380 * An empty list of type parameter types. | 10293 * An empty list of type parameter types. |
| 10381 */ | 10294 */ |
| 10382 static const List<TypeParameterType> EMPTY_ARRAY = const <TypeParameterType>[ | 10295 static const List<TypeParameterType> EMPTY_ARRAY = const <TypeParameterType>[ |
| 10383 ]; | 10296 ]; |
| 10384 | 10297 |
| 10385 /** | 10298 /** |
| 10386 * Initialize a newly created type parameter type to be declared by the given
element and to have | 10299 * Initialize a newly created type parameter type to be declared by the given
element and to have |
| 10387 * the given name. | 10300 * the given name. |
| 10388 * | 10301 * |
| 10389 * @param element the element representing the declaration of the type paramet
er | 10302 * @param element the element representing the declaration of the type paramet
er |
| 10390 */ | 10303 */ |
| 10391 TypeParameterTypeImpl(TypeParameterElement element) | 10304 TypeParameterTypeImpl(TypeParameterElement element) |
| 10392 : super(element, element.name); | 10305 : super(element, element.name); |
| 10393 | 10306 |
| 10394 @override | 10307 @override |
| 10395 TypeParameterElement get element => super.element as TypeParameterElement; | 10308 TypeParameterElement get element => super.element as TypeParameterElement; |
| 10396 | 10309 |
| 10397 @override | 10310 @override |
| 10398 int get hashCode => element.hashCode; | 10311 int get hashCode => element.hashCode; |
| 10399 | 10312 |
| 10400 @override | 10313 @override |
| 10401 bool operator ==(Object object) => | 10314 bool operator ==(Object object) => |
| 10402 object is TypeParameterTypeImpl && (element == object.element); | 10315 object is TypeParameterTypeImpl && (element == object.element); |
| 10403 | 10316 |
| 10404 @override | 10317 @override |
| 10405 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => | 10318 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => |
| 10406 this == object; | 10319 this == object; |
| 10407 | 10320 |
| 10408 @override | 10321 @override |
| 10409 int internalHashCode(List<DartType> visitedTypes) => hashCode; | 10322 int internalHashCode(List<DartType> visitedTypes) => hashCode; |
| 10410 | 10323 |
| 10411 @override | 10324 @override |
| 10412 bool internalIsMoreSpecificThan(DartType s, bool withDynamic, | 10325 bool internalIsMoreSpecificThan( |
| 10413 Set<TypeImpl_TypePair> visitedTypePairs) { | 10326 DartType s, bool withDynamic, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10414 // | 10327 // |
| 10415 // A type T is more specific than a type S, written T << S, | 10328 // A type T is more specific than a type S, written T << S, |
| 10416 // if one of the following conditions is met: | 10329 // if one of the following conditions is met: |
| 10417 // | 10330 // |
| 10418 // Reflexivity: T is S. | 10331 // Reflexivity: T is S. |
| 10419 // | 10332 // |
| 10420 if (this == s) { | 10333 if (this == s) { |
| 10421 return true; | 10334 return true; |
| 10422 } | 10335 } |
| 10423 // S is dynamic. | 10336 // S is dynamic. |
| 10424 // | 10337 // |
| 10425 if (s.isDynamic) { | 10338 if (s.isDynamic) { |
| 10426 return true; | 10339 return true; |
| 10427 } | 10340 } |
| 10428 return _isMoreSpecificThan( | 10341 return _isMoreSpecificThan( |
| 10429 s, | 10342 s, new HashSet<DartType>(), withDynamic, visitedTypePairs); |
| 10430 new HashSet<DartType>(), | |
| 10431 withDynamic, | |
| 10432 visitedTypePairs); | |
| 10433 } | 10343 } |
| 10434 | 10344 |
| 10435 @override | 10345 @override |
| 10436 bool internalIsSubtypeOf(DartType type, | 10346 bool internalIsSubtypeOf( |
| 10437 Set<TypeImpl_TypePair> visitedTypePairs) => | 10347 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) => |
| 10438 isMoreSpecificThan2(type, true, new HashSet<TypeImpl_TypePair>()); | 10348 isMoreSpecificThan2(type, true, new HashSet<TypeImpl_TypePair>()); |
| 10439 | 10349 |
| 10440 @override | 10350 @override |
| 10441 DartType substitute2(List<DartType> argumentTypes, | 10351 DartType substitute2( |
| 10442 List<DartType> parameterTypes) { | 10352 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 10443 int length = parameterTypes.length; | 10353 int length = parameterTypes.length; |
| 10444 for (int i = 0; i < length; i++) { | 10354 for (int i = 0; i < length; i++) { |
| 10445 if (parameterTypes[i] == this) { | 10355 if (parameterTypes[i] == this) { |
| 10446 return argumentTypes[i]; | 10356 return argumentTypes[i]; |
| 10447 } | 10357 } |
| 10448 } | 10358 } |
| 10449 return this; | 10359 return this; |
| 10450 } | 10360 } |
| 10451 | 10361 |
| 10452 bool _isMoreSpecificThan(DartType s, Set<DartType> visitedTypes, | 10362 bool _isMoreSpecificThan(DartType s, Set<DartType> visitedTypes, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 10473 // | 10383 // |
| 10474 if (bound is TypeParameterTypeImpl) { | 10384 if (bound is TypeParameterTypeImpl) { |
| 10475 TypeParameterTypeImpl boundTypeParameter = bound; | 10385 TypeParameterTypeImpl boundTypeParameter = bound; |
| 10476 // First check for infinite loops | 10386 // First check for infinite loops |
| 10477 if (visitedTypes.contains(bound)) { | 10387 if (visitedTypes.contains(bound)) { |
| 10478 return false; | 10388 return false; |
| 10479 } | 10389 } |
| 10480 visitedTypes.add(bound); | 10390 visitedTypes.add(bound); |
| 10481 // Then check upper bound. | 10391 // Then check upper bound. |
| 10482 return boundTypeParameter._isMoreSpecificThan( | 10392 return boundTypeParameter._isMoreSpecificThan( |
| 10483 s, | 10393 s, visitedTypes, withDynamic, visitedTypePairs); |
| 10484 visitedTypes, | |
| 10485 withDynamic, | |
| 10486 visitedTypePairs); | |
| 10487 } | 10394 } |
| 10488 // Check interface type. | 10395 // Check interface type. |
| 10489 return (bound as TypeImpl).isMoreSpecificThan2( | 10396 return (bound as TypeImpl).isMoreSpecificThan2( |
| 10490 s, | 10397 s, withDynamic, visitedTypePairs); |
| 10491 withDynamic, | |
| 10492 visitedTypePairs); | |
| 10493 } | 10398 } |
| 10494 | 10399 |
| 10495 /** | 10400 /** |
| 10496 * Return an array containing the type parameter types defined by the given ar
ray of type | 10401 * Return an array containing the type parameter types defined by the given ar
ray of type |
| 10497 * parameter elements. | 10402 * parameter elements. |
| 10498 * | 10403 * |
| 10499 * @param typeParameters the type parameter elements defining the type paramet
er types to be | 10404 * @param typeParameters the type parameter elements defining the type paramet
er types to be |
| 10500 * returned | 10405 * returned |
| 10501 * @return the type parameter types defined by the type parameter elements | 10406 * @return the type parameter types defined by the type parameter elements |
| 10502 */ | 10407 */ |
| 10503 static List<TypeParameterType> | 10408 static List<TypeParameterType> getTypes( |
| 10504 getTypes(List<TypeParameterElement> typeParameters) { | 10409 List<TypeParameterElement> typeParameters) { |
| 10505 int count = typeParameters.length; | 10410 int count = typeParameters.length; |
| 10506 if (count == 0) { | 10411 if (count == 0) { |
| 10507 return EMPTY_ARRAY; | 10412 return EMPTY_ARRAY; |
| 10508 } | 10413 } |
| 10509 List<TypeParameterType> types = new List<TypeParameterType>(count); | 10414 List<TypeParameterType> types = new List<TypeParameterType>(count); |
| 10510 for (int i = 0; i < count; i++) { | 10415 for (int i = 0; i < count; i++) { |
| 10511 types[i] = typeParameters[i].type; | 10416 types[i] = typeParameters[i].type; |
| 10512 } | 10417 } |
| 10513 return types; | 10418 return types; |
| 10514 } | 10419 } |
| 10515 } | 10420 } |
| 10516 | 10421 |
| 10517 /** | 10422 /** |
| 10518 * The interface `UndefinedElement` defines the behavior of pseudo-elements that
represent | 10423 * The interface `UndefinedElement` defines the behavior of pseudo-elements that
represent |
| 10519 * names that are undefined. This situation is not allowed by the language, so o
bjects implementing | 10424 * names that are undefined. This situation is not allowed by the language, so o
bjects implementing |
| 10520 * this interface always represent an error. As a result, most of the normal ope
rations on elements | 10425 * this interface always represent an error. As a result, most of the normal ope
rations on elements |
| 10521 * do not make sense and will return useless results. | 10426 * do not make sense and will return useless results. |
| 10522 */ | 10427 */ |
| 10523 abstract class UndefinedElement implements Element { | 10428 abstract class UndefinedElement implements Element {} |
| 10524 } | |
| 10525 | 10429 |
| 10526 /** | 10430 /** |
| 10527 * The unique instance of the class `UndefinedTypeImpl` implements the type of | 10431 * The unique instance of the class `UndefinedTypeImpl` implements the type of |
| 10528 * typenames that couldn't be resolved. | 10432 * typenames that couldn't be resolved. |
| 10529 * | 10433 * |
| 10530 * This class behaves like DynamicTypeImpl in almost every respect, to reduce | 10434 * This class behaves like DynamicTypeImpl in almost every respect, to reduce |
| 10531 * cascading errors. | 10435 * cascading errors. |
| 10532 */ | 10436 */ |
| 10533 class UndefinedTypeImpl extends TypeImpl { | 10437 class UndefinedTypeImpl extends TypeImpl { |
| 10534 /** | 10438 /** |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10573 Set<TypeImpl_TypePair> visitedTypePairs) { | 10477 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10574 // T is S | 10478 // T is S |
| 10575 if (identical(this, type)) { | 10479 if (identical(this, type)) { |
| 10576 return true; | 10480 return true; |
| 10577 } | 10481 } |
| 10578 // else | 10482 // else |
| 10579 return withDynamic; | 10483 return withDynamic; |
| 10580 } | 10484 } |
| 10581 | 10485 |
| 10582 @override | 10486 @override |
| 10583 bool internalIsSubtypeOf(DartType type, | 10487 bool internalIsSubtypeOf( |
| 10584 Set<TypeImpl_TypePair> visitedTypePairs) => | 10488 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) => true; |
| 10585 true; | |
| 10586 | 10489 |
| 10587 @override | 10490 @override |
| 10588 bool isSupertypeOf(DartType type) => true; | 10491 bool isSupertypeOf(DartType type) => true; |
| 10589 | 10492 |
| 10590 @override | 10493 @override |
| 10591 DartType substitute2(List<DartType> argumentTypes, | 10494 DartType substitute2( |
| 10592 List<DartType> parameterTypes) { | 10495 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 10593 int length = parameterTypes.length; | 10496 int length = parameterTypes.length; |
| 10594 for (int i = 0; i < length; i++) { | 10497 for (int i = 0; i < length; i++) { |
| 10595 if (parameterTypes[i] == this) { | 10498 if (parameterTypes[i] == this) { |
| 10596 return argumentTypes[i]; | 10499 return argumentTypes[i]; |
| 10597 } | 10500 } |
| 10598 } | 10501 } |
| 10599 return this; | 10502 return this; |
| 10600 } | 10503 } |
| 10601 } | 10504 } |
| 10602 | 10505 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10683 | 10586 |
| 10684 @override | 10587 @override |
| 10685 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, | 10588 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, |
| 10686 Set<TypeImpl_TypePair> visitedTypePairs) { | 10589 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10687 // What version of subtyping do we want? See discussion below in | 10590 // What version of subtyping do we want? See discussion below in |
| 10688 // [internalIsSubtypeOf]. | 10591 // [internalIsSubtypeOf]. |
| 10689 if (AnalysisEngine.instance.strictUnionTypes) { | 10592 if (AnalysisEngine.instance.strictUnionTypes) { |
| 10690 // The less unsound version: all. | 10593 // The less unsound version: all. |
| 10691 for (DartType t in _types) { | 10594 for (DartType t in _types) { |
| 10692 if (!(t as TypeImpl).internalIsMoreSpecificThan( | 10595 if (!(t as TypeImpl).internalIsMoreSpecificThan( |
| 10693 type, | 10596 type, withDynamic, visitedTypePairs)) { |
| 10694 withDynamic, | |
| 10695 visitedTypePairs)) { | |
| 10696 return false; | 10597 return false; |
| 10697 } | 10598 } |
| 10698 } | 10599 } |
| 10699 return true; | 10600 return true; |
| 10700 } else { | 10601 } else { |
| 10701 // The more unsound version: any. | 10602 // The more unsound version: any. |
| 10702 for (DartType t in _types) { | 10603 for (DartType t in _types) { |
| 10703 if ((t as TypeImpl).internalIsMoreSpecificThan( | 10604 if ((t as TypeImpl).internalIsMoreSpecificThan( |
| 10704 type, | 10605 type, withDynamic, visitedTypePairs)) { |
| 10705 withDynamic, | |
| 10706 visitedTypePairs)) { | |
| 10707 return true; | 10606 return true; |
| 10708 } | 10607 } |
| 10709 } | 10608 } |
| 10710 return false; | 10609 return false; |
| 10711 } | 10610 } |
| 10712 } | 10611 } |
| 10713 | 10612 |
| 10714 @override | 10613 @override |
| 10715 bool internalIsSubtypeOf(DartType type, | 10614 bool internalIsSubtypeOf( |
| 10716 Set<TypeImpl_TypePair> visitedTypePairs) { | 10615 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10717 if (AnalysisEngine.instance.strictUnionTypes) { | 10616 if (AnalysisEngine.instance.strictUnionTypes) { |
| 10718 // The less unsound version: all. | 10617 // The less unsound version: all. |
| 10719 // | 10618 // |
| 10720 // For this version to make sense we also need to redefine assignment | 10619 // For this version to make sense we also need to redefine assignment |
| 10721 // compatibility [<=>]. | 10620 // compatibility [<=>]. |
| 10722 // See discussion above. | 10621 // See discussion above. |
| 10723 for (DartType t in _types) { | 10622 for (DartType t in _types) { |
| 10724 if (!(t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) { | 10623 if (!(t as TypeImpl).internalIsSubtypeOf(type, visitedTypePairs)) { |
| 10725 return false; | 10624 return false; |
| 10726 } | 10625 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 10749 bool internalUnionTypeIsLessSpecificThan(DartType type, bool withDynamic, | 10648 bool internalUnionTypeIsLessSpecificThan(DartType type, bool withDynamic, |
| 10750 Set<TypeImpl_TypePair> visitedTypePairs) { | 10649 Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10751 // This implementation does not make sense when [type] is a union type, | 10650 // This implementation does not make sense when [type] is a union type, |
| 10752 // at least for the "less unsound" version of [internalIsMoreSpecificThan] | 10651 // at least for the "less unsound" version of [internalIsMoreSpecificThan] |
| 10753 // above. | 10652 // above. |
| 10754 if (type is UnionType) { | 10653 if (type is UnionType) { |
| 10755 throw new IllegalArgumentException("Only non-union types are supported."); | 10654 throw new IllegalArgumentException("Only non-union types are supported."); |
| 10756 } | 10655 } |
| 10757 for (DartType t in _types) { | 10656 for (DartType t in _types) { |
| 10758 if ((type as TypeImpl).internalIsMoreSpecificThan( | 10657 if ((type as TypeImpl).internalIsMoreSpecificThan( |
| 10759 t, | 10658 t, withDynamic, visitedTypePairs)) { |
| 10760 withDynamic, | |
| 10761 visitedTypePairs)) { | |
| 10762 return true; | 10659 return true; |
| 10763 } | 10660 } |
| 10764 } | 10661 } |
| 10765 return false; | 10662 return false; |
| 10766 } | 10663 } |
| 10767 | 10664 |
| 10768 /** | 10665 /** |
| 10769 * The supertype test for union types is uniform in non-union subtypes. So, ot
her `TypeImpl` | 10666 * The supertype test for union types is uniform in non-union subtypes. So, ot
her `TypeImpl` |
| 10770 * s can call this method to implement `internalIsSubtypeOf` for union types. | 10667 * s can call this method to implement `internalIsSubtypeOf` for union types. |
| 10771 * | 10668 * |
| 10772 * @param type | 10669 * @param type |
| 10773 * @param visitedTypePairs | 10670 * @param visitedTypePairs |
| 10774 * @return true if this union type is a super type of `type` | 10671 * @return true if this union type is a super type of `type` |
| 10775 */ | 10672 */ |
| 10776 bool internalUnionTypeIsSuperTypeOf(DartType type, | 10673 bool internalUnionTypeIsSuperTypeOf( |
| 10777 Set<TypeImpl_TypePair> visitedTypePairs) { | 10674 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 10778 // This implementation does not make sense when [type] is a union type, | 10675 // This implementation does not make sense when [type] is a union type, |
| 10779 // at least for the "less unsound" version of [internalIsSubtypeOf] above. | 10676 // at least for the "less unsound" version of [internalIsSubtypeOf] above. |
| 10780 if (type is UnionType) { | 10677 if (type is UnionType) { |
| 10781 throw new IllegalArgumentException("Only non-union types are supported."); | 10678 throw new IllegalArgumentException("Only non-union types are supported."); |
| 10782 } | 10679 } |
| 10783 for (DartType t in _types) { | 10680 for (DartType t in _types) { |
| 10784 if ((type as TypeImpl).internalIsSubtypeOf(t, visitedTypePairs)) { | 10681 if ((type as TypeImpl).internalIsSubtypeOf(t, visitedTypePairs)) { |
| 10785 return true; | 10682 return true; |
| 10786 } | 10683 } |
| 10787 } | 10684 } |
| 10788 return false; | 10685 return false; |
| 10789 } | 10686 } |
| 10790 | 10687 |
| 10791 @override | 10688 @override |
| 10792 DartType substitute2(List<DartType> argumentTypes, | 10689 DartType substitute2( |
| 10793 List<DartType> parameterTypes) { | 10690 List<DartType> argumentTypes, List<DartType> parameterTypes) { |
| 10794 List<DartType> out = new List<DartType>(); | 10691 List<DartType> out = new List<DartType>(); |
| 10795 for (DartType t in _types) { | 10692 for (DartType t in _types) { |
| 10796 out.add(t.substitute2(argumentTypes, parameterTypes)); | 10693 out.add(t.substitute2(argumentTypes, parameterTypes)); |
| 10797 } | 10694 } |
| 10798 return union(out); | 10695 return union(out); |
| 10799 } | 10696 } |
| 10800 | 10697 |
| 10801 /** | 10698 /** |
| 10802 * Any unions in the `types` will be flattened in the returned union. If there
is only one | 10699 * Any unions in the `types` will be flattened in the returned union. If there
is only one |
| 10803 * type after flattening then it will be returned directly, instead of a singl
eton union. Nulls | 10700 * type after flattening then it will be returned directly, instead of a singl
eton union. Nulls |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10858 * | 10755 * |
| 10859 * @return the offset of the URI | 10756 * @return the offset of the URI |
| 10860 */ | 10757 */ |
| 10861 int get uriOffset; | 10758 int get uriOffset; |
| 10862 } | 10759 } |
| 10863 | 10760 |
| 10864 /** | 10761 /** |
| 10865 * Instances of the class `UriReferencedElementImpl` implement an [UriReferenced
Element] | 10762 * Instances of the class `UriReferencedElementImpl` implement an [UriReferenced
Element] |
| 10866 * . | 10763 * . |
| 10867 */ | 10764 */ |
| 10868 abstract class UriReferencedElementImpl extends ElementImpl implements | 10765 abstract class UriReferencedElementImpl extends ElementImpl |
| 10869 UriReferencedElement { | 10766 implements UriReferencedElement { |
| 10870 /** | 10767 /** |
| 10871 * The offset of the URI in the file, may be `-1` if synthetic. | 10768 * The offset of the URI in the file, may be `-1` if synthetic. |
| 10872 */ | 10769 */ |
| 10873 int uriOffset = -1; | 10770 int uriOffset = -1; |
| 10874 | 10771 |
| 10875 /** | 10772 /** |
| 10876 * The offset of the character immediately following the last character of thi
s node's URI, may be | 10773 * The offset of the character immediately following the last character of thi
s node's URI, may be |
| 10877 * `-1` if synthetic. | 10774 * `-1` if synthetic. |
| 10878 */ | 10775 */ |
| 10879 int uriEnd = -1; | 10776 int uriEnd = -1; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10939 * declared type (such as if it was declared using the keyword 'var'). | 10836 * declared type (such as if it was declared using the keyword 'var'). |
| 10940 * | 10837 * |
| 10941 * @return the declared type of this variable | 10838 * @return the declared type of this variable |
| 10942 */ | 10839 */ |
| 10943 DartType get type; | 10840 DartType get type; |
| 10944 } | 10841 } |
| 10945 | 10842 |
| 10946 /** | 10843 /** |
| 10947 * Instances of the class `VariableElementImpl` implement a `VariableElement`. | 10844 * Instances of the class `VariableElementImpl` implement a `VariableElement`. |
| 10948 */ | 10845 */ |
| 10949 abstract class VariableElementImpl extends ElementImpl implements | 10846 abstract class VariableElementImpl extends ElementImpl |
| 10950 VariableElement { | 10847 implements VariableElement { |
| 10951 /** | 10848 /** |
| 10952 * An empty list of variable elements. | 10849 * An empty list of variable elements. |
| 10953 */ | 10850 */ |
| 10954 static const List<VariableElement> EMPTY_ARRAY = const <VariableElement>[]; | 10851 static const List<VariableElement> EMPTY_ARRAY = const <VariableElement>[]; |
| 10955 | 10852 |
| 10956 /** | 10853 /** |
| 10957 * The declared type of this variable. | 10854 * The declared type of this variable. |
| 10958 */ | 10855 */ |
| 10959 DartType type; | 10856 DartType type; |
| 10960 | 10857 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11124 safelyVisitChild(baseElement.initializer, visitor); | 11021 safelyVisitChild(baseElement.initializer, visitor); |
| 11125 } | 11022 } |
| 11126 } | 11023 } |
| 11127 | 11024 |
| 11128 /** | 11025 /** |
| 11129 * The interface `VoidType` defines the behavior of the unique object representi
ng the type | 11026 * The interface `VoidType` defines the behavior of the unique object representi
ng the type |
| 11130 * `void`. | 11027 * `void`. |
| 11131 */ | 11028 */ |
| 11132 abstract class VoidType implements DartType { | 11029 abstract class VoidType implements DartType { |
| 11133 @override | 11030 @override |
| 11134 VoidType substitute2(List<DartType> argumentTypes, | 11031 VoidType substitute2( |
| 11135 List<DartType> parameterTypes); | 11032 List<DartType> argumentTypes, List<DartType> parameterTypes); |
| 11136 } | 11033 } |
| 11137 | 11034 |
| 11138 /** | 11035 /** |
| 11139 * The unique instance of the class `VoidTypeImpl` implements the type `void`. | 11036 * The unique instance of the class `VoidTypeImpl` implements the type `void`. |
| 11140 */ | 11037 */ |
| 11141 class VoidTypeImpl extends TypeImpl implements VoidType { | 11038 class VoidTypeImpl extends TypeImpl implements VoidType { |
| 11142 /** | 11039 /** |
| 11143 * The unique instance of this class. | 11040 * The unique instance of this class. |
| 11144 */ | 11041 */ |
| 11145 static VoidTypeImpl _INSTANCE = new VoidTypeImpl(); | 11042 static VoidTypeImpl _INSTANCE = new VoidTypeImpl(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 11167 | 11064 |
| 11168 @override | 11065 @override |
| 11169 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => | 11066 bool internalEquals(Object object, Set<ElementPair> visitedElementPairs) => |
| 11170 identical(object, this); | 11067 identical(object, this); |
| 11171 | 11068 |
| 11172 @override | 11069 @override |
| 11173 int internalHashCode(List<DartType> visitedTypes) => hashCode; | 11070 int internalHashCode(List<DartType> visitedTypes) => hashCode; |
| 11174 | 11071 |
| 11175 @override | 11072 @override |
| 11176 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, | 11073 bool internalIsMoreSpecificThan(DartType type, bool withDynamic, |
| 11177 Set<TypeImpl_TypePair> visitedTypePairs) => | 11074 Set<TypeImpl_TypePair> visitedTypePairs) => isSubtypeOf(type); |
| 11178 isSubtypeOf(type); | |
| 11179 | 11075 |
| 11180 @override | 11076 @override |
| 11181 bool internalIsSubtypeOf(DartType type, | 11077 bool internalIsSubtypeOf( |
| 11182 Set<TypeImpl_TypePair> visitedTypePairs) { | 11078 DartType type, Set<TypeImpl_TypePair> visitedTypePairs) { |
| 11183 if (type is UnionType) { | 11079 if (type is UnionType) { |
| 11184 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf( | 11080 return (type as UnionTypeImpl).internalUnionTypeIsSuperTypeOf( |
| 11185 this, | 11081 this, visitedTypePairs); |
| 11186 visitedTypePairs); | |
| 11187 } | 11082 } |
| 11188 // The only subtype relations that pertain to void are therefore: | 11083 // The only subtype relations that pertain to void are therefore: |
| 11189 // void <: void (by reflexivity) | 11084 // void <: void (by reflexivity) |
| 11190 // bottom <: void (as bottom is a subtype of all types). | 11085 // bottom <: void (as bottom is a subtype of all types). |
| 11191 // void <: dynamic (as dynamic is a supertype of all types) | 11086 // void <: dynamic (as dynamic is a supertype of all types) |
| 11192 return identical(type, this) || type.isDynamic; | 11087 return identical(type, this) || type.isDynamic; |
| 11193 } | 11088 } |
| 11194 | 11089 |
| 11195 @override | 11090 @override |
| 11196 VoidTypeImpl substitute2(List<DartType> argumentTypes, | 11091 VoidTypeImpl substitute2( |
| 11197 List<DartType> parameterTypes) => | 11092 List<DartType> argumentTypes, List<DartType> parameterTypes) => this; |
| 11198 this; | |
| 11199 } | 11093 } |
| OLD | NEW |