Skip to content

Commit

Permalink
Elements. Use TypeParameterElementImpl in TypeParameterizedElementMixin.
Browse files Browse the repository at this point in the history
Change-Id: Ic2617976c1099cd89ba73a81eee7c460bec79fd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403906
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
  • Loading branch information
scheglov authored and Commit Queue committed Jan 10, 2025
1 parent 92ef752 commit 0c103f1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
10 changes: 5 additions & 5 deletions pkg/analyzer/lib/src/dart/element/element.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5598,7 +5598,7 @@ abstract class InstanceElementImpl2 extends ElementImpl2
@override
List<TypeParameterElementImpl2> get typeParameters2 =>
firstFragment.typeParameters
.map((fragment) => (fragment as TypeParameterElementImpl).element)
.map((fragment) => fragment.element)
.toList();

@override
Expand Down Expand Up @@ -11035,7 +11035,7 @@ mixin TypeParameterizedElementMixin on ElementImpl
_ExistingElementImpl,
TypeParameterizedElement,
TypeParameterizedFragment {
List<TypeParameterElement> _typeParameters = const [];
List<TypeParameterElementImpl> _typeParameters = const [];

@override
List<Fragment> get children3 => children.whereType<Fragment>().toList();
Expand All @@ -11049,14 +11049,14 @@ mixin TypeParameterizedElementMixin on ElementImpl
ElementLinkedData? get linkedData;

@override
List<TypeParameterElement> get typeParameters {
List<TypeParameterElementImpl> get typeParameters {
linkedData?.read(this);
return _typeParameters;
}

set typeParameters(List<TypeParameterElement> typeParameters) {
set typeParameters(List<TypeParameterElementImpl> typeParameters) {
for (var typeParameter in typeParameters) {
(typeParameter as TypeParameterElementImpl).enclosingElement3 = this;
typeParameter.enclosingElement3 = this;
}
_typeParameters = typeParameters;
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/analyzer/lib/src/dart/element/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,9 @@ extension RecordTypeExtension on RecordType {
return null;
}
}

extension TypeParameterElementImplExtension on TypeParameterElementImpl {
bool get isWildcardVariable {
return name == '_' && library.hasWildcardVariablesFeatureEnabled;
}
}
4 changes: 2 additions & 2 deletions pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ class InheritanceManager3 {
result.isSynthetic = true;
result.parameters = transformedParameters;
result.returnType = executable.returnType;
result.typeParameters = executable.typeParameters;
result.typeParameters = executable.typeParameters.cast();
return result;
}

Expand Down Expand Up @@ -1138,7 +1138,7 @@ class InheritanceManager3 {
var result = MethodElementImpl(firstMethod.name, -1);
result.enclosingElement3 = targetClass;
result.name2 = fragmentName;
result.typeParameters = resultType.typeFormals;
result.typeParameters = resultType.typeFormals.cast();
result.returnType = resultType.returnType;
result.parameters = resultType.parameters.toImpl();
result.element = MethodElementImpl2(
Expand Down
6 changes: 3 additions & 3 deletions pkg/analyzer/lib/src/generated/testing/element_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ElementFactory {

static ClassElementImpl classElement3({
required String name,
List<TypeParameterElement>? typeParameters,
List<TypeParameterElementImpl>? typeParameters,
List<String> typeParameterNames = const [],
InterfaceType? supertype,
List<InterfaceType> mixins = const [],
Expand Down Expand Up @@ -246,7 +246,7 @@ class ElementFactory {

static MixinElementImpl mixinElement(
{required String name,
List<TypeParameterElement>? typeParameters,
List<TypeParameterElementImpl>? typeParameters,
List<String> typeParameterNames = const [],
List<InterfaceType> constraints = const [],
List<InterfaceType> interfaces = const [],
Expand Down Expand Up @@ -352,7 +352,7 @@ class ElementFactory {
return TypeParameterElementImpl(name, 0);
}

static List<TypeParameterElement> typeParameters(List<String> names) {
static List<TypeParameterElementImpl> typeParameters(List<String> names) {
return names.map((name) => typeParameterWithType(name)).toList();
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/summary2/variance_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class VarianceBuilder {
if (arguments.isNotEmpty) {
var parameters = element.typeParameters;
for (var i = 0; i < arguments.length && i < parameters.length; i++) {
var parameter = parameters[i] as TypeParameterElementImpl;
var parameter = parameters[i];
var parameterVariance = parameter.variance;
result = result.meet(
parameterVariance.combine(
Expand Down
8 changes: 4 additions & 4 deletions pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ class _MockSdkElementsBuilder {
_coreUnit.encloseElement(objectElement);
objectElement.interfaces = const <InterfaceType>[];
objectElement.mixins = const <InterfaceType>[];
objectElement.typeParameters = const <TypeParameterElement>[];
objectElement.typeParameters = const <TypeParameterElementImpl>[];
objectElement.constructors = [
_constructor(isConst: true),
];
Expand Down Expand Up @@ -974,7 +974,7 @@ class _MockSdkElementsBuilder {
ClassElementImpl _class({
required String name,
bool isAbstract = false,
List<TypeParameterElement> typeParameters = const [],
List<TypeParameterElementImpl> typeParameters = const [],
required CompilationUnitElementImpl unit,
}) {
var element = ClassElementImpl(name, 0);
Expand Down Expand Up @@ -1013,7 +1013,7 @@ class _MockSdkElementsBuilder {
FunctionElementImpl _function(
String name,
DartType returnType, {
List<TypeParameterElement> typeFormals = const [],
List<TypeParameterElementImpl> typeFormals = const [],
List<ParameterElementImpl> parameters = const [],
}) {
return FunctionElementImpl(name, 0)
Expand Down Expand Up @@ -1070,7 +1070,7 @@ class _MockSdkElementsBuilder {
MethodElementImpl _method(
String name,
DartType returnType, {
List<TypeParameterElement> typeFormals = const [],
List<TypeParameterElementImpl> typeFormals = const [],
List<ParameterElementImpl> parameters = const [],
}) {
return MethodElementImpl(name, 0)
Expand Down
12 changes: 6 additions & 6 deletions pkg/analyzer/test/generated/elements_types_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ mixin ElementsTypesMixin {
bool isAugmentation = false,
bool isSealed = false,
InterfaceType? superType,
List<TypeParameterElement> typeParameters = const [],
List<TypeParameterElementImpl> typeParameters = const [],
List<InterfaceType> interfaces = const [],
List<InterfaceType> mixins = const [],
List<MethodElementImpl> methods = const [],
Expand Down Expand Up @@ -186,7 +186,7 @@ mixin ElementsTypesMixin {
required DartType extendedType,
String? name,
bool isAugmentation = false,
List<TypeParameterElement> typeParameters = const [],
List<TypeParameterElementImpl> typeParameters = const [],
List<MethodElementImpl> methods = const [],
}) {
var element = ExtensionElementImpl(name, 0);
Expand All @@ -203,7 +203,7 @@ mixin ElementsTypesMixin {
String name, {
String representationName = 'it',
required DartType representationType,
List<TypeParameterElement> typeParameters = const [],
List<TypeParameterElementImpl> typeParameters = const [],
List<InterfaceType> interfaces = const [],
}) {
var fragment = ExtensionTypeElementImpl(name, -1);
Expand Down Expand Up @@ -401,7 +401,7 @@ mixin ElementsTypesMixin {
String name,
DartType returnType, {
bool isStatic = false,
List<TypeParameterElement> typeFormals = const [],
List<TypeParameterElementImpl> typeFormals = const [],
List<ParameterElementImpl> parameters = const [],
}) {
return MethodElementImpl(name, 0)
Expand All @@ -414,7 +414,7 @@ mixin ElementsTypesMixin {
MixinElementImpl mixin_({
required String name,
bool isAugmentation = false,
List<TypeParameterElement> typeParameters = const [],
List<TypeParameterElementImpl> typeParameters = const [],
List<InterfaceType>? constraints,
List<InterfaceType> interfaces = const [],
}) {
Expand Down Expand Up @@ -575,7 +575,7 @@ mixin ElementsTypesMixin {

TypeAliasElementImpl typeAlias({
required String name,
required List<TypeParameterElement> typeParameters,
required List<TypeParameterElementImpl> typeParameters,
required DartType aliasedType,
}) {
var element = TypeAliasElementImpl(name, 0);
Expand Down

0 comments on commit 0c103f1

Please sign in to comment.