Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1488383004: Fixes incorrect generic function type capture (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b80ed5a2deaca94429c70bb7a6759ea33bb33889..e130e583645d952304930ec5c40d6a005cea372f 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -14959,7 +14959,7 @@ class TypeResolverVisitor extends ScopedVisitor {
if (argumentList != null) {
NodeList<TypeName> arguments = argumentList.arguments;
int argumentCount = arguments.length;
- List<DartType> parameters = _getTypeArguments(type);
+ List<DartType> parameters = _getTypeParameters(type);
int parameterCount = parameters.length;
List<DartType> typeArguments = new List<DartType>(parameterCount);
if (argumentCount == parameterCount) {
@@ -14978,21 +14978,13 @@ class TypeResolverVisitor extends ScopedVisitor {
typeArguments[i] = _dynamicType;
}
}
- if (type is InterfaceTypeImpl) {
- InterfaceTypeImpl interfaceType = type as InterfaceTypeImpl;
- type = interfaceType.substitute4(typeArguments);
- } else if (type is FunctionTypeImpl) {
- FunctionTypeImpl functionType = type as FunctionTypeImpl;
- type = functionType.substitute3(typeArguments);
- } else {
- // TODO(brianwilkerson) Report this internal error.
- }
+ type = _instantiateType(type, typeArguments);
} else {
//
// Check for the case where there are no type arguments given for a
// parameterized type.
//
- List<DartType> parameters = _getTypeArguments(type);
+ List<DartType> parameters = _getTypeParameters(type);
int parameterCount = parameters.length;
if (parameterCount > 0) {
DynamicTypeImpl dynamicType = DynamicTypeImpl.instance;
@@ -15000,7 +14992,7 @@ class TypeResolverVisitor extends ScopedVisitor {
for (int i = 0; i < parameterCount; i++) {
arguments[i] = dynamicType;
}
- type = type.substitute2(arguments, parameters);
+ type = _instantiateType(type, arguments);
}
}
typeName.staticType = type;
@@ -15185,11 +15177,11 @@ class TypeResolverVisitor extends ScopedVisitor {
* @param type the type whole type arguments are to be returned
* @return the type arguments associated with the given type
*/
- List<DartType> _getTypeArguments(DartType type) {
+ List<DartType> _getTypeParameters(DartType type) {
if (type is InterfaceType) {
return type.typeArguments;
} else if (type is FunctionType) {
- return type.typeArguments;
+ return TypeParameterTypeImpl.getTypes(type.boundTypeParameters);
}
return DartType.EMPTY_LIST;
}
@@ -15228,6 +15220,17 @@ class TypeResolverVisitor extends ScopedVisitor {
return type;
}
+ DartType _instantiateType(DartType type, List<DartType> typeArguments) {
+ if (type is InterfaceTypeImpl) {
+ return type.substitute4(typeArguments);
+ } else if (type is FunctionTypeImpl) {
+ return type.instantiate(typeArguments);
+ } else {
+ // TODO(brianwilkerson) Report this internal error.
+ return type;
+ }
+ }
+
/**
* Checks if the given type name is used as the type in an as expression.
*
« no previous file with comments | « pkg/analyzer/lib/src/generated/element.dart ('k') | pkg/analyzer/lib/src/generated/type_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698