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; |