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

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

Issue 2829843002: MethodElementImpl.getReifiedType() should always create new parameter elements. (Closed)
Patch Set: Created 3 years, 8 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 | « no previous file | 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/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index e3c4ed967a0de4559113ed62602df9f953501576..17a7e99ec39819f3e80201c113cbb58f792e40fc 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -6661,23 +6661,22 @@ class MethodElementImpl extends ExecutableElementImpl implements MethodElement {
@override
FunctionType getReifiedType(DartType objectType) {
- // Collect the covariant parameters. Do this first so we don't allocate
- // anything in the common case where there are none.
- Set<String> covariantNames;
+ // Check whether we have any covariant parameters.
+ // Usually we don't, so we can use the same type.
+ bool hasCovariant = false;
for (ParameterElement parameter in parameters) {
if (parameter.isCovariant) {
- covariantNames ??= new Set();
- covariantNames.add(parameter.name);
+ hasCovariant = true;
+ break;
}
}
- if (covariantNames == null) return type;
+ if (!hasCovariant) {
+ return type;
+ }
List<ParameterElement> covariantParameters = parameters.map((parameter) {
- if (!covariantNames.contains(parameter.name)) {
- return parameter;
- }
-
+ DartType type = parameter.isCovariant ? objectType : parameter.type;
return new ParameterElementImpl.synthetic(
parameter.name, objectType, parameter.parameterKind);
}).toList();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698