| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 library engine.resolver; | 3 library engine.resolver; |
| 4 import 'dart:collection'; | 4 import 'dart:collection'; |
| 5 import 'java_core.dart'; | 5 import 'java_core.dart'; |
| 6 import 'java_engine.dart'; | 6 import 'java_engine.dart'; |
| 7 import 'instrumentation.dart'; | 7 import 'instrumentation.dart'; |
| 8 import 'source.dart'; | 8 import 'source.dart'; |
| 9 import 'error.dart'; | 9 import 'error.dart'; |
| 10 import 'scanner.dart' as sc; | 10 import 'scanner.dart' as sc; |
| 11 import 'utilities_dart.dart'; |
| 11 import 'utilities_general.dart'; | 12 import 'utilities_general.dart'; |
| 12 import 'utilities_dart.dart'; | |
| 13 import 'ast.dart'; | 13 import 'ast.dart'; |
| 14 import 'parser.dart' show Parser, ParserErrorCode; | 14 import 'parser.dart' show Parser, ParserErrorCode; |
| 15 import 'sdk.dart' show DartSdk, SdkLibrary; | 15 import 'sdk.dart' show DartSdk, SdkLibrary; |
| 16 import 'element.dart'; | 16 import 'element.dart'; |
| 17 import 'html.dart' as ht; | 17 import 'html.dart' as ht; |
| 18 import 'engine.dart'; | 18 import 'engine.dart'; |
| 19 import 'constant.dart'; | 19 import 'constant.dart'; |
| 20 /** | 20 /** |
| 21 * Instances of the class `CompilationUnitBuilder` build an element model for a
single | 21 * Instances of the class `CompilationUnitBuilder` build an element model for a
single |
| 22 * compilation unit. | 22 * compilation unit. |
| (...skipping 3300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3323 Expression target = node.realTarget; | 3323 Expression target = node.realTarget; |
| 3324 if (target is SuperExpression && !isSuperInValidContext(target as SuperExpre
ssion)) { | 3324 if (target is SuperExpression && !isSuperInValidContext(target as SuperExpre
ssion)) { |
| 3325 return null; | 3325 return null; |
| 3326 } | 3326 } |
| 3327 Element staticElement; | 3327 Element staticElement; |
| 3328 Element propagatedElement; | 3328 Element propagatedElement; |
| 3329 if (target == null) { | 3329 if (target == null) { |
| 3330 staticElement = resolveInvokedElement2(methodName); | 3330 staticElement = resolveInvokedElement2(methodName); |
| 3331 propagatedElement = null; | 3331 propagatedElement = null; |
| 3332 } else { | 3332 } else { |
| 3333 staticElement = resolveInvokedElement(target, getStaticType(target), metho
dName); | 3333 Type2 staticType = getStaticType(target); |
| 3334 staticElement = resolveInvokedElement(target, staticType, methodName); |
| 3334 propagatedElement = resolveInvokedElement(target, getPropagatedType(target
), methodName); | 3335 propagatedElement = resolveInvokedElement(target, getPropagatedType(target
), methodName); |
| 3335 } | 3336 } |
| 3336 staticElement = convertSetterToGetter(staticElement); | 3337 staticElement = convertSetterToGetter(staticElement); |
| 3337 propagatedElement = convertSetterToGetter(propagatedElement); | 3338 propagatedElement = convertSetterToGetter(propagatedElement); |
| 3338 methodName.staticElement = staticElement; | 3339 methodName.staticElement = staticElement; |
| 3339 methodName.propagatedElement = propagatedElement; | 3340 methodName.propagatedElement = propagatedElement; |
| 3340 ArgumentList argumentList = node.argumentList; | 3341 ArgumentList argumentList = node.argumentList; |
| 3341 if (staticElement != null) { | 3342 if (staticElement != null) { |
| 3342 List<ParameterElement> parameters = computeCorrespondingParameters(argumen
tList, staticElement); | 3343 List<ParameterElement> parameters = computeCorrespondingParameters(argumen
tList, staticElement); |
| 3343 if (parameters != null) { | 3344 if (parameters != null) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3687 if (useStaticContext) { | 3688 if (useStaticContext) { |
| 3688 targetType = getStaticType(target); | 3689 targetType = getStaticType(target); |
| 3689 } else { | 3690 } else { |
| 3690 targetType = getPropagatedType(target); | 3691 targetType = getPropagatedType(target); |
| 3691 if (targetType == null) { | 3692 if (targetType == null) { |
| 3692 targetType = getStaticType(target); | 3693 targetType = getStaticType(target); |
| 3693 } | 3694 } |
| 3694 } | 3695 } |
| 3695 if (targetType == null) { | 3696 if (targetType == null) { |
| 3696 return CompileTimeErrorCode.UNDEFINED_FUNCTION; | 3697 return CompileTimeErrorCode.UNDEFINED_FUNCTION; |
| 3697 } else if (!targetType.isDynamic) { | 3698 } else if (!targetType.isDynamic && !targetType.isBottom) { |
| 3698 return StaticTypeWarningCode.UNDEFINED_METHOD; | 3699 return StaticTypeWarningCode.UNDEFINED_METHOD; |
| 3699 } | 3700 } |
| 3700 } | 3701 } |
| 3701 } | 3702 } |
| 3702 } | 3703 } |
| 3703 return null; | 3704 return null; |
| 3704 } | 3705 } |
| 3705 | 3706 |
| 3706 /** | 3707 /** |
| 3707 * Check that the for some index expression that the method element was resolv
ed, otherwise a | 3708 * Check that the for some index expression that the method element was resolv
ed, otherwise a |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3867 } | 3868 } |
| 3868 | 3869 |
| 3869 /** | 3870 /** |
| 3870 * Return the static type of the given expression that is to be used for type
analysis. | 3871 * Return the static type of the given expression that is to be used for type
analysis. |
| 3871 * | 3872 * |
| 3872 * @param expression the expression whose type is to be returned | 3873 * @param expression the expression whose type is to be returned |
| 3873 * @return the type of the given expression | 3874 * @return the type of the given expression |
| 3874 */ | 3875 */ |
| 3875 Type2 getStaticType(Expression expression) { | 3876 Type2 getStaticType(Expression expression) { |
| 3876 if (expression is NullLiteral) { | 3877 if (expression is NullLiteral) { |
| 3877 return _resolver.typeProvider.objectType; | 3878 return _resolver.typeProvider.bottomType; |
| 3878 } | 3879 } |
| 3879 Type2 staticType = resolveTypeParameter(expression.staticType); | 3880 Type2 staticType = resolveTypeParameter(expression.staticType); |
| 3880 if (staticType is FunctionType) { | 3881 if (staticType is FunctionType) { |
| 3881 staticType = _resolver.typeProvider.functionType; | 3882 staticType = _resolver.typeProvider.functionType; |
| 3882 } | 3883 } |
| 3883 return staticType; | 3884 return staticType; |
| 3884 } | 3885 } |
| 3885 | 3886 |
| 3886 /** | 3887 /** |
| 3887 * Return the element representing the superclass of the given class. | 3888 * Return the element representing the superclass of the given class. |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4725 | 4726 |
| 4726 /** | 4727 /** |
| 4727 * Return `true` if we should report an error as a result of looking up a memb
er in the | 4728 * Return `true` if we should report an error as a result of looking up a memb
er in the |
| 4728 * given type and not finding any member. | 4729 * given type and not finding any member. |
| 4729 * | 4730 * |
| 4730 * @param type the type in which we attempted to perform the look-up | 4731 * @param type the type in which we attempted to perform the look-up |
| 4731 * @param member the result of the look-up | 4732 * @param member the result of the look-up |
| 4732 * @return `true` if we should report an error | 4733 * @return `true` if we should report an error |
| 4733 */ | 4734 */ |
| 4734 bool shouldReportMissingMember(Type2 type, ExecutableElement member) { | 4735 bool shouldReportMissingMember(Type2 type, ExecutableElement member) { |
| 4735 if (member != null || type == null || type.isDynamic) { | 4736 if (member != null || type == null || type.isDynamic || type.isBottom) { |
| 4736 return false; | 4737 return false; |
| 4737 } | 4738 } |
| 4738 return true; | 4739 return true; |
| 4739 } | 4740 } |
| 4740 } | 4741 } |
| 4741 /** | 4742 /** |
| 4742 * Instances of the class `SyntheticIdentifier` implement an identifier that can
be used to | 4743 * Instances of the class `SyntheticIdentifier` implement an identifier that can
be used to |
| 4743 * look up names in the lexical scope when there is no identifier in the AST str
ucture. There is | 4744 * look up names in the lexical scope when there is no identifier in the AST str
ucture. There is |
| 4744 * no identifier in the AST when the parser could not distinguish between a meth
od invocation and | 4745 * no identifier in the AST when the parser could not distinguish between a meth
od invocation and |
| 4745 * an invocation of a top-level function imported with a prefix. | 4746 * an invocation of a top-level function imported with a prefix. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4779 | 4780 |
| 4780 /** | 4781 /** |
| 4781 * The [LibraryElement] that is managed by this manager. | 4782 * The [LibraryElement] that is managed by this manager. |
| 4782 */ | 4783 */ |
| 4783 LibraryElement _library; | 4784 LibraryElement _library; |
| 4784 | 4785 |
| 4785 /** | 4786 /** |
| 4786 * This is a mapping between each [ClassElement] and a map between the [String
] member | 4787 * This is a mapping between each [ClassElement] and a map between the [String
] member |
| 4787 * names and the associated [ExecutableElement] in the mixin and superclass ch
ain. | 4788 * names and the associated [ExecutableElement] in the mixin and superclass ch
ain. |
| 4788 */ | 4789 */ |
| 4789 Map<ClassElement, Map<String, ExecutableElement>> _classLookup; | 4790 Map<ClassElement, MemberMap> _classLookup; |
| 4790 | 4791 |
| 4791 /** | 4792 /** |
| 4792 * This is a mapping between each [ClassElement] and a map between the [String
] member | 4793 * This is a mapping between each [ClassElement] and a map between the [String
] member |
| 4793 * names and the associated [ExecutableElement] in the interface set. | 4794 * names and the associated [ExecutableElement] in the interface set. |
| 4794 */ | 4795 */ |
| 4795 Map<ClassElement, Map<String, ExecutableElement>> _interfaceLookup; | 4796 Map<ClassElement, MemberMap> _interfaceLookup; |
| 4796 | 4797 |
| 4797 /** | 4798 /** |
| 4798 * A map between each visited [ClassElement] and the set of [AnalysisError]s f
ound on | 4799 * A map between each visited [ClassElement] and the set of [AnalysisError]s f
ound on |
| 4799 * the class element. | 4800 * the class element. |
| 4800 */ | 4801 */ |
| 4801 Map<ClassElement, Set<AnalysisError>> _errorsInClassElement = new Map<ClassEle
ment, Set<AnalysisError>>(); | 4802 Map<ClassElement, Set<AnalysisError>> _errorsInClassElement = new Map<ClassEle
ment, Set<AnalysisError>>(); |
| 4802 | 4803 |
| 4803 /** | 4804 /** |
| 4804 * Initialize a newly created inheritance manager. | 4805 * Initialize a newly created inheritance manager. |
| 4805 * | 4806 * |
| 4806 * @param library the library element context that the inheritance mappings ar
e being generated | 4807 * @param library the library element context that the inheritance mappings ar
e being generated |
| 4807 */ | 4808 */ |
| 4808 InheritanceManager(LibraryElement library) { | 4809 InheritanceManager(LibraryElement library) { |
| 4809 this._library = library; | 4810 this._library = library; |
| 4810 _classLookup = new Map<ClassElement, Map<String, ExecutableElement>>(); | 4811 _classLookup = new Map<ClassElement, MemberMap>(); |
| 4811 _interfaceLookup = new Map<ClassElement, Map<String, ExecutableElement>>(); | 4812 _interfaceLookup = new Map<ClassElement, MemberMap>(); |
| 4812 } | 4813 } |
| 4813 | 4814 |
| 4814 /** | 4815 /** |
| 4815 * Return the set of [AnalysisError]s found on the passed [ClassElement], or | 4816 * Return the set of [AnalysisError]s found on the passed [ClassElement], or |
| 4816 * `null` if there are none. | 4817 * `null` if there are none. |
| 4817 * | 4818 * |
| 4818 * @param classElt the class element to query | 4819 * @param classElt the class element to query |
| 4819 * @return the set of [AnalysisError]s found on the passed [ClassElement], or | 4820 * @return the set of [AnalysisError]s found on the passed [ClassElement], or |
| 4820 * `null` if there are none | 4821 * `null` if there are none |
| 4821 */ | 4822 */ |
| 4822 Set<AnalysisError> getErrors(ClassElement classElt) => _errorsInClassElement[c
lassElt]; | 4823 Set<AnalysisError> getErrors(ClassElement classElt) => _errorsInClassElement[c
lassElt]; |
| 4823 | 4824 |
| 4824 /** | 4825 /** |
| 4825 * Get and return a mapping between the set of all string names of the members
inherited from the | 4826 * Get and return a mapping between the set of all string names of the members
inherited from the |
| 4826 * passed [ClassElement] superclass hierarchy, and the associated [ExecutableE
lement]. | 4827 * passed [ClassElement] superclass hierarchy, and the associated [ExecutableE
lement]. |
| 4827 * | 4828 * |
| 4828 * @param classElt the class element to query | 4829 * @param classElt the class element to query |
| 4829 * @return a mapping between the set of all members inherited from the passed
[ClassElement] | 4830 * @return a mapping between the set of all members inherited from the passed
[ClassElement] |
| 4830 * superclass hierarchy, and the associated [ExecutableElement] | 4831 * superclass hierarchy, and the associated [ExecutableElement] |
| 4831 */ | 4832 */ |
| 4832 Map<String, ExecutableElement> getMapOfMembersInheritedFromClasses(ClassElemen
t classElt) => computeClassChainLookupMap(classElt, new Set<ClassElement>()); | 4833 MemberMap getMapOfMembersInheritedFromClasses(ClassElement classElt) => comput
eClassChainLookupMap(classElt, new Set<ClassElement>()); |
| 4833 | 4834 |
| 4834 /** | 4835 /** |
| 4835 * Get and return a mapping between the set of all string names of the members
inherited from the | 4836 * Get and return a mapping between the set of all string names of the members
inherited from the |
| 4836 * passed [ClassElement] interface hierarchy, and the associated [ExecutableEl
ement]. | 4837 * passed [ClassElement] interface hierarchy, and the associated [ExecutableEl
ement]. |
| 4837 * | 4838 * |
| 4838 * @param classElt the class element to query | 4839 * @param classElt the class element to query |
| 4839 * @return a mapping between the set of all string names of the members inheri
ted from the passed | 4840 * @return a mapping between the set of all string names of the members inheri
ted from the passed |
| 4840 * [ClassElement] interface hierarchy, and the associated [ExecutableE
lement]. | 4841 * [ClassElement] interface hierarchy, and the associated [ExecutableE
lement]. |
| 4841 */ | 4842 */ |
| 4842 Map<String, ExecutableElement> getMapOfMembersInheritedFromInterfaces(ClassEle
ment classElt) => computeInterfaceLookupMap(classElt, new Set<ClassElement>()); | 4843 MemberMap getMapOfMembersInheritedFromInterfaces(ClassElement classElt) => com
puteInterfaceLookupMap(classElt, new Set<ClassElement>()); |
| 4843 | 4844 |
| 4844 /** | 4845 /** |
| 4845 * Given some [ClassElement] and some member name, this returns the | 4846 * Given some [ClassElement] and some member name, this returns the |
| 4846 * [ExecutableElement] that the class inherits from the mixins, | 4847 * [ExecutableElement] that the class inherits from the mixins, |
| 4847 * superclasses or interfaces, that has the member name, if no member is inher
ited `null` is | 4848 * superclasses or interfaces, that has the member name, if no member is inher
ited `null` is |
| 4848 * returned. | 4849 * returned. |
| 4849 * | 4850 * |
| 4850 * @param classElt the class element to query | 4851 * @param classElt the class element to query |
| 4851 * @param memberName the name of the executable element to find and return | 4852 * @param memberName the name of the executable element to find and return |
| 4852 * @return the inherited executable element with the member name, or `null` if
no such | 4853 * @return the inherited executable element with the member name, or `null` if
no such |
| 4853 * member exists | 4854 * member exists |
| 4854 */ | 4855 */ |
| 4855 ExecutableElement lookupInheritance(ClassElement classElt, String memberName)
{ | 4856 ExecutableElement lookupInheritance(ClassElement classElt, String memberName)
{ |
| 4856 if (memberName == null || memberName.isEmpty) { | 4857 if (memberName == null || memberName.isEmpty) { |
| 4857 return null; | 4858 return null; |
| 4858 } | 4859 } |
| 4859 ExecutableElement executable = computeClassChainLookupMap(classElt, new Set<
ClassElement>())[memberName]; | 4860 ExecutableElement executable = computeClassChainLookupMap(classElt, new Set<
ClassElement>()).get(memberName); |
| 4860 if (executable == null) { | 4861 if (executable == null) { |
| 4861 return computeInterfaceLookupMap(classElt, new Set<ClassElement>())[member
Name]; | 4862 return computeInterfaceLookupMap(classElt, new Set<ClassElement>()).get(me
mberName); |
| 4862 } | 4863 } |
| 4863 return executable; | 4864 return executable; |
| 4864 } | 4865 } |
| 4865 | 4866 |
| 4866 /** | 4867 /** |
| 4867 * Given some [ClassElement] and some member name, this returns the | 4868 * Given some [ClassElement] and some member name, this returns the |
| 4868 * [ExecutableElement] that the class either declares itself, or | 4869 * [ExecutableElement] that the class either declares itself, or |
| 4869 * inherits, that has the member name, if no member is inherited `null` is ret
urned. | 4870 * inherits, that has the member name, if no member is inherited `null` is ret
urned. |
| 4870 * | 4871 * |
| 4871 * @param classElt the class element to query | 4872 * @param classElt the class element to query |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4942 * Compute and return a mapping between the set of all string names of the mem
bers inherited from | 4943 * Compute and return a mapping between the set of all string names of the mem
bers inherited from |
| 4943 * the passed [ClassElement] superclass hierarchy, and the associated | 4944 * the passed [ClassElement] superclass hierarchy, and the associated |
| 4944 * [ExecutableElement]. | 4945 * [ExecutableElement]. |
| 4945 * | 4946 * |
| 4946 * @param classElt the class element to query | 4947 * @param classElt the class element to query |
| 4947 * @param visitedClasses a set of visited classes passed back into this method
when it calls | 4948 * @param visitedClasses a set of visited classes passed back into this method
when it calls |
| 4948 * itself recursively | 4949 * itself recursively |
| 4949 * @return a mapping between the set of all string names of the members inheri
ted from the passed | 4950 * @return a mapping between the set of all string names of the members inheri
ted from the passed |
| 4950 * [ClassElement] superclass hierarchy, and the associated [Executable
Element] | 4951 * [ClassElement] superclass hierarchy, and the associated [Executable
Element] |
| 4951 */ | 4952 */ |
| 4952 Map<String, ExecutableElement> computeClassChainLookupMap(ClassElement classEl
t, Set<ClassElement> visitedClasses) { | 4953 MemberMap computeClassChainLookupMap(ClassElement classElt, Set<ClassElement>
visitedClasses) { |
| 4953 Map<String, ExecutableElement> resultMap = _classLookup[classElt]; | 4954 MemberMap resultMap = _classLookup[classElt]; |
| 4954 if (resultMap != null) { | 4955 if (resultMap != null) { |
| 4955 return resultMap; | 4956 return resultMap; |
| 4956 } else { | 4957 } else { |
| 4957 resultMap = new Map<String, ExecutableElement>(); | 4958 resultMap = new MemberMap(); |
| 4958 } | 4959 } |
| 4959 ClassElement superclassElt = null; | 4960 ClassElement superclassElt = null; |
| 4960 InterfaceType supertype = classElt.supertype; | 4961 InterfaceType supertype = classElt.supertype; |
| 4961 if (supertype != null) { | 4962 if (supertype != null) { |
| 4962 superclassElt = supertype.element; | 4963 superclassElt = supertype.element; |
| 4963 } else { | 4964 } else { |
| 4964 _classLookup[classElt] = resultMap; | 4965 _classLookup[classElt] = resultMap; |
| 4965 return resultMap; | 4966 return resultMap; |
| 4966 } | 4967 } |
| 4967 if (superclassElt != null) { | 4968 if (superclassElt != null) { |
| 4968 if (!visitedClasses.contains(superclassElt)) { | 4969 if (!visitedClasses.contains(superclassElt)) { |
| 4969 javaSetAdd(visitedClasses, classElt); | 4970 javaSetAdd(visitedClasses, classElt); |
| 4970 resultMap = new Map<String, ExecutableElement>.from(computeClassChainLoo
kupMap(superclassElt, visitedClasses)); | 4971 resultMap = new MemberMap.con2(computeClassChainLookupMap(superclassElt,
visitedClasses)); |
| 4971 } else { | 4972 } else { |
| 4972 _classLookup[superclassElt] = resultMap; | 4973 _classLookup[superclassElt] = resultMap; |
| 4973 return resultMap; | 4974 return resultMap; |
| 4974 } | 4975 } |
| 4975 recordMapWithClassMembers(resultMap, supertype); | 4976 recordMapWithClassMembers(resultMap, supertype); |
| 4976 } | 4977 } |
| 4977 List<InterfaceType> mixins = classElt.mixins; | 4978 List<InterfaceType> mixins = classElt.mixins; |
| 4978 for (int i = mixins.length - 1; i >= 0; i--) { | 4979 for (int i = mixins.length - 1; i >= 0; i--) { |
| 4979 recordMapWithClassMembers(resultMap, mixins[i]); | 4980 recordMapWithClassMembers(resultMap, mixins[i]); |
| 4980 } | 4981 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5033 * Compute and return a mapping between the set of all string names of the mem
bers inherited from | 5034 * Compute and return a mapping between the set of all string names of the mem
bers inherited from |
| 5034 * the passed [ClassElement] interface hierarchy, and the associated | 5035 * the passed [ClassElement] interface hierarchy, and the associated |
| 5035 * [ExecutableElement]. | 5036 * [ExecutableElement]. |
| 5036 * | 5037 * |
| 5037 * @param classElt the class element to query | 5038 * @param classElt the class element to query |
| 5038 * @param visitedInterfaces a set of visited classes passed back into this met
hod when it calls | 5039 * @param visitedInterfaces a set of visited classes passed back into this met
hod when it calls |
| 5039 * itself recursively | 5040 * itself recursively |
| 5040 * @return a mapping between the set of all string names of the members inheri
ted from the passed | 5041 * @return a mapping between the set of all string names of the members inheri
ted from the passed |
| 5041 * [ClassElement] interface hierarchy, and the associated [ExecutableE
lement] | 5042 * [ClassElement] interface hierarchy, and the associated [ExecutableE
lement] |
| 5042 */ | 5043 */ |
| 5043 Map<String, ExecutableElement> computeInterfaceLookupMap(ClassElement classElt
, Set<ClassElement> visitedInterfaces) { | 5044 MemberMap computeInterfaceLookupMap(ClassElement classElt, Set<ClassElement> v
isitedInterfaces) { |
| 5044 Map<String, ExecutableElement> resultMap = _interfaceLookup[classElt]; | 5045 MemberMap resultMap = _interfaceLookup[classElt]; |
| 5045 if (resultMap != null) { | 5046 if (resultMap != null) { |
| 5046 return resultMap; | 5047 return resultMap; |
| 5047 } else { | 5048 } else { |
| 5048 resultMap = new Map<String, ExecutableElement>(); | 5049 resultMap = new MemberMap(); |
| 5049 } | 5050 } |
| 5050 InterfaceType supertype = classElt.supertype; | 5051 InterfaceType supertype = classElt.supertype; |
| 5051 ClassElement superclassElement = supertype != null ? supertype.element : nul
l; | 5052 ClassElement superclassElement = supertype != null ? supertype.element : nul
l; |
| 5052 List<InterfaceType> mixins = classElt.mixins; | 5053 List<InterfaceType> mixins = classElt.mixins; |
| 5053 List<InterfaceType> interfaces = classElt.interfaces; | 5054 List<InterfaceType> interfaces = classElt.interfaces; |
| 5054 List<Map<String, ExecutableElement>> lookupMaps = new List<Map<String, Execu
tableElement>>(); | 5055 List<MemberMap> lookupMaps = new List<MemberMap>(); |
| 5055 if (superclassElement != null) { | 5056 if (superclassElement != null) { |
| 5056 if (!visitedInterfaces.contains(superclassElement)) { | 5057 if (!visitedInterfaces.contains(superclassElement)) { |
| 5057 try { | 5058 try { |
| 5058 javaSetAdd(visitedInterfaces, superclassElement); | 5059 javaSetAdd(visitedInterfaces, superclassElement); |
| 5059 Map<String, ExecutableElement> map = computeInterfaceLookupMap(supercl
assElement, visitedInterfaces); | 5060 MemberMap map = computeInterfaceLookupMap(superclassElement, visitedIn
terfaces); |
| 5060 map = new Map<String, ExecutableElement>.from(map); | 5061 map = new MemberMap.con2(map); |
| 5061 List<MethodElement> methods = supertype.methods; | 5062 List<MethodElement> methods = supertype.methods; |
| 5062 for (MethodElement method in methods) { | 5063 for (MethodElement method in methods) { |
| 5063 if (method.isAccessibleIn(_library) && !method.isStatic) { | 5064 if (method.isAccessibleIn(_library) && !method.isStatic) { |
| 5064 map[method.name] = method; | 5065 map.put(method.name, method); |
| 5065 } | 5066 } |
| 5066 } | 5067 } |
| 5067 List<PropertyAccessorElement> accessors = supertype.accessors; | 5068 List<PropertyAccessorElement> accessors = supertype.accessors; |
| 5068 for (PropertyAccessorElement accessor in accessors) { | 5069 for (PropertyAccessorElement accessor in accessors) { |
| 5069 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) { | 5070 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) { |
| 5070 map[accessor.name] = accessor; | 5071 map.put(accessor.name, accessor); |
| 5071 } | 5072 } |
| 5072 } | 5073 } |
| 5073 lookupMaps.add(map); | 5074 lookupMaps.add(map); |
| 5074 } finally { | 5075 } finally { |
| 5075 visitedInterfaces.remove(superclassElement); | 5076 visitedInterfaces.remove(superclassElement); |
| 5076 } | 5077 } |
| 5077 } else { | 5078 } else { |
| 5078 Map<String, ExecutableElement> map = _interfaceLookup[classElt]; | 5079 MemberMap map = _interfaceLookup[classElt]; |
| 5079 if (map != null) { | 5080 if (map != null) { |
| 5080 lookupMaps.add(map); | 5081 lookupMaps.add(map); |
| 5081 } else { | 5082 } else { |
| 5082 _interfaceLookup[superclassElement] = resultMap; | 5083 _interfaceLookup[superclassElement] = resultMap; |
| 5083 return resultMap; | 5084 return resultMap; |
| 5084 } | 5085 } |
| 5085 } | 5086 } |
| 5086 } | 5087 } |
| 5087 for (InterfaceType mixinType in mixins) { | 5088 for (InterfaceType mixinType in mixins) { |
| 5088 Map<String, ExecutableElement> mapWithMixinMembers = new Map<String, Execu
tableElement>(); | 5089 MemberMap mapWithMixinMembers = new MemberMap(); |
| 5089 recordMapWithClassMembers(mapWithMixinMembers, mixinType); | 5090 recordMapWithClassMembers(mapWithMixinMembers, mixinType); |
| 5090 lookupMaps.add(mapWithMixinMembers); | 5091 lookupMaps.add(mapWithMixinMembers); |
| 5091 } | 5092 } |
| 5092 for (InterfaceType interfaceType in interfaces) { | 5093 for (InterfaceType interfaceType in interfaces) { |
| 5093 ClassElement interfaceElement = interfaceType.element; | 5094 ClassElement interfaceElement = interfaceType.element; |
| 5094 if (interfaceElement != null) { | 5095 if (interfaceElement != null) { |
| 5095 if (!visitedInterfaces.contains(interfaceElement)) { | 5096 if (!visitedInterfaces.contains(interfaceElement)) { |
| 5096 try { | 5097 try { |
| 5097 javaSetAdd(visitedInterfaces, interfaceElement); | 5098 javaSetAdd(visitedInterfaces, interfaceElement); |
| 5098 Map<String, ExecutableElement> map = computeInterfaceLookupMap(inter
faceElement, visitedInterfaces); | 5099 MemberMap map = computeInterfaceLookupMap(interfaceElement, visitedI
nterfaces); |
| 5099 map = new Map<String, ExecutableElement>.from(map); | 5100 map = new MemberMap.con2(map); |
| 5100 List<MethodElement> methods = interfaceType.methods; | 5101 List<MethodElement> methods = interfaceType.methods; |
| 5101 for (MethodElement method in methods) { | 5102 for (MethodElement method in methods) { |
| 5102 if (method.isAccessibleIn(_library) && !method.isStatic) { | 5103 if (method.isAccessibleIn(_library) && !method.isStatic) { |
| 5103 map[method.name] = method; | 5104 map.put(method.name, method); |
| 5104 } | 5105 } |
| 5105 } | 5106 } |
| 5106 List<PropertyAccessorElement> accessors = interfaceType.accessors; | 5107 List<PropertyAccessorElement> accessors = interfaceType.accessors; |
| 5107 for (PropertyAccessorElement accessor in accessors) { | 5108 for (PropertyAccessorElement accessor in accessors) { |
| 5108 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) { | 5109 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) { |
| 5109 map[accessor.name] = accessor; | 5110 map.put(accessor.name, accessor); |
| 5110 } | 5111 } |
| 5111 } | 5112 } |
| 5112 lookupMaps.add(map); | 5113 lookupMaps.add(map); |
| 5113 } finally { | 5114 } finally { |
| 5114 visitedInterfaces.remove(interfaceElement); | 5115 visitedInterfaces.remove(interfaceElement); |
| 5115 } | 5116 } |
| 5116 } else { | 5117 } else { |
| 5117 Map<String, ExecutableElement> map = _interfaceLookup[classElt]; | 5118 MemberMap map = _interfaceLookup[classElt]; |
| 5118 if (map != null) { | 5119 if (map != null) { |
| 5119 lookupMaps.add(map); | 5120 lookupMaps.add(map); |
| 5120 } else { | 5121 } else { |
| 5121 _interfaceLookup[interfaceElement] = resultMap; | 5122 _interfaceLookup[interfaceElement] = resultMap; |
| 5122 return resultMap; | 5123 return resultMap; |
| 5123 } | 5124 } |
| 5124 } | 5125 } |
| 5125 } | 5126 } |
| 5126 } | 5127 } |
| 5127 if (lookupMaps.length == 0) { | 5128 if (lookupMaps.length == 0) { |
| 5128 _interfaceLookup[classElt] = resultMap; | 5129 _interfaceLookup[classElt] = resultMap; |
| 5129 return resultMap; | 5130 return resultMap; |
| 5130 } | 5131 } |
| 5131 Map<String, Set<ExecutableElement>> unionMap = new Map<String, Set<Executabl
eElement>>(); | 5132 Map<String, Set<ExecutableElement>> unionMap = new Map<String, Set<Executabl
eElement>>(); |
| 5132 for (Map<String, ExecutableElement> lookupMap in lookupMaps) { | 5133 for (MemberMap lookupMap in lookupMaps) { |
| 5133 for (MapEntry<String, ExecutableElement> entry in getMapEntrySet(lookupMap
)) { | 5134 for (int i = 0; i < lookupMap.size; i++) { |
| 5134 String key = entry.getKey(); | 5135 String key = lookupMap.getKey(i); |
| 5136 if (key == null) { |
| 5137 break; |
| 5138 } |
| 5135 Set<ExecutableElement> set = unionMap[key]; | 5139 Set<ExecutableElement> set = unionMap[key]; |
| 5136 if (set == null) { | 5140 if (set == null) { |
| 5137 set = new Set<ExecutableElement>(); | 5141 set = new Set<ExecutableElement>(); |
| 5138 unionMap[key] = set; | 5142 unionMap[key] = set; |
| 5139 } | 5143 } |
| 5140 javaSetAdd(set, entry.getValue()); | 5144 javaSetAdd(set, lookupMap.getValue(i)); |
| 5141 } | 5145 } |
| 5142 } | 5146 } |
| 5143 for (MapEntry<String, Set<ExecutableElement>> entry in getMapEntrySet(unionM
ap)) { | 5147 for (MapEntry<String, Set<ExecutableElement>> entry in getMapEntrySet(unionM
ap)) { |
| 5144 String key = entry.getKey(); | 5148 String key = entry.getKey(); |
| 5145 Set<ExecutableElement> set = entry.getValue(); | 5149 Set<ExecutableElement> set = entry.getValue(); |
| 5146 int numOfEltsWithMatchingNames = set.length; | 5150 int numOfEltsWithMatchingNames = set.length; |
| 5147 if (numOfEltsWithMatchingNames == 1) { | 5151 if (numOfEltsWithMatchingNames == 1) { |
| 5148 resultMap[key] = new JavaIterator(set).next(); | 5152 resultMap.put(key, new JavaIterator(set).next()); |
| 5149 } else { | 5153 } else { |
| 5150 bool allMethods = true; | 5154 bool allMethods = true; |
| 5151 bool allSetters = true; | 5155 bool allSetters = true; |
| 5152 bool allGetters = true; | 5156 bool allGetters = true; |
| 5153 for (ExecutableElement executableElement in set) { | 5157 for (ExecutableElement executableElement in set) { |
| 5154 if (executableElement is PropertyAccessorElement) { | 5158 if (executableElement is PropertyAccessorElement) { |
| 5155 allMethods = false; | 5159 allMethods = false; |
| 5156 if (((executableElement as PropertyAccessorElement)).isSetter) { | 5160 if (((executableElement as PropertyAccessorElement)).isSetter) { |
| 5157 allGetters = false; | 5161 allGetters = false; |
| 5158 } else { | 5162 } else { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5179 for (int j = 0; j < numOfEltsWithMatchingNames && subtypeOfAllTypes;
j++) { | 5183 for (int j = 0; j < numOfEltsWithMatchingNames && subtypeOfAllTypes;
j++) { |
| 5180 if (i != j) { | 5184 if (i != j) { |
| 5181 if (!subtype.isSubtypeOf(executableElementTypes[j])) { | 5185 if (!subtype.isSubtypeOf(executableElementTypes[j])) { |
| 5182 subtypeOfAllTypes = false; | 5186 subtypeOfAllTypes = false; |
| 5183 break; | 5187 break; |
| 5184 } | 5188 } |
| 5185 } | 5189 } |
| 5186 } | 5190 } |
| 5187 if (subtypeOfAllTypes) { | 5191 if (subtypeOfAllTypes) { |
| 5188 foundSubtypeOfAllTypes = true; | 5192 foundSubtypeOfAllTypes = true; |
| 5189 resultMap[key] = elements[i]; | 5193 resultMap.put(key, elements[i]); |
| 5190 break; | 5194 break; |
| 5191 } | 5195 } |
| 5192 } | 5196 } |
| 5193 if (!foundSubtypeOfAllTypes) { | 5197 if (!foundSubtypeOfAllTypes) { |
| 5194 reportError(classElt, classElt.nameOffset, classElt.displayName.leng
th, StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE, [key]); | 5198 reportError(classElt, classElt.nameOffset, classElt.displayName.leng
th, StaticTypeWarningCode.INCONSISTENT_METHOD_INHERITANCE, [key]); |
| 5195 } | 5199 } |
| 5196 } else { | 5200 } else { |
| 5197 if (!allMethods && !allGetters) { | 5201 if (!allMethods && !allGetters) { |
| 5198 reportError(classElt, classElt.nameOffset, classElt.displayName.leng
th, StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD, [key]); | 5202 reportError(classElt, classElt.nameOffset, classElt.displayName.leng
th, StaticWarningCode.INCONSISTENT_METHOD_INHERITANCE_GETTER_AND_METHOD, [key]); |
| 5199 } | 5203 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5231 } | 5235 } |
| 5232 | 5236 |
| 5233 /** | 5237 /** |
| 5234 * Record the passed map with the set of all members (methods, getters and set
ters) in the type | 5238 * Record the passed map with the set of all members (methods, getters and set
ters) in the type |
| 5235 * into the passed map. | 5239 * into the passed map. |
| 5236 * | 5240 * |
| 5237 * @param map some non-`null` map to put the methods and accessors from the pa
ssed | 5241 * @param map some non-`null` map to put the methods and accessors from the pa
ssed |
| 5238 * [ClassElement] into | 5242 * [ClassElement] into |
| 5239 * @param type the type that will be recorded into the passed map | 5243 * @param type the type that will be recorded into the passed map |
| 5240 */ | 5244 */ |
| 5241 void recordMapWithClassMembers(Map<String, ExecutableElement> map, InterfaceTy
pe type) { | 5245 void recordMapWithClassMembers(MemberMap map, InterfaceType type) { |
| 5242 List<MethodElement> methods = type.methods; | 5246 List<MethodElement> methods = type.methods; |
| 5243 for (MethodElement method in methods) { | 5247 for (MethodElement method in methods) { |
| 5244 if (method.isAccessibleIn(_library) && !method.isStatic) { | 5248 if (method.isAccessibleIn(_library) && !method.isStatic) { |
| 5245 map[method.name] = method; | 5249 map.put(method.name, method); |
| 5246 } | 5250 } |
| 5247 } | 5251 } |
| 5248 List<PropertyAccessorElement> accessors = type.accessors; | 5252 List<PropertyAccessorElement> accessors = type.accessors; |
| 5249 for (PropertyAccessorElement accessor in accessors) { | 5253 for (PropertyAccessorElement accessor in accessors) { |
| 5250 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) { | 5254 if (accessor.isAccessibleIn(_library) && !accessor.isStatic) { |
| 5251 map[accessor.name] = accessor; | 5255 map.put(accessor.name, accessor); |
| 5252 } | 5256 } |
| 5253 } | 5257 } |
| 5254 } | 5258 } |
| 5255 | 5259 |
| 5256 /** | 5260 /** |
| 5257 * This method is used to report errors on when they are found computing inher
itance information. | 5261 * This method is used to report errors on when they are found computing inher
itance information. |
| 5258 * See [ErrorVerifier#checkForInconsistentMethodInheritance] to see where thes
e generated | 5262 * See [ErrorVerifier#checkForInconsistentMethodInheritance] to see where thes
e generated |
| 5259 * error codes are reported back into the analysis engine. | 5263 * error codes are reported back into the analysis engine. |
| 5260 * | 5264 * |
| 5261 * @param classElt the location of the source for which the exception occurred | 5265 * @param classElt the location of the source for which the exception occurred |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5837 } | 5841 } |
| 5838 buildDirectiveModels(); | 5842 buildDirectiveModels(); |
| 5839 instrumentation.metric3("buildDirectiveModels", "complete"); | 5843 instrumentation.metric3("buildDirectiveModels", "complete"); |
| 5840 _typeProvider = new TypeProviderImpl(coreElement); | 5844 _typeProvider = new TypeProviderImpl(coreElement); |
| 5841 buildTypeHierarchies(); | 5845 buildTypeHierarchies(); |
| 5842 instrumentation.metric3("buildTypeHierarchies", "complete"); | 5846 instrumentation.metric3("buildTypeHierarchies", "complete"); |
| 5843 resolveReferencesAndTypes(); | 5847 resolveReferencesAndTypes(); |
| 5844 instrumentation.metric3("resolveReferencesAndTypes", "complete"); | 5848 instrumentation.metric3("resolveReferencesAndTypes", "complete"); |
| 5845 performConstantEvaluation(); | 5849 performConstantEvaluation(); |
| 5846 instrumentation.metric3("performConstantEvaluation", "complete"); | 5850 instrumentation.metric3("performConstantEvaluation", "complete"); |
| 5847 if (fullAnalysis) { | |
| 5848 runAdditionalAnalyses(); | |
| 5849 instrumentation.metric3("runAdditionalAnalyses", "complete"); | |
| 5850 } | |
| 5851 return targetLibrary.libraryElement; | 5851 return targetLibrary.libraryElement; |
| 5852 } finally { | 5852 } finally { |
| 5853 instrumentation.log(); | 5853 instrumentation.log(); |
| 5854 } | 5854 } |
| 5855 } | 5855 } |
| 5856 | 5856 |
| 5857 /** | 5857 /** |
| 5858 * Resolve the library specified by the given source in the given context. | 5858 * Resolve the library specified by the given source in the given context. |
| 5859 * | 5859 * |
| 5860 * Note that because Dart allows circular imports between libraries, it is pos
sible that more than | 5860 * Note that because Dart allows circular imports between libraries, it is pos
sible that more than |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5888 } | 5888 } |
| 5889 buildDirectiveModels(); | 5889 buildDirectiveModels(); |
| 5890 instrumentation.metric3("buildDirectiveModels", "complete"); | 5890 instrumentation.metric3("buildDirectiveModels", "complete"); |
| 5891 _typeProvider = new TypeProviderImpl(coreElement); | 5891 _typeProvider = new TypeProviderImpl(coreElement); |
| 5892 buildTypeHierarchies(); | 5892 buildTypeHierarchies(); |
| 5893 instrumentation.metric3("buildTypeHierarchies", "complete"); | 5893 instrumentation.metric3("buildTypeHierarchies", "complete"); |
| 5894 resolveReferencesAndTypes(); | 5894 resolveReferencesAndTypes(); |
| 5895 instrumentation.metric3("resolveReferencesAndTypes", "complete"); | 5895 instrumentation.metric3("resolveReferencesAndTypes", "complete"); |
| 5896 performConstantEvaluation(); | 5896 performConstantEvaluation(); |
| 5897 instrumentation.metric3("performConstantEvaluation", "complete"); | 5897 instrumentation.metric3("performConstantEvaluation", "complete"); |
| 5898 if (fullAnalysis) { | |
| 5899 runAdditionalAnalyses(); | |
| 5900 instrumentation.metric3("runAdditionalAnalyses", "complete"); | |
| 5901 } | |
| 5902 instrumentation.metric2("librariesInCycles", resolvedLibraries.length); | 5898 instrumentation.metric2("librariesInCycles", resolvedLibraries.length); |
| 5903 for (Library lib in resolvedLibraries) { | 5899 for (Library lib in resolvedLibraries) { |
| 5904 instrumentation.metric2("librariesInCycles-CompilationUnitSources-Size",
lib.compilationUnitSources.length); | 5900 instrumentation.metric2("librariesInCycles-CompilationUnitSources-Size",
lib.compilationUnitSources.length); |
| 5905 } | 5901 } |
| 5906 return targetLibrary.libraryElement; | 5902 return targetLibrary.libraryElement; |
| 5907 } finally { | 5903 } finally { |
| 5908 instrumentation.log(); | 5904 instrumentation.log(); |
| 5909 } | 5905 } |
| 5910 } | 5906 } |
| 5911 | 5907 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6374 if (uriLiteral is StringInterpolation) { | 6370 if (uriLiteral is StringInterpolation) { |
| 6375 return null; | 6371 return null; |
| 6376 } | 6372 } |
| 6377 String uriContent = uriLiteral.stringValue.trim(); | 6373 String uriContent = uriLiteral.stringValue.trim(); |
| 6378 if (uriContent == null || uriContent.isEmpty) { | 6374 if (uriContent == null || uriContent.isEmpty) { |
| 6379 return null; | 6375 return null; |
| 6380 } | 6376 } |
| 6381 uriContent = Uri.encodeFull(uriContent); | 6377 uriContent = Uri.encodeFull(uriContent); |
| 6382 return analysisContext.sourceFactory.resolveUri(librarySource, uriContent); | 6378 return analysisContext.sourceFactory.resolveUri(librarySource, uriContent); |
| 6383 } | 6379 } |
| 6380 } |
| 6381 /** |
| 6382 * This class is used to replace uses of `HashMap<String, ExecutableElement>` wh
ich are not as |
| 6383 * performant as this class. |
| 6384 */ |
| 6385 class MemberMap { |
| 6384 | 6386 |
| 6385 /** | 6387 /** |
| 6386 * Run additional analyses, such as the [ConstantVerifier] and [ErrorVerifier] | 6388 * The current size of this map. |
| 6387 * analysis in the current cycle. | 6389 */ |
| 6390 int size = 0; |
| 6391 |
| 6392 /** |
| 6393 * The array of keys. |
| 6394 */ |
| 6395 List<String> _keys; |
| 6396 |
| 6397 /** |
| 6398 * The array of ExecutableElement values. |
| 6399 */ |
| 6400 List<ExecutableElement> _values; |
| 6401 |
| 6402 /** |
| 6403 * Default constructor. |
| 6404 */ |
| 6405 MemberMap() : this.con1(10); |
| 6406 |
| 6407 /** |
| 6408 * This constructor takes an initial capacity of the map. |
| 6388 * | 6409 * |
| 6389 * @throws AnalysisException if any of the identifiers could not be resolved o
r if the types in | 6410 * @param initialCapacity the initial capacity |
| 6390 * the library cannot be analyzed | |
| 6391 */ | 6411 */ |
| 6392 void runAdditionalAnalyses() { | 6412 MemberMap.con1(int initialCapacity) { |
| 6393 for (Library library in resolvedLibraries) { | 6413 initArrays(initialCapacity); |
| 6394 runAdditionalAnalyses2(library); | 6414 } |
| 6415 |
| 6416 /** |
| 6417 * Copy constructor. |
| 6418 */ |
| 6419 MemberMap.con2(MemberMap memberMap) { |
| 6420 initArrays(memberMap.size + 5); |
| 6421 for (int i = 0; i < memberMap.size; i++) { |
| 6422 _keys[i] = memberMap._keys[i]; |
| 6423 _values[i] = memberMap._values[i]; |
| 6424 } |
| 6425 size = memberMap.size; |
| 6426 } |
| 6427 |
| 6428 /** |
| 6429 * Given some key, return the ExecutableElement value from the map, if the key
does not exist in |
| 6430 * the map, `null` is returned. |
| 6431 * |
| 6432 * @param key some key to look up in the map |
| 6433 * @return the associated ExecutableElement value from the map, if the key doe
s not exist in the |
| 6434 * map, `null` is returned |
| 6435 */ |
| 6436 ExecutableElement get(String key) { |
| 6437 for (int i = 0; i < size; i++) { |
| 6438 if (_keys[i] != null && _keys[i] == key) { |
| 6439 return _values[i]; |
| 6440 } |
| 6441 } |
| 6442 return null; |
| 6443 } |
| 6444 |
| 6445 /** |
| 6446 * Get and return the key at the specified location. If the key/value pair has
been removed from |
| 6447 * the set, then `null` is returned. |
| 6448 * |
| 6449 * @param i some non-zero value less than size |
| 6450 * @return the key at the passed index |
| 6451 * @throw ArrayIndexOutOfBoundsException this exception is thrown if the passe
d index is less than |
| 6452 * zero or greater than or equal to the capacity of the arrays |
| 6453 */ |
| 6454 String getKey(int i) => _keys[i]; |
| 6455 |
| 6456 /** |
| 6457 * Get and return the ExecutableElement at the specified location. If the key/
value pair has been |
| 6458 * removed from the set, then then `null` is returned. |
| 6459 * |
| 6460 * @param i some non-zero value less than size |
| 6461 * @return the key at the passed index |
| 6462 * @throw ArrayIndexOutOfBoundsException this exception is thrown if the passe
d index is less than |
| 6463 * zero or greater than or equal to the capacity of the arrays |
| 6464 */ |
| 6465 ExecutableElement getValue(int i) => _values[i]; |
| 6466 |
| 6467 /** |
| 6468 * Given some key/value pair, store the pair in the map. If the key exists alr
eady, then the new |
| 6469 * value overrides the old value. |
| 6470 * |
| 6471 * @param key the key to store in the map |
| 6472 * @param value the ExecutableElement value to store in the map |
| 6473 */ |
| 6474 void put(String key, ExecutableElement value) { |
| 6475 for (int i = 0; i < size; i++) { |
| 6476 if (_keys[i] != null && _keys[i] == key) { |
| 6477 _values[i] = value; |
| 6478 return; |
| 6479 } |
| 6480 } |
| 6481 if (size == _keys.length) { |
| 6482 int newArrayLength = size * 2; |
| 6483 List<String> keys_new_array = new List<String>(newArrayLength); |
| 6484 List<ExecutableElement> values_new_array = new List<ExecutableElement>(new
ArrayLength); |
| 6485 for (int i = 0; i < size; i++) { |
| 6486 keys_new_array[i] = _keys[i]; |
| 6487 } |
| 6488 for (int i = 0; i < size; i++) { |
| 6489 values_new_array[i] = _values[i]; |
| 6490 } |
| 6491 _keys = keys_new_array; |
| 6492 _values = values_new_array; |
| 6493 } |
| 6494 _keys[size] = key; |
| 6495 _values[size] = value; |
| 6496 size++; |
| 6497 } |
| 6498 |
| 6499 /** |
| 6500 * Given some String key, this method replaces the associated key and value pa
ir with `null` |
| 6501 * . The size is not decremented with this call, instead it is expected that t
he users check for |
| 6502 * `null`. |
| 6503 * |
| 6504 * @param key the key of the key/value pair to remove from the map |
| 6505 */ |
| 6506 void remove(String key) { |
| 6507 for (int i = 0; i < size; i++) { |
| 6508 if (_keys[i] == key) { |
| 6509 _keys[i] = null; |
| 6510 _values[i] = null; |
| 6511 return; |
| 6512 } |
| 6395 } | 6513 } |
| 6396 } | 6514 } |
| 6397 | 6515 |
| 6398 /** | 6516 /** |
| 6399 * Run additional analyses, such as the [ConstantVerifier] and [ErrorVerifier] | 6517 * Initializes [keys] and [values]. |
| 6400 * analysis in the given library. | |
| 6401 * | |
| 6402 * @param library the library to have the extra analyses processes run | |
| 6403 * @throws AnalysisException if any of the identifiers could not be resolved o
r if the types in | |
| 6404 * the library cannot be analyzed | |
| 6405 */ | 6518 */ |
| 6406 void runAdditionalAnalyses2(Library library) { | 6519 void initArrays(int initialCapacity) { |
| 6407 TimeCounter_TimeCounterHandle timeCounter = PerformanceStatistics.errors.sta
rt(); | 6520 _keys = new List<String>(initialCapacity); |
| 6408 for (Source source in library.compilationUnitSources) { | 6521 _values = new List<ExecutableElement>(initialCapacity); |
| 6409 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | |
| 6410 CompilationUnit unit = library.getAST(source); | |
| 6411 ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _t
ypeProvider); | |
| 6412 unit.accept(constantVerifier); | |
| 6413 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, library.lib
raryElement, _typeProvider, library.inheritanceManager); | |
| 6414 unit.accept(errorVerifier); | |
| 6415 } | |
| 6416 timeCounter.stop(); | |
| 6417 } | 6522 } |
| 6418 } | 6523 } |
| 6419 /** | 6524 /** |
| 6420 * This class is a wrapper for an [AnalysisError] which can also be queried afte
r resolution | 6525 * This class is a wrapper for an [AnalysisError] which can also be queried afte
r resolution |
| 6421 * to find out if the error should actually be reported. In this case, these err
ors are conditional | 6526 * to find out if the error should actually be reported. In this case, these err
ors are conditional |
| 6422 * on the non-existence of an `@proxy` annotation. | 6527 * on the non-existence of an `@proxy` annotation. |
| 6423 * | 6528 * |
| 6424 * If we have other conditional error codes in the future, we should have this c
lass implement some | 6529 * If we have other conditional error codes in the future, we should have this c
lass implement some |
| 6425 * ConditionalErrorCode so that after resolution, a list of ConditionalErrorCode
can be visited | 6530 * ConditionalErrorCode so that after resolution, a list of ConditionalErrorCode
can be visited |
| 6426 * instead of multiple lists of *ConditionalErrorCodes. | 6531 * instead of multiple lists of *ConditionalErrorCodes. |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7003 | 7108 |
| 7004 /** | 7109 /** |
| 7005 * If it is appropriate to do so, override the current type of the given eleme
nt with the given | 7110 * If it is appropriate to do so, override the current type of the given eleme
nt with the given |
| 7006 * type. Generally speaking, it is appropriate if the given type is more speci
fic than the current | 7111 * type. Generally speaking, it is appropriate if the given type is more speci
fic than the current |
| 7007 * type. | 7112 * type. |
| 7008 * | 7113 * |
| 7009 * @param element the element whose type might be overridden | 7114 * @param element the element whose type might be overridden |
| 7010 * @param potentialType the potential type of the element | 7115 * @param potentialType the potential type of the element |
| 7011 */ | 7116 */ |
| 7012 void override2(VariableElement element, Type2 potentialType) { | 7117 void override2(VariableElement element, Type2 potentialType) { |
| 7013 if (potentialType == null || identical(potentialType, BottomTypeImpl.instanc
e)) { | 7118 if (potentialType == null || potentialType.isBottom) { |
| 7014 return; | 7119 return; |
| 7015 } | 7120 } |
| 7016 if (element is PropertyInducingElement) { | 7121 if (element is PropertyInducingElement) { |
| 7017 PropertyInducingElement variable = element as PropertyInducingElement; | 7122 PropertyInducingElement variable = element as PropertyInducingElement; |
| 7018 if (!variable.isConst && !variable.isFinal) { | 7123 if (!variable.isConst && !variable.isFinal) { |
| 7019 return; | 7124 return; |
| 7020 } | 7125 } |
| 7021 } | 7126 } |
| 7022 Type2 currentType = getBestType(element); | 7127 Type2 currentType = getBestType(element); |
| 7023 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { | 7128 if (currentType == null || !currentType.isMoreSpecificThan(potentialType)) { |
| (...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8989 * Compute the static return type of the method or function represented by the
given element. | 9094 * Compute the static return type of the method or function represented by the
given element. |
| 8990 * | 9095 * |
| 8991 * @param element the element representing the method or function invoked by t
he given node | 9096 * @param element the element representing the method or function invoked by t
he given node |
| 8992 * @return the static return type that was computed | 9097 * @return the static return type that was computed |
| 8993 */ | 9098 */ |
| 8994 Type2 computeStaticReturnType(Element element) { | 9099 Type2 computeStaticReturnType(Element element) { |
| 8995 if (element is PropertyAccessorElement) { | 9100 if (element is PropertyAccessorElement) { |
| 8996 FunctionType propertyType = ((element as PropertyAccessorElement)).type; | 9101 FunctionType propertyType = ((element as PropertyAccessorElement)).type; |
| 8997 if (propertyType != null) { | 9102 if (propertyType != null) { |
| 8998 Type2 returnType = propertyType.returnType; | 9103 Type2 returnType = propertyType.returnType; |
| 8999 if (returnType is InterfaceType) { | 9104 if (returnType.isDartCoreFunction) { |
| 9000 if (identical(returnType, _typeProvider.functionType)) { | 9105 return _dynamicType; |
| 9001 return _dynamicType; | 9106 } else if (returnType is InterfaceType) { |
| 9002 } | |
| 9003 MethodElement callMethod = ((returnType as InterfaceType)).lookUpMetho
d(ElementResolver.CALL_METHOD_NAME, _resolver.definingLibrary); | 9107 MethodElement callMethod = ((returnType as InterfaceType)).lookUpMetho
d(ElementResolver.CALL_METHOD_NAME, _resolver.definingLibrary); |
| 9004 if (callMethod != null) { | 9108 if (callMethod != null) { |
| 9005 return callMethod.type.returnType; | 9109 return callMethod.type.returnType; |
| 9006 } | 9110 } |
| 9007 } else if (returnType is FunctionType) { | 9111 } else if (returnType is FunctionType) { |
| 9008 Type2 innerReturnType = ((returnType as FunctionType)).returnType; | 9112 Type2 innerReturnType = ((returnType as FunctionType)).returnType; |
| 9009 if (innerReturnType != null) { | 9113 if (innerReturnType != null) { |
| 9010 return innerReturnType; | 9114 return innerReturnType; |
| 9011 } | 9115 } |
| 9012 } else if (returnType.isDartCoreFunction) { | |
| 9013 return _dynamicType; | |
| 9014 } | 9116 } |
| 9015 if (returnType != null) { | 9117 if (returnType != null) { |
| 9016 return returnType; | 9118 return returnType; |
| 9017 } | 9119 } |
| 9018 } | 9120 } |
| 9019 } else if (element is ExecutableElement) { | 9121 } else if (element is ExecutableElement) { |
| 9020 FunctionType type = ((element as ExecutableElement)).type; | 9122 FunctionType type = ((element as ExecutableElement)).type; |
| 9021 if (type != null) { | 9123 if (type != null) { |
| 9022 return type.returnType; | 9124 return type.returnType; |
| 9023 } | 9125 } |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9267 * @param functionElement the function element to record propagated return typ
e for | 9369 * @param functionElement the function element to record propagated return typ
e for |
| 9268 * @param body the boy of the function whose propagated return type is to be c
omputed | 9370 * @param body the boy of the function whose propagated return type is to be c
omputed |
| 9269 * @return the propagated return type that was computed, may be `null` if it i
s not more | 9371 * @return the propagated return type that was computed, may be `null` if it i
s not more |
| 9270 * specific than the static return type. | 9372 * specific than the static return type. |
| 9271 */ | 9373 */ |
| 9272 void recordPropagatedType(ExecutableElement functionElement, FunctionBody body
) { | 9374 void recordPropagatedType(ExecutableElement functionElement, FunctionBody body
) { |
| 9273 Type2 propagatedReturnType = computePropagatedReturnType2(body); | 9375 Type2 propagatedReturnType = computePropagatedReturnType2(body); |
| 9274 if (propagatedReturnType == null) { | 9376 if (propagatedReturnType == null) { |
| 9275 return; | 9377 return; |
| 9276 } | 9378 } |
| 9277 if (identical(propagatedReturnType, BottomTypeImpl.instance)) { | 9379 if (propagatedReturnType.isBottom) { |
| 9278 return; | 9380 return; |
| 9279 } | 9381 } |
| 9280 Type2 staticReturnType = functionElement.returnType; | 9382 Type2 staticReturnType = functionElement.returnType; |
| 9281 if (!propagatedReturnType.isMoreSpecificThan(staticReturnType)) { | 9383 if (!propagatedReturnType.isMoreSpecificThan(staticReturnType)) { |
| 9282 return; | 9384 return; |
| 9283 } | 9385 } |
| 9284 _propagatedReturnTypes[functionElement] = propagatedReturnType; | 9386 _propagatedReturnTypes[functionElement] = propagatedReturnType; |
| 9285 } | 9387 } |
| 9286 | 9388 |
| 9287 /** | 9389 /** |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9817 * Instances of the class `TypeResolverVisitor` are used to resolve the types as
sociated with | 9919 * Instances of the class `TypeResolverVisitor` are used to resolve the types as
sociated with |
| 9818 * the elements in the element model. This includes the types of superclasses, m
ixins, interfaces, | 9920 * the elements in the element model. This includes the types of superclasses, m
ixins, interfaces, |
| 9819 * fields, methods, parameters, and local variables. As a side-effect, this also
finishes building | 9921 * fields, methods, parameters, and local variables. As a side-effect, this also
finishes building |
| 9820 * the type hierarchy. | 9922 * the type hierarchy. |
| 9821 * | 9923 * |
| 9822 * @coverage dart.engine.resolver | 9924 * @coverage dart.engine.resolver |
| 9823 */ | 9925 */ |
| 9824 class TypeResolverVisitor extends ScopedVisitor { | 9926 class TypeResolverVisitor extends ScopedVisitor { |
| 9825 | 9927 |
| 9826 /** | 9928 /** |
| 9929 * @return `true` if the name of the given [TypeName] is an built-in identifie
r. |
| 9930 */ |
| 9931 static bool isBuiltInIdentifier(TypeName node) { |
| 9932 sc.Token token = node.name.beginToken; |
| 9933 return identical(token.type, sc.TokenType.KEYWORD); |
| 9934 } |
| 9935 |
| 9936 /** |
| 9937 * @return `true` if given [TypeName] is used as a type annotation. |
| 9938 */ |
| 9939 static bool isTypeAnnotation(TypeName node) { |
| 9940 ASTNode parent = node.parent; |
| 9941 if (parent is VariableDeclarationList) { |
| 9942 return identical(((parent as VariableDeclarationList)).type, node); |
| 9943 } |
| 9944 if (parent is FieldFormalParameter) { |
| 9945 return identical(((parent as FieldFormalParameter)).type, node); |
| 9946 } |
| 9947 if (parent is SimpleFormalParameter) { |
| 9948 return identical(((parent as SimpleFormalParameter)).type, node); |
| 9949 } |
| 9950 return false; |
| 9951 } |
| 9952 |
| 9953 /** |
| 9827 * The type representing the type 'dynamic'. | 9954 * The type representing the type 'dynamic'. |
| 9828 */ | 9955 */ |
| 9829 Type2 _dynamicType; | 9956 Type2 _dynamicType; |
| 9830 | 9957 |
| 9831 /** | 9958 /** |
| 9832 * The flag specifying if currently visited class references 'super' expressio
n. | 9959 * The flag specifying if currently visited class references 'super' expressio
n. |
| 9833 */ | 9960 */ |
| 9834 bool _hasReferenceToSuper = false; | 9961 bool _hasReferenceToSuper = false; |
| 9835 | 9962 |
| 9836 /** | 9963 /** |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10100 elementValid = false; | 10227 elementValid = false; |
| 10101 } else { | 10228 } else { |
| 10102 if (element != null) { | 10229 if (element != null) { |
| 10103 reportError5(StaticWarningCode.NEW_WITH_NON_TYPE, typeNameSimple, [typ
eName]); | 10230 reportError5(StaticWarningCode.NEW_WITH_NON_TYPE, typeNameSimple, [typ
eName]); |
| 10104 elementValid = false; | 10231 elementValid = false; |
| 10105 } | 10232 } |
| 10106 } | 10233 } |
| 10107 } | 10234 } |
| 10108 if (elementValid && element == null) { | 10235 if (elementValid && element == null) { |
| 10109 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); | 10236 SimpleIdentifier typeNameSimple = getTypeSimpleIdentifier(typeName); |
| 10110 if (typeNameSimple.name == "boolean") { | 10237 if (isBuiltInIdentifier(node) && isTypeAnnotation(node)) { |
| 10238 reportError5(CompileTimeErrorCode.BUILT_IN_IDENTIFIER_AS_TYPE, typeName,
[typeName.name]); |
| 10239 } else if (typeNameSimple.name == "boolean") { |
| 10111 reportError5(StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, typeNameSimple,
[]); | 10240 reportError5(StaticWarningCode.UNDEFINED_CLASS_BOOLEAN, typeNameSimple,
[]); |
| 10112 } else if (isTypeNameInCatchClause(node)) { | 10241 } else if (isTypeNameInCatchClause(node)) { |
| 10113 reportError5(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [type
Name.name]); | 10242 reportError5(StaticWarningCode.NON_TYPE_IN_CATCH_CLAUSE, typeName, [type
Name.name]); |
| 10114 } else if (isTypeNameInAsExpression(node)) { | 10243 } else if (isTypeNameInAsExpression(node)) { |
| 10115 reportError5(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.nam
e]); | 10244 reportError5(StaticWarningCode.CAST_TO_NON_TYPE, typeName, [typeName.nam
e]); |
| 10116 } else if (isTypeNameInIsExpression(node)) { | 10245 } else if (isTypeNameInIsExpression(node)) { |
| 10117 reportError5(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [typeName.n
ame]); | 10246 reportError5(StaticWarningCode.TYPE_TEST_NON_TYPE, typeName, [typeName.n
ame]); |
| 10118 } else if (isTypeNameTargetInRedirectedConstructor(node)) { | 10247 } else if (isTypeNameTargetInRedirectedConstructor(node)) { |
| 10119 reportError5(StaticWarningCode.REDIRECT_TO_NON_CLASS, typeName, [typeNam
e.name]); | 10248 reportError5(StaticWarningCode.REDIRECT_TO_NON_CLASS, typeName, [typeNam
e.name]); |
| 10120 } else if (isTypeNameInTypeArgumentList(node)) { | 10249 } else if (isTypeNameInTypeArgumentList(node)) { |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10991 String libName1 = "", libName2 = ""; | 11120 String libName1 = "", libName2 = ""; |
| 10992 List<Element> conflictingMembers = ((foundElement as MultiplyDefinedElemen
tImpl)).conflictingElements; | 11121 List<Element> conflictingMembers = ((foundElement as MultiplyDefinedElemen
tImpl)).conflictingElements; |
| 10993 LibraryElement enclosingLibrary = conflictingMembers[0].getAncestor(Librar
yElement); | 11122 LibraryElement enclosingLibrary = conflictingMembers[0].getAncestor(Librar
yElement); |
| 10994 if (enclosingLibrary != null) { | 11123 if (enclosingLibrary != null) { |
| 10995 libName1 = enclosingLibrary.definingCompilationUnit.displayName; | 11124 libName1 = enclosingLibrary.definingCompilationUnit.displayName; |
| 10996 } | 11125 } |
| 10997 enclosingLibrary = conflictingMembers[1].getAncestor(LibraryElement); | 11126 enclosingLibrary = conflictingMembers[1].getAncestor(LibraryElement); |
| 10998 if (enclosingLibrary != null) { | 11127 if (enclosingLibrary != null) { |
| 10999 libName2 = enclosingLibrary.definingCompilationUnit.displayName; | 11128 libName2 = enclosingLibrary.definingCompilationUnit.displayName; |
| 11000 } | 11129 } |
| 11001 _errorListener.onError(new AnalysisError.con2(source, identifier.offset, i
dentifier.length, StaticWarningCode.AMBIGUOUS_IMPORT, [foundEltName, libName1, l
ibName2])); | 11130 _errorListener.onError(new AnalysisError.con2(getSource2(identifier), iden
tifier.offset, identifier.length, StaticWarningCode.AMBIGUOUS_IMPORT, [foundEltN
ame, libName1, libName2])); |
| 11002 return foundElement; | 11131 return foundElement; |
| 11003 } | 11132 } |
| 11004 if (foundElement != null) { | 11133 if (foundElement != null) { |
| 11005 defineWithoutChecking2(name, foundElement); | 11134 defineWithoutChecking2(name, foundElement); |
| 11006 } | 11135 } |
| 11007 return foundElement; | 11136 return foundElement; |
| 11008 } | 11137 } |
| 11009 | 11138 |
| 11010 /** | 11139 /** |
| 11011 * Create all of the namespaces associated with the libraries imported into th
is library. The | 11140 * Create all of the namespaces associated with the libraries imported into th
is library. The |
| 11012 * names are not added to this scope, but are stored for later reference. | 11141 * names are not added to this scope, but are stored for later reference. |
| 11013 * | 11142 * |
| 11014 * @param definingLibrary the element representing the library that imports th
e libraries for | 11143 * @param definingLibrary the element representing the library that imports th
e libraries for |
| 11015 * which namespaces will be created | 11144 * which namespaces will be created |
| 11016 */ | 11145 */ |
| 11017 void createImportedNamespaces(LibraryElement definingLibrary) { | 11146 void createImportedNamespaces(LibraryElement definingLibrary) { |
| 11018 NamespaceBuilder builder = new NamespaceBuilder(); | 11147 NamespaceBuilder builder = new NamespaceBuilder(); |
| 11019 for (ImportElement element in definingLibrary.imports) { | 11148 for (ImportElement element in definingLibrary.imports) { |
| 11020 _importedNamespaces.add(builder.createImportNamespace(element)); | 11149 _importedNamespaces.add(builder.createImportNamespace(element)); |
| 11021 } | 11150 } |
| 11022 } | 11151 } |
| 11023 | 11152 |
| 11024 /** | 11153 /** |
| 11154 * Return the source that contains the given identifier, or the source associa
ted with this scope |
| 11155 * if the source containing the identifier could not be determined. |
| 11156 * |
| 11157 * @param identifier the identifier whose source is to be returned |
| 11158 * @return the source that contains the given identifier |
| 11159 */ |
| 11160 Source getSource2(Identifier identifier) { |
| 11161 CompilationUnit unit = identifier.getAncestor(CompilationUnit); |
| 11162 if (unit != null) { |
| 11163 CompilationUnitElement element = unit.element; |
| 11164 if (element != null) { |
| 11165 Source source = element.source; |
| 11166 if (source != null) { |
| 11167 return source; |
| 11168 } |
| 11169 } |
| 11170 } |
| 11171 return this.source; |
| 11172 } |
| 11173 |
| 11174 /** |
| 11025 * Given a collection of elements that a single name could all be mapped to, r
emove from the list | 11175 * Given a collection of elements that a single name could all be mapped to, r
emove from the list |
| 11026 * all of the names defined in the SDK. Return the element(s) that remain. | 11176 * all of the names defined in the SDK. Return the element(s) that remain. |
| 11027 * | 11177 * |
| 11028 * @param foundElement the element encapsulating the collection of elements | 11178 * @param foundElement the element encapsulating the collection of elements |
| 11029 * @return all of the elements that are not defined in the SDK | 11179 * @return all of the elements that are not defined in the SDK |
| 11030 */ | 11180 */ |
| 11031 Element removeSdkElements(MultiplyDefinedElementImpl foundElement) { | 11181 Element removeSdkElements(MultiplyDefinedElementImpl foundElement) { |
| 11032 List<Element> conflictingMembers = foundElement.conflictingElements; | 11182 List<Element> conflictingMembers = foundElement.conflictingElements; |
| 11033 int length = conflictingMembers.length; | 11183 int length = conflictingMembers.length; |
| 11034 int to = 0; | 11184 int to = 0; |
| (...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12546 try { | 12696 try { |
| 12547 if (initializerNode != null) { | 12697 if (initializerNode != null) { |
| 12548 initializerNode.accept(this); | 12698 initializerNode.accept(this); |
| 12549 } | 12699 } |
| 12550 } finally { | 12700 } finally { |
| 12551 _isInInstanceVariableInitializer = false; | 12701 _isInInstanceVariableInitializer = false; |
| 12552 _namesForReferenceToDeclaredVariableInInitializer.remove(name); | 12702 _namesForReferenceToDeclaredVariableInInitializer.remove(name); |
| 12553 } | 12703 } |
| 12554 return null; | 12704 return null; |
| 12555 } | 12705 } |
| 12556 Object visitVariableDeclarationList(VariableDeclarationList node) { | 12706 Object visitVariableDeclarationList(VariableDeclarationList node) => super.vis
itVariableDeclarationList(node); |
| 12557 checkForBuiltInIdentifierAsName2(node); | |
| 12558 return super.visitVariableDeclarationList(node); | |
| 12559 } | |
| 12560 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { | 12707 Object visitVariableDeclarationStatement(VariableDeclarationStatement node) { |
| 12561 checkForFinalNotInitialized2(node.variables); | 12708 checkForFinalNotInitialized2(node.variables); |
| 12562 return super.visitVariableDeclarationStatement(node); | 12709 return super.visitVariableDeclarationStatement(node); |
| 12563 } | 12710 } |
| 12564 Object visitWhileStatement(WhileStatement node) { | 12711 Object visitWhileStatement(WhileStatement node) { |
| 12565 checkForNonBoolCondition(node.condition); | 12712 checkForNonBoolCondition(node.condition); |
| 12566 return super.visitWhileStatement(node); | 12713 return super.visitWhileStatement(node); |
| 12567 } | 12714 } |
| 12568 | 12715 |
| 12569 /** | 12716 /** |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12667 * @see StaticWarningCode#INVALID_GETTER_OVERRIDE_RETURN_TYPE | 12814 * @see StaticWarningCode#INVALID_GETTER_OVERRIDE_RETURN_TYPE |
| 12668 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_RETURN_TYPE | 12815 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_RETURN_TYPE |
| 12669 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE | 12816 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NORMAL_PARAM_TYPE |
| 12670 * @see StaticWarningCode#INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE | 12817 * @see StaticWarningCode#INVALID_SETTER_OVERRIDE_NORMAL_PARAM_TYPE |
| 12671 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE | 12818 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_OPTIONAL_PARAM_TYPE |
| 12672 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE | 12819 * @see StaticWarningCode#INVALID_METHOD_OVERRIDE_NAMED_PARAM_TYPE |
| 12673 * @see StaticWarningCode#INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES | 12820 * @see StaticWarningCode#INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES |
| 12674 */ | 12821 */ |
| 12675 bool checkForAllInvalidOverrideErrorCodes(ExecutableElement executableElement,
List<ParameterElement> parameters, List<ASTNode> parameterLocations, SimpleIden
tifier errorNameTarget) { | 12822 bool checkForAllInvalidOverrideErrorCodes(ExecutableElement executableElement,
List<ParameterElement> parameters, List<ASTNode> parameterLocations, SimpleIden
tifier errorNameTarget) { |
| 12676 String executableElementName = executableElement.name; | 12823 String executableElementName = executableElement.name; |
| 12824 bool executableElementPrivate = Identifier.isPrivateName(executableElementNa
me); |
| 12677 ExecutableElement overriddenExecutable = _inheritanceManager.lookupInheritan
ce(_enclosingClass, executableElementName); | 12825 ExecutableElement overriddenExecutable = _inheritanceManager.lookupInheritan
ce(_enclosingClass, executableElementName); |
| 12678 bool isGetter = false; | 12826 bool isGetter = false; |
| 12679 bool isSetter = false; | 12827 bool isSetter = false; |
| 12680 if (executableElement is PropertyAccessorElement) { | 12828 if (executableElement is PropertyAccessorElement) { |
| 12681 PropertyAccessorElement accessorElement = executableElement as PropertyAcc
essorElement; | 12829 PropertyAccessorElement accessorElement = executableElement as PropertyAcc
essorElement; |
| 12682 isGetter = accessorElement.isGetter; | 12830 isGetter = accessorElement.isGetter; |
| 12683 isSetter = accessorElement.isSetter; | 12831 isSetter = accessorElement.isSetter; |
| 12684 } | 12832 } |
| 12685 if (overriddenExecutable == null) { | 12833 if (overriddenExecutable == null) { |
| 12686 if (!isGetter && !isSetter && !executableElement.isOperator) { | 12834 if (!isGetter && !isSetter && !executableElement.isOperator) { |
| 12687 Set<ClassElement> visitedClasses = new Set<ClassElement>(); | 12835 Set<ClassElement> visitedClasses = new Set<ClassElement>(); |
| 12688 InterfaceType superclassType = _enclosingClass.supertype; | 12836 InterfaceType superclassType = _enclosingClass.supertype; |
| 12689 ClassElement superclassElement = superclassType == null ? null : supercl
assType.element; | 12837 ClassElement superclassElement = superclassType == null ? null : supercl
assType.element; |
| 12690 while (superclassElement != null && !visitedClasses.contains(superclassE
lement)) { | 12838 while (superclassElement != null && !visitedClasses.contains(superclassE
lement)) { |
| 12691 javaSetAdd(visitedClasses, superclassElement); | 12839 javaSetAdd(visitedClasses, superclassElement); |
| 12840 LibraryElement superclassLibrary = superclassElement.library; |
| 12692 List<FieldElement> fieldElts = superclassElement.fields; | 12841 List<FieldElement> fieldElts = superclassElement.fields; |
| 12693 for (FieldElement fieldElt in fieldElts) { | 12842 for (FieldElement fieldElt in fieldElts) { |
| 12694 if (fieldElt.name == executableElementName && fieldElt.isStatic) { | 12843 if (fieldElt.name != executableElementName) { |
| 12844 continue; |
| 12845 } |
| 12846 if (executableElementPrivate && _currentLibrary != superclassLibrary
) { |
| 12847 continue; |
| 12848 } |
| 12849 if (fieldElt.isStatic) { |
| 12695 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME
_COLLIDES_WITH_SUPERCLASS_STATIC, errorNameTarget, [ | 12850 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME
_COLLIDES_WITH_SUPERCLASS_STATIC, errorNameTarget, [ |
| 12696 executableElementName, | 12851 executableElementName, |
| 12697 fieldElt.enclosingElement.displayName]); | 12852 fieldElt.enclosingElement.displayName]); |
| 12698 return true; | 12853 return true; |
| 12699 } | 12854 } |
| 12700 } | 12855 } |
| 12701 List<MethodElement> methodElements = superclassElement.methods; | 12856 List<MethodElement> methodElements = superclassElement.methods; |
| 12702 for (MethodElement methodElement in methodElements) { | 12857 for (MethodElement methodElement in methodElements) { |
| 12703 if (methodElement.name == executableElementName && methodElement.isS
tatic) { | 12858 if (methodElement.name != executableElementName) { |
| 12859 continue; |
| 12860 } |
| 12861 if (executableElementPrivate && _currentLibrary != superclassLibrary
) { |
| 12862 continue; |
| 12863 } |
| 12864 if (methodElement.isStatic) { |
| 12704 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME
_COLLIDES_WITH_SUPERCLASS_STATIC, errorNameTarget, [ | 12865 _errorReporter.reportError2(StaticWarningCode.INSTANCE_METHOD_NAME
_COLLIDES_WITH_SUPERCLASS_STATIC, errorNameTarget, [ |
| 12705 executableElementName, | 12866 executableElementName, |
| 12706 methodElement.enclosingElement.displayName]); | 12867 methodElement.enclosingElement.displayName]); |
| 12707 return true; | 12868 return true; |
| 12708 } | 12869 } |
| 12709 } | 12870 } |
| 12710 superclassType = superclassElement.supertype; | 12871 superclassType = superclassElement.supertype; |
| 12711 superclassElement = superclassType == null ? null : superclassType.ele
ment; | 12872 superclassElement = superclassType == null ? null : superclassType.ele
ment; |
| 12712 } | 12873 } |
| 12713 } | 12874 } |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13118 } | 13279 } |
| 13119 return problemReported; | 13280 return problemReported; |
| 13120 } | 13281 } |
| 13121 | 13282 |
| 13122 /** | 13283 /** |
| 13123 * This verifies that the passed argument can be assigned to its corresponding
parameter. | 13284 * This verifies that the passed argument can be assigned to its corresponding
parameter. |
| 13124 * | 13285 * |
| 13125 * @param argument the argument to evaluate | 13286 * @param argument the argument to evaluate |
| 13126 * @return `true` if and only if an error code is generated on the passed node | 13287 * @return `true` if and only if an error code is generated on the passed node |
| 13127 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 13288 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 13128 * @see CompileTimeErrorCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | |
| 13129 */ | 13289 */ |
| 13130 bool checkForArgumentTypeNotAssignable2(Expression argument) { | 13290 bool checkForArgumentTypeNotAssignable2(Expression argument) { |
| 13131 if (argument == null) { | 13291 if (argument == null) { |
| 13132 return false; | 13292 return false; |
| 13133 } | 13293 } |
| 13134 ErrorCode errorCode; | |
| 13135 if (_isInConstInstanceCreation || _isEnclosingConstructorConst) { | |
| 13136 errorCode = CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE; | |
| 13137 } else { | |
| 13138 errorCode = StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE; | |
| 13139 } | |
| 13140 ParameterElement staticParameterElement = argument.staticParameterElement; | 13294 ParameterElement staticParameterElement = argument.staticParameterElement; |
| 13141 Type2 staticParameterType = staticParameterElement == null ? null : staticPa
rameterElement.type; | 13295 Type2 staticParameterType = staticParameterElement == null ? null : staticPa
rameterElement.type; |
| 13142 ParameterElement propagatedParameterElement = argument.propagatedParameterEl
ement; | 13296 ParameterElement propagatedParameterElement = argument.propagatedParameterEl
ement; |
| 13143 Type2 propagatedParameterType = propagatedParameterElement == null ? null :
propagatedParameterElement.type; | 13297 Type2 propagatedParameterType = propagatedParameterElement == null ? null :
propagatedParameterElement.type; |
| 13144 return checkForArgumentTypeNotAssignable3(argument, staticParameterType, pro
pagatedParameterType, errorCode); | 13298 return checkForArgumentTypeNotAssignable3(argument, staticParameterType, pro
pagatedParameterType, StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE); |
| 13145 } | 13299 } |
| 13146 | 13300 |
| 13147 /** | 13301 /** |
| 13148 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. | 13302 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. |
| 13149 * | 13303 * |
| 13150 * @param expression the expression to evaluate | 13304 * @param expression the expression to evaluate |
| 13151 * @param expectedStaticType the expected static type | 13305 * @param expectedStaticType the expected static type |
| 13152 * @param expectedPropagatedType the expected propagated type, may be `null` | 13306 * @param expectedPropagatedType the expected propagated type, may be `null` |
| 13153 * @return `true` if and only if an error code is generated on the passed node | 13307 * @return `true` if and only if an error code is generated on the passed node |
| 13154 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 13308 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 13155 * @see CompileTimeErrorCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | |
| 13156 */ | 13309 */ |
| 13157 bool checkForArgumentTypeNotAssignable3(Expression expression, Type2 expectedS
taticType, Type2 expectedPropagatedType, ErrorCode errorCode) => checkForArgumen
tTypeNotAssignable4(expression, expectedStaticType, getStaticType(expression), e
xpectedPropagatedType, expression.propagatedType, errorCode); | 13310 bool checkForArgumentTypeNotAssignable3(Expression expression, Type2 expectedS
taticType, Type2 expectedPropagatedType, ErrorCode errorCode) => checkForArgumen
tTypeNotAssignable4(expression, expectedStaticType, getStaticType(expression), e
xpectedPropagatedType, expression.propagatedType, errorCode); |
| 13158 | 13311 |
| 13159 /** | 13312 /** |
| 13160 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. | 13313 * This verifies that the passed expression can be assigned to its correspondi
ng parameters. |
| 13161 * | 13314 * |
| 13162 * @param expression the expression to evaluate | 13315 * @param expression the expression to evaluate |
| 13163 * @param expectedStaticType the expected static type of the parameter | 13316 * @param expectedStaticType the expected static type of the parameter |
| 13164 * @param actualStaticType the actual static type of the argument | 13317 * @param actualStaticType the actual static type of the argument |
| 13165 * @param expectedPropagatedType the expected propagated type of the parameter
, may be | 13318 * @param expectedPropagatedType the expected propagated type of the parameter
, may be |
| 13166 * `null` | 13319 * `null` |
| 13167 * @param actualPropagatedType the expected propagated type of the parameter,
may be `null` | 13320 * @param actualPropagatedType the expected propagated type of the parameter,
may be `null` |
| 13168 * @return `true` if and only if an error code is generated on the passed node | 13321 * @return `true` if and only if an error code is generated on the passed node |
| 13169 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 13322 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 13170 * @see CompileTimeErrorCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | |
| 13171 */ | 13323 */ |
| 13172 bool checkForArgumentTypeNotAssignable4(Expression expression, Type2 expectedS
taticType, Type2 actualStaticType, Type2 expectedPropagatedType, Type2 actualPro
pagatedType, ErrorCode errorCode) { | 13324 bool checkForArgumentTypeNotAssignable4(Expression expression, Type2 expectedS
taticType, Type2 actualStaticType, Type2 expectedPropagatedType, Type2 actualPro
pagatedType, ErrorCode errorCode) { |
| 13173 if (actualStaticType == null || expectedStaticType == null) { | 13325 if (actualStaticType == null || expectedStaticType == null) { |
| 13174 return false; | 13326 return false; |
| 13175 } | 13327 } |
| 13176 if (_strictMode) { | 13328 if (_strictMode) { |
| 13177 if (actualStaticType.isAssignableTo(expectedStaticType)) { | 13329 if (actualStaticType.isAssignableTo(expectedStaticType)) { |
| 13178 return false; | 13330 return false; |
| 13179 } | 13331 } |
| 13180 _errorReporter.reportError2(errorCode, expression, [ | 13332 _errorReporter.reportError2(errorCode, expression, [ |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13270 bool checkForBuiltInIdentifierAsName(SimpleIdentifier identifier, ErrorCode er
rorCode) { | 13422 bool checkForBuiltInIdentifierAsName(SimpleIdentifier identifier, ErrorCode er
rorCode) { |
| 13271 sc.Token token = identifier.token; | 13423 sc.Token token = identifier.token; |
| 13272 if (identical(token.type, sc.TokenType.KEYWORD)) { | 13424 if (identical(token.type, sc.TokenType.KEYWORD)) { |
| 13273 _errorReporter.reportError2(errorCode, identifier, [identifier.name]); | 13425 _errorReporter.reportError2(errorCode, identifier, [identifier.name]); |
| 13274 return true; | 13426 return true; |
| 13275 } | 13427 } |
| 13276 return false; | 13428 return false; |
| 13277 } | 13429 } |
| 13278 | 13430 |
| 13279 /** | 13431 /** |
| 13280 * This verifies that the passed variable declaration list does not have a bui
lt-in identifier. | |
| 13281 * | |
| 13282 * @param node the variable declaration list to check | |
| 13283 * @return `true` if and only if an error code is generated on the passed node | |
| 13284 * @see CompileTimeErrorCode#BUILT_IN_IDENTIFIER_AS_TYPE | |
| 13285 */ | |
| 13286 bool checkForBuiltInIdentifierAsName2(VariableDeclarationList node) { | |
| 13287 TypeName typeName = node.type; | |
| 13288 if (typeName != null) { | |
| 13289 Identifier identifier = typeName.name; | |
| 13290 if (identifier is SimpleIdentifier) { | |
| 13291 SimpleIdentifier simpleIdentifier = identifier as SimpleIdentifier; | |
| 13292 sc.Token token = simpleIdentifier.token; | |
| 13293 if (identical(token.type, sc.TokenType.KEYWORD)) { | |
| 13294 if (((token as sc.KeywordToken)).keyword != sc.Keyword.DYNAMIC) { | |
| 13295 _errorReporter.reportError2(CompileTimeErrorCode.BUILT_IN_IDENTIFIER
_AS_TYPE, identifier, [identifier.name]); | |
| 13296 return true; | |
| 13297 } | |
| 13298 } | |
| 13299 } | |
| 13300 } | |
| 13301 return false; | |
| 13302 } | |
| 13303 | |
| 13304 /** | |
| 13305 * This verifies that the given switch case is terminated with 'break', 'conti
nue', 'return' or | 13432 * This verifies that the given switch case is terminated with 'break', 'conti
nue', 'return' or |
| 13306 * 'throw'. | 13433 * 'throw'. |
| 13307 * | 13434 * |
| 13308 * @param node the switch case to evaluate | 13435 * @param node the switch case to evaluate |
| 13309 * @return `true` if and only if an error code is generated on the passed node | 13436 * @return `true` if and only if an error code is generated on the passed node |
| 13310 * @see StaticWarningCode#CASE_BLOCK_NOT_TERMINATED | 13437 * @see StaticWarningCode#CASE_BLOCK_NOT_TERMINATED |
| 13311 */ | 13438 */ |
| 13312 bool checkForCaseBlockNotTerminated(SwitchCase node) { | 13439 bool checkForCaseBlockNotTerminated(SwitchCase node) { |
| 13313 NodeList<Statement> statements = node.statements; | 13440 NodeList<Statement> statements = node.statements; |
| 13314 if (statements.isEmpty) { | 13441 if (statements.isEmpty) { |
| (...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14401 } | 14528 } |
| 14402 | 14529 |
| 14403 /** | 14530 /** |
| 14404 * This verifies that an 'int' can be assigned to the parameter corresponding
to the given | 14531 * This verifies that an 'int' can be assigned to the parameter corresponding
to the given |
| 14405 * expression. This is used for prefix and postfix expressions where the argum
ent value is | 14532 * expression. This is used for prefix and postfix expressions where the argum
ent value is |
| 14406 * implicit. | 14533 * implicit. |
| 14407 * | 14534 * |
| 14408 * @param argument the expression to which the operator is being applied | 14535 * @param argument the expression to which the operator is being applied |
| 14409 * @return `true` if and only if an error code is generated on the passed node | 14536 * @return `true` if and only if an error code is generated on the passed node |
| 14410 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | 14537 * @see StaticWarningCode#ARGUMENT_TYPE_NOT_ASSIGNABLE |
| 14411 * @see CompileTimeErrorCode#ARGUMENT_TYPE_NOT_ASSIGNABLE | |
| 14412 */ | 14538 */ |
| 14413 bool checkForIntNotAssignable(Expression argument) { | 14539 bool checkForIntNotAssignable(Expression argument) { |
| 14414 if (argument == null) { | 14540 if (argument == null) { |
| 14415 return false; | 14541 return false; |
| 14416 } | 14542 } |
| 14417 ErrorCode errorCode; | |
| 14418 if (_isInConstInstanceCreation || _isEnclosingConstructorConst) { | |
| 14419 errorCode = CompileTimeErrorCode.ARGUMENT_TYPE_NOT_ASSIGNABLE; | |
| 14420 } else { | |
| 14421 errorCode = StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE; | |
| 14422 } | |
| 14423 ParameterElement staticParameterElement = argument.staticParameterElement; | 14543 ParameterElement staticParameterElement = argument.staticParameterElement; |
| 14424 Type2 staticParameterType = staticParameterElement == null ? null : staticPa
rameterElement.type; | 14544 Type2 staticParameterType = staticParameterElement == null ? null : staticPa
rameterElement.type; |
| 14425 ParameterElement propagatedParameterElement = argument.propagatedParameterEl
ement; | 14545 ParameterElement propagatedParameterElement = argument.propagatedParameterEl
ement; |
| 14426 Type2 propagatedParameterType = propagatedParameterElement == null ? null :
propagatedParameterElement.type; | 14546 Type2 propagatedParameterType = propagatedParameterElement == null ? null :
propagatedParameterElement.type; |
| 14427 return checkForArgumentTypeNotAssignable4(argument, staticParameterType, _ty
peProvider.intType, propagatedParameterType, _typeProvider.intType, errorCode); | 14547 return checkForArgumentTypeNotAssignable4(argument, staticParameterType, _ty
peProvider.intType, propagatedParameterType, _typeProvider.intType, StaticWarnin
gCode.ARGUMENT_TYPE_NOT_ASSIGNABLE); |
| 14428 } | 14548 } |
| 14429 | 14549 |
| 14430 /** | 14550 /** |
| 14431 * Given an assignment using a compound assignment operator, this verifies tha
t the given | 14551 * Given an assignment using a compound assignment operator, this verifies tha
t the given |
| 14432 * assignment is valid. | 14552 * assignment is valid. |
| 14433 * | 14553 * |
| 14434 * @param node the assignment expression being tested | 14554 * @param node the assignment expression being tested |
| 14435 * @return `true` if and only if an error code is generated on the passed node | 14555 * @return `true` if and only if an error code is generated on the passed node |
| 14436 * @see StaticTypeWarningCode#INVALID_ASSIGNMENT | 14556 * @see StaticTypeWarningCode#INVALID_ASSIGNMENT |
| 14437 */ | 14557 */ |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14842 for (MethodElement method in methods) { | 14962 for (MethodElement method in methods) { |
| 14843 javaSetAdd(methodsInEnclosingClass, method.name); | 14963 javaSetAdd(methodsInEnclosingClass, method.name); |
| 14844 } | 14964 } |
| 14845 for (PropertyAccessorElement accessor in accessors) { | 14965 for (PropertyAccessorElement accessor in accessors) { |
| 14846 javaSetAdd(accessorsInEnclosingClass, accessor.name); | 14966 javaSetAdd(accessorsInEnclosingClass, accessor.name); |
| 14847 } | 14967 } |
| 14848 if (methodsInEnclosingClass.contains(ElementResolver.NO_SUCH_METHOD_METHOD_N
AME)) { | 14968 if (methodsInEnclosingClass.contains(ElementResolver.NO_SUCH_METHOD_METHOD_N
AME)) { |
| 14849 return false; | 14969 return false; |
| 14850 } | 14970 } |
| 14851 Set<ExecutableElement> missingOverrides = new Set<ExecutableElement>(); | 14971 Set<ExecutableElement> missingOverrides = new Set<ExecutableElement>(); |
| 14852 Map<String, ExecutableElement> membersInheritedFromInterfaces = _inheritance
Manager.getMapOfMembersInheritedFromInterfaces(_enclosingClass); | 14972 MemberMap membersInheritedFromInterfaces = _inheritanceManager.getMapOfMembe
rsInheritedFromInterfaces(_enclosingClass); |
| 14853 Map<String, ExecutableElement> membersInheritedFromSuperclasses = _inheritan
ceManager.getMapOfMembersInheritedFromClasses(_enclosingClass); | 14973 MemberMap membersInheritedFromSuperclasses = _inheritanceManager.getMapOfMem
bersInheritedFromClasses(_enclosingClass); |
| 14854 for (MapEntry<String, ExecutableElement> entry in getMapEntrySet(membersInhe
ritedFromInterfaces)) { | 14974 for (int i = 0; i < membersInheritedFromInterfaces.size; i++) { |
| 14855 ExecutableElement executableElt = entry.getValue(); | 14975 String memberName = membersInheritedFromInterfaces.getKey(i); |
| 14856 ExecutableElement elt = membersInheritedFromSuperclasses[executableElt.nam
e]; | 14976 ExecutableElement executableElt = membersInheritedFromInterfaces.getValue(
i); |
| 14977 if (memberName == null) { |
| 14978 break; |
| 14979 } |
| 14980 ExecutableElement elt = membersInheritedFromSuperclasses.get(executableElt
.name); |
| 14857 if (elt != null) { | 14981 if (elt != null) { |
| 14858 if (elt is MethodElement && !((elt as MethodElement)).isAbstract) { | 14982 if (elt is MethodElement && !((elt as MethodElement)).isAbstract) { |
| 14859 continue; | 14983 continue; |
| 14860 } else if (elt is PropertyAccessorElement && !((elt as PropertyAccessorE
lement)).isAbstract) { | 14984 } else if (elt is PropertyAccessorElement && !((elt as PropertyAccessorE
lement)).isAbstract) { |
| 14861 continue; | 14985 continue; |
| 14862 } | 14986 } |
| 14863 } | 14987 } |
| 14864 if (executableElt is MethodElement) { | 14988 if (executableElt is MethodElement) { |
| 14865 String methodName = entry.getKey(); | 14989 if (!methodsInEnclosingClass.contains(memberName) && !memberHasConcreteM
ethodImplementationInSuperclassChain(_enclosingClass, memberName, new List<Class
Element>())) { |
| 14866 if (!methodsInEnclosingClass.contains(methodName) && !memberHasConcreteM
ethodImplementationInSuperclassChain(_enclosingClass, methodName, new List<Class
Element>())) { | |
| 14867 javaSetAdd(missingOverrides, executableElt); | 14990 javaSetAdd(missingOverrides, executableElt); |
| 14868 } | 14991 } |
| 14869 } else if (executableElt is PropertyAccessorElement) { | 14992 } else if (executableElt is PropertyAccessorElement) { |
| 14870 String accessorName = entry.getKey(); | 14993 if (!accessorsInEnclosingClass.contains(memberName) && !memberHasConcret
eAccessorImplementationInSuperclassChain(_enclosingClass, memberName, new List<C
lassElement>())) { |
| 14871 if (!accessorsInEnclosingClass.contains(accessorName) && !memberHasConcr
eteAccessorImplementationInSuperclassChain(_enclosingClass, accessorName, new Li
st<ClassElement>())) { | |
| 14872 javaSetAdd(missingOverrides, executableElt); | 14994 javaSetAdd(missingOverrides, executableElt); |
| 14873 } | 14995 } |
| 14874 } | 14996 } |
| 14875 } | 14997 } |
| 14876 int missingOverridesSize = missingOverrides.length; | 14998 int missingOverridesSize = missingOverrides.length; |
| 14877 if (missingOverridesSize == 0) { | 14999 if (missingOverridesSize == 0) { |
| 14878 return false; | 15000 return false; |
| 14879 } | 15001 } |
| 14880 List<ExecutableElement> missingOverridesArray = new List.from(missingOverrid
es); | 15002 List<ExecutableElement> missingOverridesArray = new List.from(missingOverrid
es); |
| 14881 List<String> stringMembersArrayListSet = new List<String>(); | 15003 List<String> stringMembersArrayListSet = new List<String>(); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15342 * and [visitExpressionFunctionBody]. | 15464 * and [visitExpressionFunctionBody]. |
| 15343 * | 15465 * |
| 15344 * @param returnExpression the returned expression to evaluate | 15466 * @param returnExpression the returned expression to evaluate |
| 15345 * @param expectedReturnType the expressed return type by the enclosing method
or function | 15467 * @param expectedReturnType the expressed return type by the enclosing method
or function |
| 15346 * @return `true` if and only if an error code is generated on the passed node | 15468 * @return `true` if and only if an error code is generated on the passed node |
| 15347 * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE | 15469 * @see StaticTypeWarningCode#RETURN_OF_INVALID_TYPE |
| 15348 */ | 15470 */ |
| 15349 bool checkForReturnOfInvalidType(Expression returnExpression, Type2 expectedRe
turnType) { | 15471 bool checkForReturnOfInvalidType(Expression returnExpression, Type2 expectedRe
turnType) { |
| 15350 Type2 staticReturnType = getStaticType(returnExpression); | 15472 Type2 staticReturnType = getStaticType(returnExpression); |
| 15351 if (expectedReturnType.isVoid) { | 15473 if (expectedReturnType.isVoid) { |
| 15352 if (staticReturnType.isVoid || staticReturnType.isDynamic || identical(sta
ticReturnType, BottomTypeImpl.instance)) { | 15474 if (staticReturnType.isVoid || staticReturnType.isDynamic || staticReturnT
ype.isBottom) { |
| 15353 return false; | 15475 return false; |
| 15354 } | 15476 } |
| 15355 _errorReporter.reportError2(StaticTypeWarningCode.RETURN_OF_INVALID_TYPE,
returnExpression, [ | 15477 _errorReporter.reportError2(StaticTypeWarningCode.RETURN_OF_INVALID_TYPE,
returnExpression, [ |
| 15356 staticReturnType.displayName, | 15478 staticReturnType.displayName, |
| 15357 expectedReturnType.displayName, | 15479 expectedReturnType.displayName, |
| 15358 _enclosingFunction.displayName]); | 15480 _enclosingFunction.displayName]); |
| 15359 return true; | 15481 return true; |
| 15360 } | 15482 } |
| 15361 bool isStaticAssignable = staticReturnType.isAssignableTo(expectedReturnType
); | 15483 bool isStaticAssignable = staticReturnType.isAssignableTo(expectedReturnType
); |
| 15362 Type2 propagatedReturnType = returnExpression.propagatedType; | 15484 Type2 propagatedReturnType = returnExpression.propagatedType; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15807 } | 15929 } |
| 15808 if (current != null && !checked.contains(current)) { | 15930 if (current != null && !checked.contains(current)) { |
| 15809 break; | 15931 break; |
| 15810 } | 15932 } |
| 15811 } | 15933 } |
| 15812 current.accept(new GeneralizingElementVisitor_12(target, toCheck)); | 15934 current.accept(new GeneralizingElementVisitor_12(target, toCheck)); |
| 15813 javaSetAdd(checked, current); | 15935 javaSetAdd(checked, current); |
| 15814 } | 15936 } |
| 15815 } | 15937 } |
| 15816 bool isFunctionType(Type2 type) { | 15938 bool isFunctionType(Type2 type) { |
| 15817 if (type.isDynamic || identical(type, BottomTypeImpl.instance)) { | 15939 if (type.isDynamic || type.isBottom) { |
| 15940 return true; |
| 15941 } else if (type is FunctionType || type.isDartCoreFunction) { |
| 15818 return true; | 15942 return true; |
| 15819 } else if (type is InterfaceType) { | 15943 } else if (type is InterfaceType) { |
| 15820 if (identical(type, _typeProvider.functionType)) { | |
| 15821 return true; | |
| 15822 } | |
| 15823 MethodElement callMethod = ((type as InterfaceType)).lookUpMethod(ElementR
esolver.CALL_METHOD_NAME, _currentLibrary); | 15944 MethodElement callMethod = ((type as InterfaceType)).lookUpMethod(ElementR
esolver.CALL_METHOD_NAME, _currentLibrary); |
| 15824 return callMethod != null; | 15945 return callMethod != null; |
| 15825 } else if (type is FunctionType || type.isDartCoreFunction) { | |
| 15826 return true; | |
| 15827 } | 15946 } |
| 15828 return false; | 15947 return false; |
| 15829 } | 15948 } |
| 15830 | 15949 |
| 15831 /** | 15950 /** |
| 15832 * @return `true` if the given [ASTNode] is the part of constant constructor | 15951 * @return `true` if the given [ASTNode] is the part of constant constructor |
| 15833 * invocation. | 15952 * invocation. |
| 15834 */ | 15953 */ |
| 15835 bool isInConstConstructorInvocation(ASTNode node) { | 15954 bool isInConstConstructorInvocation(ASTNode node) { |
| 15836 InstanceCreationExpression creation = node.getAncestor(InstanceCreationExpre
ssion); | 15955 InstanceCreationExpression creation = node.getAncestor(InstanceCreationExpre
ssion); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16096 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag
e, String correction) : super(name, ordinal) { | 16215 ResolverErrorCode.con2(String name, int ordinal, ErrorType type, String messag
e, String correction) : super(name, ordinal) { |
| 16097 this._type = type; | 16216 this._type = type; |
| 16098 this._message = message; | 16217 this._message = message; |
| 16099 this.correction9 = correction; | 16218 this.correction9 = correction; |
| 16100 } | 16219 } |
| 16101 String get correction => correction9; | 16220 String get correction => correction9; |
| 16102 ErrorSeverity get errorSeverity => _type.severity; | 16221 ErrorSeverity get errorSeverity => _type.severity; |
| 16103 String get message => _message; | 16222 String get message => _message; |
| 16104 ErrorType get type => _type; | 16223 ErrorType get type => _type; |
| 16105 } | 16224 } |
| OLD | NEW |