Skip to content

Commit c0126fc

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Rename whyNotPromotedList -> whyNotPromotedArguments
The new name better reflects the purpose of the argument, which is to keep track of "why not promoted" information for the arguments of the invocation. In follow-up CLs I'll be doing more plumbing of "why not promoted" information, and this rename will make it clearer to distinguish the new plumbing from `whyNotPromotedArguments`. Change-Id: Ie4d618c211221fc0ea8e3a1c79f24a3423663f9e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391566 Commit-Queue: Paul Berry <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent c409e77 commit c0126fc

9 files changed

+207
-184
lines changed

pkg/analyzer/lib/src/dart/resolver/annotation_resolver.dart

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ class AnnotationResolver {
2424
ErrorReporter get _errorReporter => _resolver.errorReporter;
2525

2626
void resolve(
27-
AnnotationImpl node, List<WhyNotPromotedGetter> whyNotPromotedList) {
27+
AnnotationImpl node, List<WhyNotPromotedGetter> whyNotPromotedArguments) {
2828
node.typeArguments?.accept(_resolver);
29-
_resolve(node, whyNotPromotedList);
29+
_resolve(node, whyNotPromotedArguments);
3030
}
3131

3232
void _classConstructorInvocation(
3333
AnnotationImpl node,
3434
ClassElement classElement,
3535
SimpleIdentifierImpl? constructorName,
3636
ArgumentListImpl argumentList,
37-
List<WhyNotPromotedGetter> whyNotPromotedList,
37+
List<WhyNotPromotedGetter> whyNotPromotedArguments,
3838
) {
3939
ConstructorElement? constructorElement;
4040
if (constructorName != null) {
@@ -58,15 +58,15 @@ class AnnotationResolver {
5858
nullabilitySuffix: NullabilitySuffix.none,
5959
);
6060
},
61-
whyNotPromotedList,
61+
whyNotPromotedArguments,
6262
);
6363
}
6464

6565
void _classGetter(
6666
AnnotationImpl node,
6767
InterfaceElement classElement,
6868
SimpleIdentifierImpl? getterName,
69-
List<WhyNotPromotedGetter> whyNotPromotedList,
69+
List<WhyNotPromotedGetter> whyNotPromotedArguments,
7070
) {
7171
ExecutableElement? getter;
7272
if (getterName != null) {
@@ -81,7 +81,8 @@ class AnnotationResolver {
8181
node.element = getter;
8282

8383
if (getterName != null && getter is PropertyAccessorElement) {
84-
_propertyAccessorElement(node, getterName, getter, whyNotPromotedList);
84+
_propertyAccessorElement(
85+
node, getterName, getter, whyNotPromotedArguments);
8586
_resolveAnnotationElementGetter(node, getter);
8687
} else if (getter is! ConstructorElement) {
8788
_errorReporter.atNode(
@@ -90,7 +91,7 @@ class AnnotationResolver {
9091
);
9192
}
9293

93-
_visitArguments(node, whyNotPromotedList,
94+
_visitArguments(node, whyNotPromotedArguments,
9495
dataForTesting: _resolver.inferenceHelper.dataForTesting);
9596
}
9697

@@ -102,7 +103,7 @@ class AnnotationResolver {
102103
ConstructorElement? constructorElement,
103104
ArgumentListImpl argumentList,
104105
InterfaceType Function(List<DartType> typeArguments) instantiateElement,
105-
List<WhyNotPromotedGetter> whyNotPromotedList,
106+
List<WhyNotPromotedGetter> whyNotPromotedArguments,
106107
) {
107108
constructorName?.staticElement = constructorElement;
108109
node.element = constructorElement;
@@ -117,7 +118,7 @@ class AnnotationResolver {
117118
node: node,
118119
argumentList: argumentList,
119120
contextType: UnknownInferredType.instance,
120-
whyNotPromotedList: whyNotPromotedList,
121+
whyNotPromotedArguments: whyNotPromotedArguments,
121122
constructorName: constructorName)
122123
.resolveInvocation(rawType: null);
123124
return;
@@ -134,7 +135,7 @@ class AnnotationResolver {
134135
node: node,
135136
argumentList: argumentList,
136137
contextType: UnknownInferredType.instance,
137-
whyNotPromotedList: whyNotPromotedList,
138+
whyNotPromotedArguments: whyNotPromotedArguments,
138139
constructorName: constructorName)
139140
.resolveInvocation(rawType: constructorRawType);
140141
}
@@ -143,7 +144,7 @@ class AnnotationResolver {
143144
AnnotationImpl node,
144145
ExtensionElement extensionElement,
145146
SimpleIdentifierImpl? getterName,
146-
List<WhyNotPromotedGetter> whyNotPromotedList,
147+
List<WhyNotPromotedGetter> whyNotPromotedArguments,
147148
) {
148149
ExecutableElement? getter;
149150
if (getterName != null) {
@@ -154,7 +155,8 @@ class AnnotationResolver {
154155
node.element = getter;
155156

156157
if (getterName != null && getter is PropertyAccessorElement) {
157-
_propertyAccessorElement(node, getterName, getter, whyNotPromotedList);
158+
_propertyAccessorElement(
159+
node, getterName, getter, whyNotPromotedArguments);
158160
_resolveAnnotationElementGetter(node, getter);
159161
} else {
160162
_errorReporter.atNode(
@@ -163,14 +165,14 @@ class AnnotationResolver {
163165
);
164166
}
165167

166-
_visitArguments(node, whyNotPromotedList,
168+
_visitArguments(node, whyNotPromotedArguments,
167169
dataForTesting: _resolver.inferenceHelper.dataForTesting);
168170
}
169171

170172
void _localVariable(
171173
AnnotationImpl node,
172174
VariableElement element,
173-
List<WhyNotPromotedGetter> whyNotPromotedList,
175+
List<WhyNotPromotedGetter> whyNotPromotedArguments,
174176
) {
175177
if (!element.isConst || node.arguments != null) {
176178
_errorReporter.atNode(
@@ -179,26 +181,26 @@ class AnnotationResolver {
179181
);
180182
}
181183

182-
_visitArguments(node, whyNotPromotedList,
184+
_visitArguments(node, whyNotPromotedArguments,
183185
dataForTesting: _resolver.inferenceHelper.dataForTesting);
184186
}
185187

186188
void _propertyAccessorElement(
187189
AnnotationImpl node,
188190
SimpleIdentifierImpl name,
189191
PropertyAccessorElement element,
190-
List<WhyNotPromotedGetter> whyNotPromotedList,
192+
List<WhyNotPromotedGetter> whyNotPromotedArguments,
191193
) {
192194
name.staticElement = element;
193195
node.element = element;
194196

195197
_resolveAnnotationElementGetter(node, element);
196-
_visitArguments(node, whyNotPromotedList,
198+
_visitArguments(node, whyNotPromotedArguments,
197199
dataForTesting: _resolver.inferenceHelper.dataForTesting);
198200
}
199201

200202
void _resolve(
201-
AnnotationImpl node, List<WhyNotPromotedGetter> whyNotPromotedList) {
203+
AnnotationImpl node, List<WhyNotPromotedGetter> whyNotPromotedArguments) {
202204
SimpleIdentifierImpl name1;
203205
SimpleIdentifierImpl? name2;
204206
SimpleIdentifierImpl? name3;
@@ -222,7 +224,7 @@ class AnnotationResolver {
222224
CompileTimeErrorCode.UNDEFINED_ANNOTATION,
223225
arguments: [name1.name],
224226
);
225-
_visitArguments(node, whyNotPromotedList,
227+
_visitArguments(node, whyNotPromotedArguments,
226228
dataForTesting: _resolver.inferenceHelper.dataForTesting);
227229
return;
228230
}
@@ -231,16 +233,16 @@ class AnnotationResolver {
231233
if (element1 is InterfaceElement) {
232234
if (element1 is ClassElement && argumentList != null) {
233235
_classConstructorInvocation(
234-
node, element1, name2, argumentList, whyNotPromotedList);
236+
node, element1, name2, argumentList, whyNotPromotedArguments);
235237
} else {
236-
_classGetter(node, element1, name2, whyNotPromotedList);
238+
_classGetter(node, element1, name2, whyNotPromotedArguments);
237239
}
238240
return;
239241
}
240242

241243
// Extension.CONST
242244
if (element1 is ExtensionElement) {
243-
_extensionGetter(node, element1, name2, whyNotPromotedList);
245+
_extensionGetter(node, element1, name2, whyNotPromotedArguments);
244246
return;
245247
}
246248

@@ -253,20 +255,21 @@ class AnnotationResolver {
253255
if (element is InterfaceElement) {
254256
if (element is ClassElement && argumentList != null) {
255257
_classConstructorInvocation(
256-
node, element, name3, argumentList, whyNotPromotedList);
258+
node, element, name3, argumentList, whyNotPromotedArguments);
257259
} else {
258-
_classGetter(node, element, name3, whyNotPromotedList);
260+
_classGetter(node, element, name3, whyNotPromotedArguments);
259261
}
260262
return;
261263
}
262264
// prefix.Extension.CONST
263265
if (element is ExtensionElement) {
264-
_extensionGetter(node, element, name3, whyNotPromotedList);
266+
_extensionGetter(node, element, name3, whyNotPromotedArguments);
265267
return;
266268
}
267269
// prefix.CONST
268270
if (element is PropertyAccessorElement) {
269-
_propertyAccessorElement(node, name2, element, whyNotPromotedList);
271+
_propertyAccessorElement(
272+
node, name2, element, whyNotPromotedArguments);
270273
return;
271274
}
272275

@@ -276,10 +279,10 @@ class AnnotationResolver {
276279
var argumentList = node.arguments;
277280
if (aliasedType is InterfaceType && argumentList != null) {
278281
_typeAliasConstructorInvocation(node, element, name3, aliasedType,
279-
argumentList, whyNotPromotedList,
282+
argumentList, whyNotPromotedArguments,
280283
dataForTesting: _resolver.inferenceHelper.dataForTesting);
281284
} else {
282-
_typeAliasGetter(node, element, name3, whyNotPromotedList);
285+
_typeAliasGetter(node, element, name3, whyNotPromotedArguments);
283286
}
284287
return;
285288
}
@@ -290,7 +293,7 @@ class AnnotationResolver {
290293
CompileTimeErrorCode.UNDEFINED_ANNOTATION,
291294
arguments: [name2.name],
292295
);
293-
_visitArguments(node, whyNotPromotedList,
296+
_visitArguments(node, whyNotPromotedArguments,
294297
dataForTesting: _resolver.inferenceHelper.dataForTesting);
295298
return;
296299
}
@@ -299,7 +302,7 @@ class AnnotationResolver {
299302

300303
// CONST
301304
if (element1 is PropertyAccessorElement) {
302-
_propertyAccessorElement(node, name1, element1, whyNotPromotedList);
305+
_propertyAccessorElement(node, name1, element1, whyNotPromotedArguments);
303306
return;
304307
}
305308

@@ -309,16 +312,16 @@ class AnnotationResolver {
309312
var argumentList = node.arguments;
310313
if (aliasedType is InterfaceType && argumentList != null) {
311314
_typeAliasConstructorInvocation(node, element1, name2, aliasedType,
312-
argumentList, whyNotPromotedList,
315+
argumentList, whyNotPromotedArguments,
313316
dataForTesting: _resolver.inferenceHelper.dataForTesting);
314317
} else {
315-
_typeAliasGetter(node, element1, name2, whyNotPromotedList);
318+
_typeAliasGetter(node, element1, name2, whyNotPromotedArguments);
316319
}
317320
return;
318321
}
319322

320323
if (element1 is VariableElement) {
321-
_localVariable(node, element1, whyNotPromotedList);
324+
_localVariable(node, element1, whyNotPromotedArguments);
322325
return;
323326
}
324327

@@ -327,7 +330,7 @@ class AnnotationResolver {
327330
CompileTimeErrorCode.INVALID_ANNOTATION,
328331
);
329332

330-
_visitArguments(node, whyNotPromotedList,
333+
_visitArguments(node, whyNotPromotedArguments,
331334
dataForTesting: _resolver.inferenceHelper.dataForTesting);
332335
}
333336

@@ -356,7 +359,7 @@ class AnnotationResolver {
356359
SimpleIdentifierImpl? constructorName,
357360
InterfaceType aliasedType,
358361
ArgumentListImpl argumentList,
359-
List<WhyNotPromotedGetter> whyNotPromotedList,
362+
List<WhyNotPromotedGetter> whyNotPromotedArguments,
360363
{required TypeConstraintGenerationDataForTesting? dataForTesting}) {
361364
var constructorElement = aliasedType.lookUpConstructor(
362365
constructorName?.name,
@@ -376,15 +379,15 @@ class AnnotationResolver {
376379
nullabilitySuffix: NullabilitySuffix.none,
377380
) as InterfaceType;
378381
},
379-
whyNotPromotedList,
382+
whyNotPromotedArguments,
380383
);
381384
}
382385

383386
void _typeAliasGetter(
384387
AnnotationImpl node,
385388
TypeAliasElement typeAliasElement,
386389
SimpleIdentifierImpl? getterName,
387-
List<WhyNotPromotedGetter> whyNotPromotedList,
390+
List<WhyNotPromotedGetter> whyNotPromotedArguments,
388391
) {
389392
ExecutableElement? getter;
390393
var aliasedType = typeAliasElement.aliasedType;
@@ -399,7 +402,8 @@ class AnnotationResolver {
399402
node.element = getter;
400403

401404
if (getterName != null && getter is PropertyAccessorElement) {
402-
_propertyAccessorElement(node, getterName, getter, whyNotPromotedList);
405+
_propertyAccessorElement(
406+
node, getterName, getter, whyNotPromotedArguments);
403407
_resolveAnnotationElementGetter(node, getter);
404408
} else if (getter is! ConstructorElement) {
405409
_errorReporter.atNode(
@@ -408,12 +412,12 @@ class AnnotationResolver {
408412
);
409413
}
410414

411-
_visitArguments(node, whyNotPromotedList,
415+
_visitArguments(node, whyNotPromotedArguments,
412416
dataForTesting: _resolver.inferenceHelper.dataForTesting);
413417
}
414418

415419
void _visitArguments(
416-
AnnotationImpl node, List<WhyNotPromotedGetter> whyNotPromotedList,
420+
AnnotationImpl node, List<WhyNotPromotedGetter> whyNotPromotedArguments,
417421
{required TypeConstraintGenerationDataForTesting? dataForTesting}) {
418422
var arguments = node.arguments;
419423
if (arguments != null) {
@@ -422,7 +426,7 @@ class AnnotationResolver {
422426
node: node,
423427
argumentList: arguments,
424428
contextType: UnknownInferredType.instance,
425-
whyNotPromotedList: whyNotPromotedList,
429+
whyNotPromotedArguments: whyNotPromotedArguments,
426430
constructorName: null)
427431
.resolveInvocation(rawType: null);
428432
}

pkg/analyzer/lib/src/dart/resolver/extension_member_resolver.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ class ExtensionMemberResolver {
178178
}
179179

180180
/// Perform upward inference for the override.
181-
void resolveOverride(
182-
ExtensionOverride node, List<WhyNotPromotedGetter> whyNotPromotedList) {
181+
void resolveOverride(ExtensionOverride node,
182+
List<WhyNotPromotedGetter> whyNotPromotedArguments) {
183183
var nodeImpl = node as ExtensionOverrideImpl;
184184
var element = node.element;
185185
var typeParameters = element.typeParameters;
@@ -240,7 +240,7 @@ class ExtensionMemberResolver {
240240
} else if (!_typeSystem.isAssignableTo(receiverType, extendedType,
241241
strictCasts: _resolver.analysisOptions.strictCasts)) {
242242
var whyNotPromoted =
243-
whyNotPromotedList.isEmpty ? null : whyNotPromotedList[0];
243+
whyNotPromotedArguments.isEmpty ? null : whyNotPromotedArguments[0];
244244
_errorReporter.atNode(
245245
receiverExpression,
246246
CompileTimeErrorCode.EXTENSION_OVERRIDE_ARGUMENT_NOT_ASSIGNABLE,

0 commit comments

Comments
 (0)