Chromium Code Reviews| Index: pkg/analyzer/lib/src/generated/resolver.dart |
| diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart |
| index 2d5fac3269d04c5bcd01af8a8d70c3c9d7b6a13e..dd433626580fa41af6216cb52d57012ab4c49895 100644 |
| --- a/pkg/analyzer/lib/src/generated/resolver.dart |
| +++ b/pkg/analyzer/lib/src/generated/resolver.dart |
| @@ -5852,28 +5852,6 @@ class InheritanceManager { |
| } |
| /** |
| - * Given some [InterfaceType] and some member name, this returns the |
| - * [FunctionType] of the [ExecutableElement] that the |
| - * class either declares itself, or inherits, that has the member name, if no member is inherited |
| - * `null` is returned. The returned [FunctionType] has all type |
| - * parameters substituted with corresponding type arguments from the given [InterfaceType]. |
| - * |
| - * @param interfaceType the interface type to query |
| - * @param memberName the name of the executable element to find and return |
| - * @return the member's function type, or `null` if no such member exists |
| - */ |
| - FunctionType lookupMemberType( |
| - InterfaceType interfaceType, String memberName) { |
| - ExecutableElement iteratorMember = |
| - lookupMember(interfaceType.element, memberName); |
| - if (iteratorMember == null) { |
| - return null; |
| - } |
| - return substituteTypeArgumentsInMemberFromInheritance( |
| - iteratorMember.type, memberName, interfaceType); |
| - } |
| - |
| - /** |
| * Determine the set of methods which is overridden by the given class member. If no member is |
| * inherited, an empty list is returned. If one of the inherited members is a |
| * [MultiplyInheritedExecutableElement], then it is expanded into its constituent inherited |
| @@ -5912,45 +5890,6 @@ class InheritanceManager { |
| } |
| /** |
| - * This method takes some inherited [FunctionType], and resolves all the parameterized types |
| - * in the function type, dependent on the class in which it is being overridden. |
| - * |
| - * @param baseFunctionType the function type that is being overridden |
| - * @param memberName the name of the member, this is used to lookup the inheritance path of the |
| - * override |
| - * @param definingType the type that is overriding the member |
| - * @return the passed function type with any parameterized types substituted |
| - */ |
| - FunctionType substituteTypeArgumentsInMemberFromInheritance( |
| - FunctionType baseFunctionType, |
| - String memberName, |
| - InterfaceType definingType) { |
| - // if the baseFunctionType is null, or does not have any parameters, |
| - // return it. |
| - if (baseFunctionType == null || |
| - baseFunctionType.typeArguments.length == 0) { |
| - return baseFunctionType; |
| - } |
| - // First, generate the path from the defining type to the overridden member |
| - Queue<InterfaceType> inheritancePath = new Queue<InterfaceType>(); |
| - _computeInheritancePath(inheritancePath, definingType, memberName); |
| - if (inheritancePath == null || inheritancePath.isEmpty) { |
| - // TODO(jwren) log analysis engine error |
| - return baseFunctionType; |
| - } |
| - FunctionType functionTypeToReturn = baseFunctionType; |
| - // loop backward through the list substituting as we go: |
| - while (!inheritancePath.isEmpty) { |
| - InterfaceType lastType = inheritancePath.removeLast(); |
| - List<DartType> parameterTypes = lastType.element.type.typeArguments; |
| - List<DartType> argumentTypes = lastType.typeArguments; |
| - functionTypeToReturn = |
| - functionTypeToReturn.substitute2(argumentTypes, parameterTypes); |
| - } |
| - return functionTypeToReturn; |
| - } |
| - |
| - /** |
| * Compute and return a mapping between the set of all string names of the members inherited from |
| * the passed [ClassElement] superclass hierarchy, and the associated |
| * [ExecutableElement]. |
| @@ -11592,8 +11531,8 @@ class ResolverVisitor extends ScopedVisitor { |
| DartType expressionType = iteratorExpression.bestType; |
| if (expressionType is InterfaceType) { |
| InterfaceType interfaceType = expressionType; |
| - FunctionType iteratorFunction = |
| - _inheritanceManager.lookupMemberType(interfaceType, "iterator"); |
| + PropertyAccessorElement iteratorFunction = |
| + interfaceType.lookUpInheritedGetter("iterator"); |
| if (iteratorFunction == null) { |
| // TODO(brianwilkerson) Should we report this error? |
| return null; |
| @@ -11601,8 +11540,8 @@ class ResolverVisitor extends ScopedVisitor { |
| DartType iteratorType = iteratorFunction.returnType; |
| if (iteratorType is InterfaceType) { |
| InterfaceType iteratorInterfaceType = iteratorType; |
| - FunctionType currentFunction = _inheritanceManager.lookupMemberType( |
| - iteratorInterfaceType, "current"); |
| + PropertyAccessorElement currentFunction = |
| + iteratorInterfaceType.lookUpInheritedGetter("current"); |
| if (currentFunction == null) { |
| // TODO(brianwilkerson) Should we report this error? |
| return null; |
| @@ -11615,16 +11554,15 @@ class ResolverVisitor extends ScopedVisitor { |
| /** |
| * The given expression is the expression used to compute the stream for an |
| - * asyncronous for-each statement. Attempt to compute the type of objects that |
| - * will be assigned to the loop variable and return that type. Return `null` |
| - * if the type could not be determined. The [streamExpression] is the |
| - * expression that will return the stream being iterated over. |
| + * asynchronous for-each statement. Attempt to compute the type of objects |
| + * that will be assigned to the loop variable and return that type. |
| + * Return `null` if the type could not be determined. The [streamExpression] |
| + * is the expression that will return the stream being iterated over. |
| */ |
| DartType _getStreamElementType(Expression streamExpression) { |
| DartType streamType = streamExpression.bestType; |
| if (streamType is InterfaceType) { |
| - FunctionType listenFunction = |
| - _inheritanceManager.lookupMemberType(streamType, "listen"); |
| + MethodElement listenFunction = streamType.lookUpInheritedMethod("listen"); |
| if (listenFunction == null) { |
| return null; |
| } |
| @@ -11635,17 +11573,10 @@ class ResolverVisitor extends ScopedVisitor { |
| DartType onDataType = listenParameters[0].type; |
| if (onDataType is FunctionType) { |
| List<ParameterElement> onDataParameters = onDataType.parameters; |
| - if (onDataParameters == null || onDataParameters.length < 1) { |
| + if (onDataParameters == null || onDataParameters.isEmpty) { |
| return null; |
| } |
| - DartType eventType = onDataParameters[0].type; |
| - // TODO(paulberry): checking that typeParameters.isNotEmpty is a |
| - // band-aid fix for dartbug.com/24191. Figure out what the correct |
| - // logic should be. |
| - if (streamType.typeParameters.isNotEmpty && |
| - eventType.element == streamType.typeParameters[0]) { |
| - return streamType.typeArguments[0]; |
| - } |
| + return onDataParameters[0].type; |
| } |
| } |
| return null; |
| @@ -12881,10 +12812,8 @@ class StrongTypeSystemImpl implements TypeSystem { |
| FunctionType _getCallMethodType(DartType t) { |
| if (t is InterfaceType) { |
| - ClassElement element = t.element; |
| - InheritanceManager manager = new InheritanceManager(element.library); |
| - FunctionType callType = manager.lookupMemberType(t, "call"); |
| - return callType; |
| + MethodElement callMethod = t.lookUpInheritedMethod("call"); |
| + return callMethod != null ? callMethod.type : null; |
|
Paul Berry
2015/10/29 16:29:59
Nit: these two lines could be collapsed to:
retur
Jennifer Messerly
2015/10/29 16:36:40
not sure if I can use null aware ops yet
Paul Berry
2015/10/29 16:43:10
There was a brief period where we couldn't use the
Jennifer Messerly
2015/10/29 17:24:33
Ah thank you!
BTW, I didn't intend to reply to yo
|
| } |
| return null; |
| } |