| 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 dbff10ebee74a66d83473c08b8d2c53d74dbab38..ebd1f63a559a4f28940bff5542e05217321b9137 100644
|
| --- a/pkg/analyzer/lib/src/dart/element/element.dart
|
| +++ b/pkg/analyzer/lib/src/dart/element/element.dart
|
| @@ -1683,6 +1683,11 @@ class CompilationUnitElementImpl extends UriReferencedElementImpl
|
|
|
| @override
|
| List<FunctionTypeAliasElement> get functionTypeAliases {
|
| + if (_kernelContext != null) {
|
| + _typeAliases ??= _kernelContext.library.typedefs
|
| + .map((k) => new FunctionTypeAliasElementImpl.forKernel(this, k))
|
| + .toList(growable: false);
|
| + }
|
| if (_unlinkedUnit != null) {
|
| _typeAliases ??= _unlinkedUnit.typedefs.map((t) {
|
| if (t.style == TypedefStyle.functionType) {
|
| @@ -4921,6 +4926,11 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
| final UnlinkedTypedef _unlinkedTypedef;
|
|
|
| /**
|
| + * The kernel of the element.
|
| + */
|
| + final kernel.Typedef _kernel;
|
| +
|
| + /**
|
| * A list containing all of the parameters defined by this type alias.
|
| */
|
| List<ParameterElement> _parameters;
|
| @@ -4944,13 +4954,23 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
| */
|
| FunctionTypeAliasElementImpl(String name, int nameOffset)
|
| : _unlinkedTypedef = null,
|
| + _kernel = null,
|
| super(name, nameOffset);
|
|
|
| /**
|
| + * Initialize using the given kernel.
|
| + */
|
| + FunctionTypeAliasElementImpl.forKernel(
|
| + CompilationUnitElementImpl enclosingUnit, this._kernel)
|
| + : _unlinkedTypedef = null,
|
| + super.forSerialized(enclosingUnit);
|
| +
|
| + /**
|
| * Initialize a newly created type alias element to have the given [name].
|
| */
|
| FunctionTypeAliasElementImpl.forNode(Identifier name)
|
| : _unlinkedTypedef = null,
|
| + _kernel = null,
|
| super.forNode(name);
|
|
|
| /**
|
| @@ -4958,7 +4978,8 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
| */
|
| FunctionTypeAliasElementImpl.forSerialized(
|
| this._unlinkedTypedef, CompilationUnitElementImpl enclosingUnit)
|
| - : super.forSerialized(enclosingUnit);
|
| + : _kernel = null,
|
| + super.forSerialized(enclosingUnit);
|
|
|
| @override
|
| int get codeLength {
|
| @@ -4999,7 +5020,7 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
| _enclosingElement as CompilationUnitElementImpl;
|
|
|
| @override
|
| - List<kernel.TypeParameter> get kernelTypeParams => null;
|
| + List<kernel.TypeParameter> get kernelTypeParams => _kernel?.typeParameters;
|
|
|
| @override
|
| ElementKind get kind => ElementKind.FUNCTION_TYPE_ALIAS;
|
| @@ -5015,6 +5036,9 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
|
|
| @override
|
| String get name {
|
| + if (_kernel != null) {
|
| + return _kernel.name;
|
| + }
|
| if (_unlinkedTypedef != null) {
|
| return _unlinkedTypedef.name;
|
| }
|
| @@ -5032,6 +5056,13 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
|
|
| @override
|
| List<ParameterElement> get parameters {
|
| + if (_kernel != null) {
|
| + _parameters ??= ParameterElementImpl.forKernelParameters(
|
| + this,
|
| + _kernel.requiredParameterCount,
|
| + _kernel.positionalParameters,
|
| + _kernel.namedParameters);
|
| + }
|
| if (_unlinkedTypedef != null) {
|
| _parameters ??= ParameterElementImpl.resynthesizeList(
|
| _unlinkedTypedef.parameters, this);
|
| @@ -5054,10 +5085,17 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
|
|
| @override
|
| DartType get returnType {
|
| - if (_unlinkedTypedef != null && _returnType == null) {
|
| - _returnType = enclosingUnit.resynthesizerContext.resolveTypeRef(
|
| - this, _unlinkedTypedef.returnType,
|
| - declaredType: true);
|
| + if (_returnType == null) {
|
| + if (_kernel != null) {
|
| + var type = _kernel.type as kernel.FunctionType;
|
| + _returnType =
|
| + enclosingUnit._kernelContext.getType(this, type.returnType);
|
| + }
|
| + if (_unlinkedTypedef != null) {
|
| + _returnType = enclosingUnit.resynthesizerContext.resolveTypeRef(
|
| + this, _unlinkedTypedef.returnType,
|
| + declaredType: true);
|
| + }
|
| }
|
| return _returnType;
|
| }
|
| @@ -5069,8 +5107,10 @@ class FunctionTypeAliasElementImpl extends ElementImpl
|
|
|
| @override
|
| FunctionType get type {
|
| - if (_unlinkedTypedef != null && _type == null) {
|
| - _type = new FunctionTypeImpl.forTypedef(this);
|
| + if (_type == null) {
|
| + if (_kernel != null || _unlinkedTypedef != null) {
|
| + _type = new FunctionTypeImpl.forTypedef(this);
|
| + }
|
| }
|
| return _type;
|
| }
|
|
|