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

Unified Diff: pkg/analyzer/lib/src/dart/element/type.dart

Issue 2378243004: fix #27454, prune FunctionTypeImpl.parameters (Closed)
Patch Set: fix null type Created 4 years, 3 months 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/dart/element/member.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/type.dart
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index 4c2e971b1d9f2e408b6cf5d21b72931170fc5c9d..4bc84b629fb4168d1bd8d04aba814c4ac388cc9c 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -515,13 +515,41 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
if (parameterCount == 0) {
return baseParameters;
}
+
// create specialized parameters
- List<ParameterElement> specializedParameters =
- new List<ParameterElement>(parameterCount);
+ var specializedParams = new List<ParameterElement>(parameterCount);
+
+ var parameterTypes = TypeParameterTypeImpl.getTypes(typeParameters);
for (int i = 0; i < parameterCount; i++) {
- specializedParameters[i] = ParameterMember.from(baseParameters[i], this);
+ var parameter = baseParameters[i];
+ if (parameter?.type == null) {
+ specializedParams[i] = parameter;
+ continue;
+ }
+
+ // Check if parameter type depends on defining type type arguments, or
+ // if it needs to be pruned.
+
+ if (parameter is FieldFormalParameterElement) {
+ // TODO(jmesserly): this seems like it won't handle pruning correctly.
+ specializedParams[i] = new FieldFormalParameterMember(parameter, this);
+ continue;
+ }
+
+ var baseType = parameter.type as TypeImpl;
+ TypeImpl type;
+ if (typeArguments.isEmpty ||
+ typeArguments.length != typeParameters.length) {
+ type = baseType.pruned(newPrune);
+ } else {
+ type = baseType.substitute2(typeArguments, parameterTypes, newPrune);
+ }
+
+ specializedParams[i] = identical(type, baseType)
+ ? parameter
+ : new ParameterMember(parameter, this, type);
}
- return specializedParameters;
+ return specializedParams;
}
@override
@@ -634,6 +662,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
return instantiate(freshVariables) ==
object.instantiate(freshVariables);
}
+
return returnType == object.returnType &&
TypeImpl.equalArrays(
normalParameterTypes, object.normalParameterTypes) &&
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/member.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698