OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.generated.resolver; | 5 library analyzer.src.generated.resolver; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
(...skipping 8448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8459 | 8459 |
8460 /** | 8460 /** |
8461 * Return the type represented by the given type [annotation]. | 8461 * Return the type represented by the given type [annotation]. |
8462 */ | 8462 */ |
8463 DartType _getType(TypeAnnotation annotation) { | 8463 DartType _getType(TypeAnnotation annotation) { |
8464 DartType type = annotation.type; | 8464 DartType type = annotation.type; |
8465 if (type == null) { | 8465 if (type == null) { |
8466 return undefinedType; | 8466 return undefinedType; |
8467 } else if (type is FunctionType) { | 8467 } else if (type is FunctionType) { |
8468 Element element = type.element; | 8468 Element element = type.element; |
8469 if (annotation is TypeName && element is GenericTypeAliasElement) { | 8469 if (annotation is TypeName && element is GenericTypeAliasElementImpl) { |
8470 List<TypeParameterElement> parameterElements = element.typeParameters; | 8470 TypeArgumentList argumentList = annotation.typeArguments; |
8471 FunctionType functionType = element.function.type; | 8471 List<DartType> typeArguments = null; |
8472 if (parameterElements.isNotEmpty) { | 8472 if (argumentList != null) { |
8473 List<DartType> parameterTypes = | 8473 List<TypeAnnotation> arguments = argumentList.arguments; |
8474 TypeParameterTypeImpl.getTypes(parameterElements); | 8474 int argumentCount = arguments.length; |
8475 int parameterCount = parameterTypes.length; | 8475 typeArguments = new List<DartType>(argumentCount); |
8476 TypeArgumentList argumentList = annotation.typeArguments; | 8476 for (int i = 0; i < argumentCount; i++) { |
8477 List<DartType> typeArguments; | 8477 typeArguments[i] = _getType(arguments[i]); |
8478 if (argumentList != null) { | |
8479 List<TypeAnnotation> arguments = argumentList.arguments; | |
8480 int argumentCount = arguments.length; | |
8481 if (argumentCount == parameterCount) { | |
8482 typeArguments = new List<DartType>(parameterCount); | |
8483 for (int i = 0; i < parameterCount; i++) { | |
8484 typeArguments[i] = _getType(arguments[i]); | |
8485 } | |
8486 } | |
8487 } | 8478 } |
8488 typeArguments ??= | |
8489 new List<DartType>.filled(parameterCount, dynamicType); | |
8490 functionType = | |
8491 functionType.substitute2(typeArguments, parameterTypes); | |
8492 } | 8479 } |
8493 return functionType; | 8480 return element.typeAfterSubstitution(typeArguments); |
8494 } | 8481 } |
8495 } | 8482 } |
8496 return type; | 8483 return type; |
8497 } | 8484 } |
8498 | 8485 |
8499 /** | 8486 /** |
8500 * Returns the simple identifier of the given (may be qualified) type name. | 8487 * Returns the simple identifier of the given (may be qualified) type name. |
8501 * | 8488 * |
8502 * @param typeName the (may be qualified) qualified type name | 8489 * @param typeName the (may be qualified) qualified type name |
8503 * @return the simple identifier of the given (may be qualified) type name. | 8490 * @return the simple identifier of the given (may be qualified) type name. |
(...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10927 return null; | 10914 return null; |
10928 } | 10915 } |
10929 if (identical(node.staticElement, variable)) { | 10916 if (identical(node.staticElement, variable)) { |
10930 if (node.inSetterContext()) { | 10917 if (node.inSetterContext()) { |
10931 result = true; | 10918 result = true; |
10932 } | 10919 } |
10933 } | 10920 } |
10934 return null; | 10921 return null; |
10935 } | 10922 } |
10936 } | 10923 } |
OLD | NEW |