Skip to content

Commit 0c103f1

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Use TypeParameterElementImpl in TypeParameterizedElementMixin.
Change-Id: Ic2617976c1099cd89ba73a81eee7c460bec79fd7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403906 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 92ef752 commit 0c103f1

File tree

7 files changed

+27
-21
lines changed

7 files changed

+27
-21
lines changed

pkg/analyzer/lib/src/dart/element/element.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5598,7 +5598,7 @@ abstract class InstanceElementImpl2 extends ElementImpl2
55985598
@override
55995599
List<TypeParameterElementImpl2> get typeParameters2 =>
56005600
firstFragment.typeParameters
5601-
.map((fragment) => (fragment as TypeParameterElementImpl).element)
5601+
.map((fragment) => fragment.element)
56025602
.toList();
56035603

56045604
@override
@@ -11035,7 +11035,7 @@ mixin TypeParameterizedElementMixin on ElementImpl
1103511035
_ExistingElementImpl,
1103611036
TypeParameterizedElement,
1103711037
TypeParameterizedFragment {
11038-
List<TypeParameterElement> _typeParameters = const [];
11038+
List<TypeParameterElementImpl> _typeParameters = const [];
1103911039

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

1105111051
@override
11052-
List<TypeParameterElement> get typeParameters {
11052+
List<TypeParameterElementImpl> get typeParameters {
1105311053
linkedData?.read(this);
1105411054
return _typeParameters;
1105511055
}
1105611056

11057-
set typeParameters(List<TypeParameterElement> typeParameters) {
11057+
set typeParameters(List<TypeParameterElementImpl> typeParameters) {
1105811058
for (var typeParameter in typeParameters) {
11059-
(typeParameter as TypeParameterElementImpl).enclosingElement3 = this;
11059+
typeParameter.enclosingElement3 = this;
1106011060
}
1106111061
_typeParameters = typeParameters;
1106211062
}

pkg/analyzer/lib/src/dart/element/extensions.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,9 @@ extension RecordTypeExtension on RecordType {
286286
return null;
287287
}
288288
}
289+
290+
extension TypeParameterElementImplExtension on TypeParameterElementImpl {
291+
bool get isWildcardVariable {
292+
return name == '_' && library.hasWildcardVariablesFeatureEnabled;
293+
}
294+
}

pkg/analyzer/lib/src/dart/element/inheritance_manager3.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ class InheritanceManager3 {
10681068
result.isSynthetic = true;
10691069
result.parameters = transformedParameters;
10701070
result.returnType = executable.returnType;
1071-
result.typeParameters = executable.typeParameters;
1071+
result.typeParameters = executable.typeParameters.cast();
10721072
return result;
10731073
}
10741074

@@ -1138,7 +1138,7 @@ class InheritanceManager3 {
11381138
var result = MethodElementImpl(firstMethod.name, -1);
11391139
result.enclosingElement3 = targetClass;
11401140
result.name2 = fragmentName;
1141-
result.typeParameters = resultType.typeFormals;
1141+
result.typeParameters = resultType.typeFormals.cast();
11421142
result.returnType = resultType.returnType;
11431143
result.parameters = resultType.parameters.toImpl();
11441144
result.element = MethodElementImpl2(

pkg/analyzer/lib/src/generated/testing/element_factory.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class ElementFactory {
6464

6565
static ClassElementImpl classElement3({
6666
required String name,
67-
List<TypeParameterElement>? typeParameters,
67+
List<TypeParameterElementImpl>? typeParameters,
6868
List<String> typeParameterNames = const [],
6969
InterfaceType? supertype,
7070
List<InterfaceType> mixins = const [],
@@ -246,7 +246,7 @@ class ElementFactory {
246246

247247
static MixinElementImpl mixinElement(
248248
{required String name,
249-
List<TypeParameterElement>? typeParameters,
249+
List<TypeParameterElementImpl>? typeParameters,
250250
List<String> typeParameterNames = const [],
251251
List<InterfaceType> constraints = const [],
252252
List<InterfaceType> interfaces = const [],
@@ -352,7 +352,7 @@ class ElementFactory {
352352
return TypeParameterElementImpl(name, 0);
353353
}
354354

355-
static List<TypeParameterElement> typeParameters(List<String> names) {
355+
static List<TypeParameterElementImpl> typeParameters(List<String> names) {
356356
return names.map((name) => typeParameterWithType(name)).toList();
357357
}
358358

pkg/analyzer/lib/src/summary2/variance_builder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class VarianceBuilder {
8686
if (arguments.isNotEmpty) {
8787
var parameters = element.typeParameters;
8888
for (var i = 0; i < arguments.length && i < parameters.length; i++) {
89-
var parameter = parameters[i] as TypeParameterElementImpl;
89+
var parameter = parameters[i];
9090
var parameterVariance = parameter.variance;
9191
result = result.meet(
9292
parameterVariance.combine(

pkg/analyzer/lib/src/test_utilities/mock_sdk_elements.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ class _MockSdkElementsBuilder {
623623
_coreUnit.encloseElement(objectElement);
624624
objectElement.interfaces = const <InterfaceType>[];
625625
objectElement.mixins = const <InterfaceType>[];
626-
objectElement.typeParameters = const <TypeParameterElement>[];
626+
objectElement.typeParameters = const <TypeParameterElementImpl>[];
627627
objectElement.constructors = [
628628
_constructor(isConst: true),
629629
];
@@ -974,7 +974,7 @@ class _MockSdkElementsBuilder {
974974
ClassElementImpl _class({
975975
required String name,
976976
bool isAbstract = false,
977-
List<TypeParameterElement> typeParameters = const [],
977+
List<TypeParameterElementImpl> typeParameters = const [],
978978
required CompilationUnitElementImpl unit,
979979
}) {
980980
var element = ClassElementImpl(name, 0);
@@ -1013,7 +1013,7 @@ class _MockSdkElementsBuilder {
10131013
FunctionElementImpl _function(
10141014
String name,
10151015
DartType returnType, {
1016-
List<TypeParameterElement> typeFormals = const [],
1016+
List<TypeParameterElementImpl> typeFormals = const [],
10171017
List<ParameterElementImpl> parameters = const [],
10181018
}) {
10191019
return FunctionElementImpl(name, 0)
@@ -1070,7 +1070,7 @@ class _MockSdkElementsBuilder {
10701070
MethodElementImpl _method(
10711071
String name,
10721072
DartType returnType, {
1073-
List<TypeParameterElement> typeFormals = const [],
1073+
List<TypeParameterElementImpl> typeFormals = const [],
10741074
List<ParameterElementImpl> parameters = const [],
10751075
}) {
10761076
return MethodElementImpl(name, 0)

pkg/analyzer/test/generated/elements_types_mixin.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ mixin ElementsTypesMixin {
123123
bool isAugmentation = false,
124124
bool isSealed = false,
125125
InterfaceType? superType,
126-
List<TypeParameterElement> typeParameters = const [],
126+
List<TypeParameterElementImpl> typeParameters = const [],
127127
List<InterfaceType> interfaces = const [],
128128
List<InterfaceType> mixins = const [],
129129
List<MethodElementImpl> methods = const [],
@@ -186,7 +186,7 @@ mixin ElementsTypesMixin {
186186
required DartType extendedType,
187187
String? name,
188188
bool isAugmentation = false,
189-
List<TypeParameterElement> typeParameters = const [],
189+
List<TypeParameterElementImpl> typeParameters = const [],
190190
List<MethodElementImpl> methods = const [],
191191
}) {
192192
var element = ExtensionElementImpl(name, 0);
@@ -203,7 +203,7 @@ mixin ElementsTypesMixin {
203203
String name, {
204204
String representationName = 'it',
205205
required DartType representationType,
206-
List<TypeParameterElement> typeParameters = const [],
206+
List<TypeParameterElementImpl> typeParameters = const [],
207207
List<InterfaceType> interfaces = const [],
208208
}) {
209209
var fragment = ExtensionTypeElementImpl(name, -1);
@@ -401,7 +401,7 @@ mixin ElementsTypesMixin {
401401
String name,
402402
DartType returnType, {
403403
bool isStatic = false,
404-
List<TypeParameterElement> typeFormals = const [],
404+
List<TypeParameterElementImpl> typeFormals = const [],
405405
List<ParameterElementImpl> parameters = const [],
406406
}) {
407407
return MethodElementImpl(name, 0)
@@ -414,7 +414,7 @@ mixin ElementsTypesMixin {
414414
MixinElementImpl mixin_({
415415
required String name,
416416
bool isAugmentation = false,
417-
List<TypeParameterElement> typeParameters = const [],
417+
List<TypeParameterElementImpl> typeParameters = const [],
418418
List<InterfaceType>? constraints,
419419
List<InterfaceType> interfaces = const [],
420420
}) {
@@ -575,7 +575,7 @@ mixin ElementsTypesMixin {
575575

576576
TypeAliasElementImpl typeAlias({
577577
required String name,
578-
required List<TypeParameterElement> typeParameters,
578+
required List<TypeParameterElementImpl> typeParameters,
579579
required DartType aliasedType,
580580
}) {
581581
var element = TypeAliasElementImpl(name, 0);

0 commit comments

Comments
 (0)