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

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

Issue 2985293002: Add optional FunctionType.positionalParameterNames and use them to resynthesize function-type forma… (Closed)
Patch Set: Created 3 years, 5 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 | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | pkg/kernel/lib/ast.dart » ('J')
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 b4059812a9e3ae697a622fb654871910ef1cf940..9992fbf5cd03b388c08e13920535ab60f7afb413 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -8103,9 +8103,6 @@ class ParameterElementImpl extends VariableElementImpl
@override
DartType get type {
- if (_kernel != null) {
- return _type ??= enclosingUnit._kernelContext.getType(this, _kernel.type);
- }
_resynthesizeTypeAndParameters();
return super.type;
}
@@ -8217,6 +8214,36 @@ class ParameterElementImpl extends VariableElementImpl
* been build yet, build them and remember in the corresponding fields.
*/
void _resynthesizeTypeAndParameters() {
+ if (_kernel != null && _type == null) {
+ kernel.DartType type = _kernel.type;
+ _type = enclosingUnit._kernelContext.getType(this, type);
+ if (type is kernel.FunctionType) {
+ _parameters = new List<ParameterElement>(
+ type.positionalParameters.length + type.namedParameters.length);
+ int index = 0;
+ for (int i = 0; i < type.positionalParameters.length; i++) {
+ String name = i < type.positionalParameterNames.length
+ ? type.positionalParameterNames[i]
+ : null;
+ _parameters[index++] = new ParameterElementImpl.forKernel(
+ enclosingElement,
+ new kernel.VariableDeclaration(name,
+ type: type.positionalParameters[i]),
+ i < type.requiredParameterCount
+ ? ParameterKind.REQUIRED
+ : ParameterKind.POSITIONAL);
+ }
+ for (int i = 0; i < type.namedParameters.length; i++) {
+ _parameters[index++] = new ParameterElementImpl.forKernel(
+ enclosingElement,
+ new kernel.VariableDeclaration(type.namedParameters[i].name,
+ type: type.namedParameters[i].type),
+ ParameterKind.NAMED);
+ }
+ } else {
+ _parameters = const <ParameterElement>[];
+ }
+ }
if (_unlinkedParam != null && _declaredType == null && _type == null) {
if (_unlinkedParam.isFunctionTyped) {
CompilationUnitElementImpl enclosingUnit = this.enclosingUnit;
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_common.dart » ('j') | pkg/kernel/lib/ast.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698