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

Unified Diff: pkg/analyzer/lib/src/generated/type_system.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/resolver.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/type_system.dart
diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
index dc3bc7ec384d555346bfff8ef9db29bc6cf417c7..f731360a6bda23e117e45b5c348808d11fc01151 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -50,27 +50,19 @@ class StrongTypeSystemImpl implements TypeSystem {
FunctionTypeImpl fnType,
List<DartType> correspondingParameterTypes,
List<DartType> argumentTypes) {
- TypeParameterizedElement element = fnType.element;
- if (element.typeParameters.isEmpty) {
+ if (fnType.boundTypeParameters.isEmpty) {
return fnType;
}
- assert(correspondingParameterTypes.length == argumentTypes.length);
- int numParams = element.typeParameters.length;
- List<DartType> fnTypeParams = fnType.typeArguments;
- fnTypeParams = fnTypeParams.sublist(0, numParams);
- for (int i = 0; i < numParams; i++) {
- if (element.typeParameters[i].type != fnTypeParams[i]) {
- // Only infer if all of the type parameters are unsubstituted.
- return fnType;
- }
- }
+
+ List<TypeParameterType> fnTypeParams =
+ TypeParameterTypeImpl.getTypes(fnType.boundTypeParameters);
// Create a TypeSystem that will allow certain type parameters to be
// inferred. It will optimistically assume these type parameters can be
// subtypes (or supertypes) as necessary, and track the constraints that
// are implied by this.
- var inferringTypeSystem = new _StrongInferenceTypeSystem(
- typeProvider, new List<TypeParameterType>.from(fnTypeParams));
+ var inferringTypeSystem =
+ new _StrongInferenceTypeSystem(typeProvider, fnTypeParams);
for (int i = 0; i < argumentTypes.length; i++) {
// Try to pass each argument to each parameter, recording any type
@@ -132,8 +124,8 @@ class StrongTypeSystemImpl implements TypeSystem {
}
}
- // Return the substituted type.
- return fnType.substitute2(inferredTypes, fnTypeParams);
+ // Return the instantiated type.
+ return fnType.instantiate(inferredTypes);
}
// TODO(leafp): Document the rules in play here
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698