Add DartType.alias, deprecate aliasElement/aliasArguments.

Change-Id: I80e0c47c8f431eb504044f4110b55add64c943d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207280
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-07-19 21:56:34 +00:00 committed by commit-bot@chromium.org
parent 9c6b1ea4e9
commit 62f73a5bd9
22 changed files with 206 additions and 141 deletions

View file

@ -860,14 +860,13 @@ class CorrectionUtils {
/// used by the generated source, but not imported.
String? getTypeSource(DartType type, Set<Source> librariesToImport,
{StringBuffer? parametersBuffer}) {
var aliasElement = type.aliasElement;
var aliasArguments = type.aliasArguments;
if (aliasElement != null && aliasArguments != null) {
var alias = type.alias;
if (alias != null) {
return _getTypeCodeElementArguments(
librariesToImport: librariesToImport,
element: aliasElement,
element: alias.element,
isNullable: type.nullabilitySuffix == NullabilitySuffix.question,
typeArguments: aliasArguments,
typeArguments: alias.typeArguments,
);
}

View file

@ -1,4 +1,4 @@
## 2.1.0
## 2.1.0-dev
* Changed `AnalysisResult.path` to be non-nullable.
* Changed `ParsedLibraryResult.units` to be non-nullable.
* Changed `ResolvedLibraryResult.element` to be non-nullable.
@ -11,6 +11,9 @@
`content` and `unit` were `null`, when the result actually had only errors.
Now it produces either `ResolvedUnitResult`, or `ErrorsResult`, or
some other results that might be added in the future.
* Added `DartType.alias` with information about instantiated type alias.
The type alias element and arguments are present or absent together.
* Deprecated `DartType.aliasElement` and `DartType.aliasArguments`.
## 2.0.0
* Removed deprecated `Scope.lookup2()`.

View file

@ -28,12 +28,19 @@ import 'package:analyzer/src/dart/element/type.dart' show InterfaceTypeImpl;
///
/// Clients may not extend, implement or mix-in this class.
abstract class DartType {
/// If this type is an instantiation of a type alias, information about
/// the alias element, and the type arguments.
/// Otherwise return `null`.
InstantiatedTypeAliasElement? get alias;
/// If this type is an instantiation of a type alias, return the type
/// arguments used for the instantiation. Otherwise return `null`.
@Deprecated('Use alias instead')
List<DartType>? get aliasArguments;
/// If this type is an instantiation of a type alias, return it.
/// Otherwise return `null`.
@Deprecated('Use alias instead')
TypeAliasElement? get aliasElement;
/// Return the name of this type as it should appear when presented to users
@ -245,6 +252,17 @@ abstract class FunctionType implements DartType {
FunctionType instantiate(List<DartType> argumentTypes);
}
/// Information about an instantiated [TypeAliasElement] and the type
/// arguments with which it is instantiated.
abstract class InstantiatedTypeAliasElement {
/// The alias element that is instantiated to produce a [DartType].
TypeAliasElement get element;
/// The type arguments with which the [element] was instantiated.
/// This list will be empty if the [element] is not generic.
List<DartType> get typeArguments;
}
/// The type introduced by either a class or an interface, or a reference to
/// such a type.
///

View file

@ -5480,23 +5480,29 @@ class TypeAliasElementImpl extends _ExistingElementImpl
parameters: type.parameters,
returnType: type.returnType,
nullabilitySuffix: resultNullability,
aliasElement: this,
aliasArguments: typeArguments,
alias: InstantiatedTypeAliasElementImpl(
element: this,
typeArguments: typeArguments,
),
);
} else if (type is InterfaceType) {
return InterfaceTypeImpl(
element: type.element,
typeArguments: type.typeArguments,
nullabilitySuffix: resultNullability,
aliasElement: this,
aliasArguments: typeArguments,
alias: InstantiatedTypeAliasElementImpl(
element: this,
typeArguments: typeArguments,
),
);
} else if (type is TypeParameterType) {
return TypeParameterTypeImpl(
element: type.element,
nullabilitySuffix: resultNullability,
aliasElement: this,
aliasArguments: typeArguments,
alias: InstantiatedTypeAliasElementImpl(
element: this,
typeArguments: typeArguments,
),
);
} else {
return (type as TypeImpl).withNullability(resultNullability);

View file

@ -583,7 +583,7 @@ class GenericInferrer {
if (typeElement != null && typeElement.hasOptionalTypeArgs) {
return;
}
var typeAliasElement = type.aliasElement;
var typeAliasElement = type.alias?.element;
if (typeAliasElement != null &&
typeAliasElement.hasOptionalTypeArgs) {
return;

View file

@ -53,8 +53,9 @@ class ReplaceTopBottomVisitor {
}
}
if (type.aliasElement != null) {
return _typeAliasInstantiation(type, variance);
var alias = type.alias;
if (alias != null) {
return _instantiatedTypeAlias(type, alias, variance);
} else if (type is InterfaceType) {
return _interfaceType(type, variance);
} else if (type is FunctionType) {
@ -83,6 +84,34 @@ class ReplaceTopBottomVisitor {
);
}
DartType _instantiatedTypeAlias(
DartType type,
InstantiatedTypeAliasElement alias,
Variance variance,
) {
var aliasElement = alias.element;
var aliasArguments = alias.typeArguments;
var typeParameters = aliasElement.typeParameters;
assert(typeParameters.length == aliasArguments.length);
var newTypeArguments = <DartType>[];
for (var i = 0; i < typeParameters.length; i++) {
var typeParameter = typeParameters[i] as TypeParameterElementImpl;
newTypeArguments.add(
process(
aliasArguments[i],
typeParameter.variance.combine(variance),
),
);
}
return aliasElement.instantiate(
typeArguments: newTypeArguments,
nullabilitySuffix: type.nullabilitySuffix,
);
}
DartType _interfaceType(InterfaceType type, Variance variance) {
var typeParameters = type.element.typeParameters;
if (typeParameters.isEmpty) {
@ -105,30 +134,6 @@ class ReplaceTopBottomVisitor {
);
}
DartType _typeAliasInstantiation(DartType type, Variance variance) {
var aliasElement = type.aliasElement!;
var aliasArguments = type.aliasArguments!;
var typeParameters = aliasElement.typeParameters;
assert(typeParameters.length == aliasArguments.length);
var newTypeArguments = <DartType>[];
for (var i = 0; i < typeParameters.length; i++) {
var typeParameter = typeParameters[i] as TypeParameterElementImpl;
newTypeArguments.add(
process(
aliasArguments[i],
typeParameter.variance.combine(variance),
),
);
}
return aliasElement.instantiate(
typeArguments: newTypeArguments,
nullabilitySuffix: type.nullabilitySuffix,
);
}
/// Runs an instance of the visitor on the given [type] and returns the
/// resulting type. If the type contains no instances of Top or Bottom, the
/// original type object is returned to avoid unnecessary allocation.

View file

@ -29,13 +29,14 @@ class ReplacementVisitor
DartType? createFunctionType({
required FunctionType type,
required List<DartType>? newAliasArguments,
required InstantiatedTypeAliasElement? newAlias,
required List<TypeParameterElement>? newTypeParameters,
required List<ParameterElement>? newParameters,
required DartType? newReturnType,
required NullabilitySuffix? newNullability,
}) {
if (newNullability == null &&
if (newAlias == null &&
newNullability == null &&
newReturnType == null &&
newParameters == null) {
return null;
@ -46,8 +47,7 @@ class ReplacementVisitor
parameters: newParameters ?? type.parameters,
returnType: newReturnType ?? type.returnType,
nullabilitySuffix: newNullability ?? type.nullabilitySuffix,
aliasElement: type.aliasElement,
aliasArguments: newAliasArguments ?? type.aliasArguments,
alias: newAlias ?? type.alias,
);
}
@ -74,11 +74,11 @@ class ReplacementVisitor
DartType? createInterfaceType({
required InterfaceType type,
required List<DartType>? newAliasArguments,
required InstantiatedTypeAliasElement? newAlias,
required List<DartType>? newTypeArguments,
required NullabilitySuffix? newNullability,
}) {
if (newAliasArguments == null &&
if (newAlias == null &&
newTypeArguments == null &&
newNullability == null) {
return null;
@ -88,8 +88,7 @@ class ReplacementVisitor
element: type.element,
typeArguments: newTypeArguments ?? type.typeArguments,
nullabilitySuffix: newNullability ?? type.nullabilitySuffix,
aliasElement: type.aliasElement,
aliasArguments: newAliasArguments ?? type.aliasArguments,
alias: newAlias ?? type.alias,
);
}
@ -136,8 +135,7 @@ class ReplacementVisitor
element: type.element,
nullabilitySuffix: newNullability ?? type.nullabilitySuffix,
promotedBound: newPromotedBound ?? promotedBound,
aliasElement: type.aliasElement,
aliasArguments: type.aliasArguments,
alias: type.alias,
);
}
@ -152,8 +150,7 @@ class ReplacementVisitor
return TypeParameterTypeImpl(
element: type.element,
nullabilitySuffix: newNullability,
aliasElement: type.aliasElement,
aliasArguments: type.aliasArguments,
alias: type.alias,
);
}
@ -215,16 +212,24 @@ class ReplacementVisitor
var newReturnType = visitType(node.returnType);
List<DartType>? newAliasArguments;
var aliasArguments = node.aliasArguments;
if (aliasArguments != null) {
InstantiatedTypeAliasElement? newAlias;
var alias = node.alias;
if (alias != null) {
List<DartType>? newArguments;
var aliasArguments = alias.typeArguments;
for (var i = 0; i < aliasArguments.length; i++) {
var substitution = aliasArguments[i].accept(this);
if (substitution != null) {
newAliasArguments ??= aliasArguments.toList(growable: false);
newAliasArguments[i] = substitution;
newArguments ??= aliasArguments.toList(growable: false);
newArguments[i] = substitution;
}
}
if (newArguments != null) {
newAlias = InstantiatedTypeAliasElementImpl(
element: alias.element,
typeArguments: newArguments,
);
}
}
changeVariance();
@ -253,7 +258,7 @@ class ReplacementVisitor
return createFunctionType(
type: node,
newAliasArguments: newAliasArguments,
newAlias: newAlias,
newTypeParameters: newTypeParameters,
newParameters: newParameters,
newReturnType: newReturnType,
@ -351,13 +356,20 @@ class ReplacementVisitor
DartType? visitInterfaceType(InterfaceType type) {
var newNullability = visitNullability(type);
var aliasElement = type.aliasElement;
var newAliasArguments = aliasElement != null
? _typeArguments(
aliasElement.typeParameters,
type.aliasArguments,
)
: null;
InstantiatedTypeAliasElement? newAlias;
var alias = type.alias;
if (alias != null) {
var newArguments = _typeArguments(
alias.element.typeParameters,
alias.typeArguments,
);
if (newArguments != null) {
newAlias = InstantiatedTypeAliasElementImpl(
element: alias.element,
typeArguments: newArguments,
);
}
}
var newTypeArguments = _typeArguments(
type.element.typeParameters,
@ -366,7 +378,7 @@ class ReplacementVisitor
return createInterfaceType(
type: type,
newAliasArguments: newAliasArguments,
newAlias: newAlias,
newTypeArguments: newTypeArguments,
newNullability: newNullability,
);
@ -453,12 +465,8 @@ class ReplacementVisitor
List<DartType>? _typeArguments(
List<TypeParameterElement> parameters,
List<DartType>? arguments,
List<DartType> arguments,
) {
if (arguments == null) {
return null;
}
if (arguments.length != parameters.length) {
return null;
}

View file

@ -109,13 +109,12 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
required List<ParameterElement> parameters,
required DartType returnType,
required NullabilitySuffix nullabilitySuffix,
TypeAliasElement? aliasElement,
List<DartType>? aliasArguments,
InstantiatedTypeAliasElement? alias,
}) : typeFormals = typeFormals,
parameters = _sortNamedParameters(parameters),
returnType = returnType,
nullabilitySuffix = nullabilitySuffix,
super(null, aliasElement: aliasElement, aliasArguments: aliasArguments);
super(null, alias: alias);
@override
int get hashCode {
@ -297,8 +296,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
parameters: parameters,
returnType: returnType,
nullabilitySuffix: nullabilitySuffix,
aliasElement: aliasElement,
aliasArguments: aliasArguments,
alias: alias,
);
}
@ -610,6 +608,19 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
}
}
class InstantiatedTypeAliasElementImpl implements InstantiatedTypeAliasElement {
@override
final TypeAliasElement element;
@override
final List<DartType> typeArguments;
InstantiatedTypeAliasElementImpl({
required this.element,
required this.typeArguments,
});
}
/// A concrete implementation of an [InterfaceType].
class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
@override
@ -631,12 +642,10 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
required ClassElement element,
required this.typeArguments,
required this.nullabilitySuffix,
TypeAliasElement? aliasElement,
List<DartType>? aliasArguments,
InstantiatedTypeAliasElement? alias,
}) : super(
element,
aliasElement: aliasElement,
aliasArguments: aliasArguments,
alias: alias,
);
@override
@ -1615,19 +1624,26 @@ class NeverTypeImpl extends TypeImpl implements NeverType {
/// representing the declared type of elements in the element model.
abstract class TypeImpl implements DartType {
@override
final List<DartType>? aliasArguments;
@override
final TypeAliasElement? aliasElement;
InstantiatedTypeAliasElement? alias;
/// The element representing the declaration of this type, or `null` if the
/// type has not, or cannot, be associated with an element.
final Element? _element;
/// Initialize a newly created type to be declared by the given [element].
TypeImpl(this._element, {this.aliasElement, this.aliasArguments})
: assert(aliasElement == null && aliasArguments == null ||
aliasElement != null && aliasArguments != null);
TypeImpl(this._element, {this.alias});
@Deprecated('Use alias instead')
@override
List<DartType>? get aliasArguments {
return alias?.typeArguments;
}
@Deprecated('Use alias instead')
@override
TypeAliasElement? get aliasElement {
return alias?.element;
}
@deprecated
@override
@ -1774,12 +1790,10 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
required TypeParameterElement element,
required this.nullabilitySuffix,
this.promotedBound,
TypeAliasElement? aliasElement,
List<DartType>? aliasArguments,
InstantiatedTypeAliasElement? alias,
}) : super(
element,
aliasElement: aliasElement,
aliasArguments: aliasArguments,
alias: alias,
);
@override

View file

@ -444,9 +444,13 @@ abstract class _TypeSubstitutor
var returnType = type.returnType.accept(inner);
var aliasArguments = type.aliasArguments;
var newAliasArguments =
aliasArguments != null ? _mapList(aliasArguments) : null;
var alias = type.alias;
var newAlias = alias != null
? InstantiatedTypeAliasElementImpl(
element: alias.element,
typeArguments: _mapList(alias.typeArguments),
)
: null;
if (useCounter == before) return type;
@ -455,8 +459,7 @@ abstract class _TypeSubstitutor
parameters: parameters,
returnType: returnType,
nullabilitySuffix: type.nullabilitySuffix,
aliasElement: type.aliasElement,
aliasArguments: newAliasArguments,
alias: newAlias,
);
}

View file

@ -38,8 +38,7 @@ class DemotionNonNullificationVisitor extends ReplacementVisitor {
return TypeParameterTypeImpl(
element: type.element,
nullabilitySuffix: newNullability ?? type.nullabilitySuffix,
aliasElement: type.aliasElement,
aliasArguments: type.aliasArguments,
alias: type.alias,
);
}
}

View file

@ -628,7 +628,7 @@ class TypeSystemImpl implements TypeSystem {
appendParameters(type.returnType);
type.parameters.map((p) => p.type).forEach(appendParameters);
// TODO(scheglov) https://github.com/dart-lang/sdk/issues/44218
type.aliasArguments?.forEach(appendParameters);
type.alias?.typeArguments.forEach(appendParameters);
} else if (type is InterfaceType) {
type.typeArguments.forEach(appendParameters);
}

View file

@ -144,7 +144,7 @@ class LegacyTypeAsserter extends GeneralizingAstVisitor<void> {
return;
}
type.aliasArguments?.forEach(_assertLegacyType);
type.alias?.typeArguments.forEach(_assertLegacyType);
if (type is TypeParameterType) {
_assertLegacyType(type.bound);

View file

@ -755,7 +755,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
// not report synthetic `dynamic` in place of an unresolved type.
if ((type.element == _nullType.element ||
(type.isDynamic && name == 'dynamic')) &&
type.aliasElement == null) {
type.alias == null) {
_errorReporter.reportErrorForNode(
HintCode.UNNECESSARY_QUESTION_MARK, node, [name]);
}
@ -1048,7 +1048,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
...element.typeParameters.map((tp) => tp.bound),
];
for (var type in signatureTypes) {
var aliasElement = type?.aliasElement;
var aliasElement = type?.alias?.element;
if (aliasElement != null && aliasElement.hasInternal) {
_errorReporter.reportErrorForNode(
HintCode.INVALID_EXPORT_OF_INTERNAL_ELEMENT_INDIRECTLY,

View file

@ -210,10 +210,10 @@ class TypeArgumentsVerifier {
List<TypeParameterElement> typeParameters;
List<DartType> typeArguments;
var aliasElement = type.aliasElement;
if (aliasElement != null) {
typeParameters = aliasElement.typeParameters;
typeArguments = type.aliasArguments!;
var alias = type.alias;
if (alias != null) {
typeParameters = alias.element.typeParameters;
typeArguments = alias.typeArguments;
} else if (type is InterfaceType) {
typeParameters = type.element.typeParameters;
typeArguments = type.typeArguments;
@ -277,8 +277,9 @@ class TypeArgumentsVerifier {
// Prepare type arguments for checking for super-bounded.
type = _typeSystem.replaceTopAndBottom(type);
if (type.aliasElement != null) {
typeArguments = type.aliasArguments!;
alias = type.alias;
if (alias != null) {
typeArguments = alias.typeArguments;
} else if (type is InterfaceType) {
typeArguments = type.typeArguments;
} else {
@ -422,9 +423,9 @@ class TypeArgumentsVerifier {
bool _isMissingTypeArguments(AstNode node, DartType type, Element? element,
Expression? inferenceContextNode) {
List<DartType> typeArguments;
var aliasElement = type.aliasElement;
if (aliasElement != null) {
typeArguments = type.aliasArguments!;
var alias = type.alias;
if (alias != null) {
typeArguments = alias.typeArguments;
} else if (type is InterfaceType) {
typeArguments = type.typeArguments;
} else {

View file

@ -1551,23 +1551,29 @@ class ResolutionReader {
parameters: type.parameters,
returnType: type.returnType,
nullabilitySuffix: type.nullabilitySuffix,
aliasElement: aliasElement,
aliasArguments: aliasArguments,
alias: InstantiatedTypeAliasElementImpl(
element: aliasElement,
typeArguments: aliasArguments,
),
);
} else if (type is InterfaceType) {
return InterfaceTypeImpl(
element: type.element,
typeArguments: type.typeArguments,
nullabilitySuffix: type.nullabilitySuffix,
aliasElement: aliasElement,
aliasArguments: aliasArguments,
alias: InstantiatedTypeAliasElementImpl(
element: aliasElement,
typeArguments: aliasArguments,
),
);
} else if (type is TypeParameterType) {
return TypeParameterTypeImpl(
element: type.element,
nullabilitySuffix: type.nullabilitySuffix,
aliasElement: aliasElement,
aliasArguments: aliasArguments,
alias: InstantiatedTypeAliasElementImpl(
element: aliasElement,
typeArguments: aliasArguments,
),
);
} else if (type is VoidType) {
// TODO(scheglov) add support for `void` aliasing

View file

@ -707,10 +707,10 @@ class ResolutionSink extends _SummaryDataWriter {
}
void _writeTypeAliasElementArguments(DartType type) {
var aliasElement = type.aliasElement;
_writeElement(aliasElement);
if (aliasElement != null) {
_writeTypeList(type.aliasArguments!);
var alias = type.alias;
_writeElement(alias?.element);
if (alias != null) {
_writeTypeList(alias.typeArguments);
}
}

View file

@ -1,5 +1,5 @@
name: analyzer
version: 2.0.0
version: 2.1.0-dev
description: This package provides a library that performs static analysis of Dart code.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer

View file

@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/element/nullability_eliminator.dart';
@ -155,13 +156,11 @@ class NullabilityEliminatorTest extends AbstractTypeSystemNullSafetyTest {
nullabilitySuffix: NullabilitySuffix.none,
);
expect(_typeToString(input), 'int Function()');
expect(input.aliasElement, same(A));
expect(input.aliasArguments!.map(_typeToString).join(', '), 'int');
_assertInstantiatedAlias(input, A, 'int');
var result = NullabilityEliminator.perform(typeProvider, input);
expect(_typeToString(result), 'int* Function()*');
expect(result.aliasElement, same(A));
expect(result.aliasArguments!.map(_typeToString).join(', '), 'int*');
_assertInstantiatedAlias(result, A, 'int*');
}
test_functionType_typeParameters() {
@ -278,8 +277,7 @@ class NullabilityEliminatorTest extends AbstractTypeSystemNullSafetyTest {
var result = NullabilityEliminator.perform(typeProvider, input);
expect(_typeToString(result), 'List<int*>*');
expect(result.aliasElement, same(A));
expect(result.aliasArguments!.map(_typeToString).join(', '), 'int*');
_assertInstantiatedAlias(result, A, 'int*');
}
test_interfaceType_int() {
@ -333,6 +331,13 @@ class NullabilityEliminatorTest extends AbstractTypeSystemNullSafetyTest {
_verifySame(typeProvider.voidType);
}
void _assertInstantiatedAlias(
DartType type, Element aliasElement, String aliasArguments) {
var alias = type.alias!;
expect(alias.element, same(aliasElement));
expect(alias.typeArguments.map(_typeToString).join(', '), aliasArguments);
}
String _typeToString(DartType type) {
return type.getDisplayString(withNullability: true);
}

View file

@ -754,8 +754,8 @@ mixin ResolutionTest implements ResourceProviderMixin {
required TypeAliasElement element,
required List<String> typeArguments,
}) {
assertElement2(type.aliasElement, declaration: element);
assertElementTypeStrings(type.aliasArguments, typeArguments);
assertElement2(type.alias?.element, declaration: element);
assertElementTypeStrings(type.alias?.typeArguments, typeArguments);
}
/// Assert that the given [identifier] is a reference to a type alias, in the

View file

@ -758,15 +758,14 @@ class _ElementWriter {
_writelnWithIndent('$typeStr');
}
var aliasElement = type.aliasElement;
var aliasArguments = type.aliasArguments;
if (aliasElement is TypeAliasElementImpl && aliasArguments != null) {
var alias = type.alias;
if (alias != null) {
_withIndent(() {
_createAstPrinter().writeElement('aliasElement', aliasElement);
_createAstPrinter().writeElement('aliasElement', alias.element);
_writeElements<DartType>(
'aliasArguments',
aliasArguments,
alias.typeArguments,
_writeType,
);
});

View file

@ -16762,8 +16762,8 @@ F<int> a;
var unit = library.definingCompilationUnit;
var type = unit.topLevelVariables[0].type as FunctionType;
expect(type.aliasElement, same(unit.typeAliases[0]));
_assertTypeStrings(type.aliasArguments!, ['int']);
expect(type.alias!.element, same(unit.typeAliases[0]));
_assertTypeStrings(type.alias!.typeArguments, ['int']);
}
test_functionTypeAlias_typeParameters_variance_contravariant() async {

View file

@ -1155,12 +1155,11 @@ class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
return false;
}
var aliasElement = type.aliasElement;
var aliasArguments = type.aliasArguments;
if (aliasElement != null && aliasArguments != null) {
var alias = type.alias;
if (alias != null) {
_writeTypeElementArguments(
element: aliasElement,
typeArguments: aliasArguments,
element: alias.element,
typeArguments: alias.typeArguments,
methodBeingCopied: methodBeingCopied,
);
_writeTypeNullability(type);