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.dart.element.element; | 5 library analyzer.src.dart.element.element; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 5218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5229 } | 5229 } |
5230 | 5230 |
5231 /** | 5231 /** |
5232 * Return the type of the function defined by this typedef after substituting | 5232 * Return the type of the function defined by this typedef after substituting |
5233 * the given [typeArguments] for the type parameters defined for this typedef | 5233 * the given [typeArguments] for the type parameters defined for this typedef |
5234 * (but not the type parameters defined by the function). If the number of | 5234 * (but not the type parameters defined by the function). If the number of |
5235 * [typeArguments] does not match the number of type parameters, then | 5235 * [typeArguments] does not match the number of type parameters, then |
5236 * `dynamic` will be used in place of each of the type arguments. | 5236 * `dynamic` will be used in place of each of the type arguments. |
5237 */ | 5237 */ |
5238 FunctionType typeAfterSubstitution(List<DartType> typeArguments) { | 5238 FunctionType typeAfterSubstitution(List<DartType> typeArguments) { |
| 5239 GenericFunctionTypeElement function = this.function; |
| 5240 if (function == null) { |
| 5241 return null; |
| 5242 } |
5239 FunctionType functionType = function.type; | 5243 FunctionType functionType = function.type; |
5240 List<TypeParameterElement> parameterElements = typeParameters; | 5244 List<TypeParameterElement> parameterElements = typeParameters; |
5241 List<DartType> parameterTypes = | 5245 List<DartType> parameterTypes = |
5242 TypeParameterTypeImpl.getTypes(parameterElements); | 5246 TypeParameterTypeImpl.getTypes(parameterElements); |
5243 int parameterCount = parameterTypes.length; | 5247 int parameterCount = parameterTypes.length; |
5244 if (typeArguments == null || | 5248 if (typeArguments == null || |
5245 parameterElements.length != typeArguments.length) { | 5249 parameterElements.length != typeArguments.length) { |
5246 DartType dynamicType = DynamicElementImpl.instance.type; | 5250 DartType dynamicType = DynamicElementImpl.instance.type; |
5247 typeArguments = new List<DartType>.filled(parameterCount, dynamicType); | 5251 typeArguments = new List<DartType>.filled(parameterCount, dynamicType); |
5248 } | 5252 } |
(...skipping 3847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9096 | 9100 |
9097 @override | 9101 @override |
9098 void visitElement(Element element) { | 9102 void visitElement(Element element) { |
9099 int offset = element.nameOffset; | 9103 int offset = element.nameOffset; |
9100 if (offset != -1) { | 9104 if (offset != -1) { |
9101 map[offset] = element; | 9105 map[offset] = element; |
9102 } | 9106 } |
9103 super.visitElement(element); | 9107 super.visitElement(element); |
9104 } | 9108 } |
9105 } | 9109 } |
OLD | NEW |