Skip to content

Commit ed209fb

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate runtime_type_equality_test
Change-Id: I49a15e55fc4af8686eca070bf2a33811ad82a718 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/405402 Auto-Submit: Phil Quitslund <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent f77e9ba commit ed209fb

File tree

2 files changed

+83
-33
lines changed

2 files changed

+83
-33
lines changed

pkg/analyzer/test/generated/elements_types_mixin.dart

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,17 @@ mixin ElementsTypesMixin {
256256
);
257257
}
258258

259+
FunctionTypeImpl functionTypeNone2({
260+
List<TypeParameterElement2> typeFormals = const [],
261+
List<FormalParameterElement> parameters = const [],
262+
required DartType returnType,
263+
}) {
264+
return functionTypeNone(
265+
parameters: parameters.map((e) => e.asElement).toList(),
266+
typeFormals: typeFormals.map((e) => e.asElement).toList(),
267+
returnType: returnType);
268+
}
269+
259270
FunctionTypeImpl functionTypeQuestion({
260271
List<TypeParameterElement> typeFormals = const [],
261272
List<ParameterElement> parameters = const [],
@@ -453,6 +464,15 @@ mixin ElementsTypesMixin {
453464
return parameter;
454465
}
455466

467+
FormalParameterElement namedParameter2({
468+
required String name,
469+
required TypeImpl type,
470+
bool isCovariant = false,
471+
}) {
472+
return namedParameter(name: name, type: type, isCovariant: isCovariant)
473+
.asElement2;
474+
}
475+
456476
ParameterElementImpl namedRequiredParameter({
457477
required String name,
458478
required TypeImpl type,
@@ -468,6 +488,16 @@ mixin ElementsTypesMixin {
468488
return parameter;
469489
}
470490

491+
FormalParameterElement namedRequiredParameter2({
492+
required String name,
493+
required TypeImpl type,
494+
bool isCovariant = false,
495+
}) {
496+
return namedRequiredParameter(
497+
name: name, type: type, isCovariant: isCovariant)
498+
.asElement2;
499+
}
500+
471501
ParameterElementImpl positionalParameter({
472502
String? name,
473503
required TypeImpl type,
@@ -485,6 +515,19 @@ mixin ElementsTypesMixin {
485515
return parameter;
486516
}
487517

518+
FormalParameterElement positionalParameter2({
519+
String? name,
520+
required TypeImpl type,
521+
bool isCovariant = false,
522+
String? defaultValueCode,
523+
}) {
524+
return positionalParameter(
525+
type: type,
526+
isCovariant: isCovariant,
527+
defaultValueCode: defaultValueCode)
528+
.asElement2;
529+
}
530+
488531
TypeParameterTypeImpl promotedTypeParameterType({
489532
required TypeParameterElement element,
490533
required NullabilitySuffix nullabilitySuffix,
@@ -587,6 +630,15 @@ mixin ElementsTypesMixin {
587630
return parameter;
588631
}
589632

633+
FormalParameterElement requiredParameter2({
634+
String? name,
635+
required TypeImpl type,
636+
bool isCovariant = false,
637+
}) {
638+
return requiredParameter(name: name, type: type, isCovariant: isCovariant)
639+
.asElement2;
640+
}
641+
590642
TypeAliasElementImpl typeAlias({
591643
required String name,
592644
required List<TypeParameterElementImpl> typeParameters,

pkg/analyzer/test/src/dart/element/runtime_type_equality_test.dart

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// ignore_for_file: analyzer_use_new_elements
6-
7-
import 'package:analyzer/dart/element/element.dart';
5+
import 'package:analyzer/dart/element/element2.dart';
86
import 'package:analyzer/dart/element/type.dart';
97
import 'package:analyzer/src/dart/element/type.dart';
108
import 'package:test/test.dart';
@@ -39,15 +37,15 @@ class RuntimeTypeEqualityTypeTest extends AbstractTypeSystemTest
3937

4038
test_functionType_parameters() {
4139
void check(
42-
ParameterElement T1_parameter,
43-
ParameterElement T2_parameter,
40+
FormalParameterElement T1_parameter,
41+
FormalParameterElement T2_parameter,
4442
bool expected,
4543
) {
46-
var T1 = functionTypeNone(
44+
var T1 = functionTypeNone2(
4745
returnType: voidNone,
4846
parameters: [T1_parameter],
4947
);
50-
var T2 = functionTypeNone(
48+
var T2 = functionTypeNone2(
5149
returnType: voidNone,
5250
parameters: [T2_parameter],
5351
);
@@ -61,8 +59,8 @@ class RuntimeTypeEqualityTypeTest extends AbstractTypeSystemTest
6159
bool expected,
6260
) {
6361
check(
64-
requiredParameter(type: T1_type),
65-
requiredParameter(type: T2_type),
62+
requiredParameter2(type: T1_type),
63+
requiredParameter2(type: T2_type),
6664
expected,
6765
);
6866
}
@@ -74,78 +72,78 @@ class RuntimeTypeEqualityTypeTest extends AbstractTypeSystemTest
7472
checkRequiredParameter(intQuestion, intQuestion, true);
7573

7674
check(
77-
requiredParameter(type: intNone, name: 'a'),
78-
requiredParameter(type: intNone, name: 'b'),
75+
requiredParameter2(type: intNone, name: 'a'),
76+
requiredParameter2(type: intNone, name: 'b'),
7977
true,
8078
);
8179

8280
check(
83-
requiredParameter(type: intNone),
84-
positionalParameter(type: intNone),
81+
requiredParameter2(type: intNone),
82+
positionalParameter2(type: intNone),
8583
false,
8684
);
8785

8886
check(
89-
requiredParameter(type: intNone),
90-
namedParameter(type: intNone, name: 'a'),
87+
requiredParameter2(type: intNone),
88+
namedParameter2(type: intNone, name: 'a'),
9189
false,
9290
);
9391

9492
check(
95-
requiredParameter(type: intNone),
96-
namedRequiredParameter(type: intNone, name: 'a'),
93+
requiredParameter2(type: intNone),
94+
namedRequiredParameter2(type: intNone, name: 'a'),
9795
false,
9896
);
9997
}
10098

10199
{
102100
check(
103-
namedParameter(type: intNone, name: 'a'),
104-
namedParameter(type: intNone, name: 'a'),
101+
namedParameter2(type: intNone, name: 'a'),
102+
namedParameter2(type: intNone, name: 'a'),
105103
true,
106104
);
107105

108106
check(
109-
namedParameter(type: intNone, name: 'a'),
110-
namedParameter(type: boolNone, name: 'a'),
107+
namedParameter2(type: intNone, name: 'a'),
108+
namedParameter2(type: boolNone, name: 'a'),
111109
false,
112110
);
113111

114112
check(
115-
namedParameter(type: intNone, name: 'a'),
116-
namedParameter(type: intNone, name: 'b'),
113+
namedParameter2(type: intNone, name: 'a'),
114+
namedParameter2(type: intNone, name: 'b'),
117115
false,
118116
);
119117

120118
check(
121-
namedParameter(type: intNone, name: 'a'),
122-
namedRequiredParameter(type: intNone, name: 'a'),
119+
namedParameter2(type: intNone, name: 'a'),
120+
namedRequiredParameter2(type: intNone, name: 'a'),
123121
false,
124122
);
125123
}
126124

127125
{
128126
check(
129-
namedRequiredParameter(type: intNone, name: 'a'),
130-
namedRequiredParameter(type: intNone, name: 'a'),
127+
namedRequiredParameter2(type: intNone, name: 'a'),
128+
namedRequiredParameter2(type: intNone, name: 'a'),
131129
true,
132130
);
133131

134132
check(
135-
namedRequiredParameter(type: intNone, name: 'a'),
136-
namedRequiredParameter(type: boolNone, name: 'a'),
133+
namedRequiredParameter2(type: intNone, name: 'a'),
134+
namedRequiredParameter2(type: boolNone, name: 'a'),
137135
false,
138136
);
139137

140138
check(
141-
namedRequiredParameter(type: intNone, name: 'a'),
142-
namedRequiredParameter(type: intNone, name: 'b'),
139+
namedRequiredParameter2(type: intNone, name: 'a'),
140+
namedRequiredParameter2(type: intNone, name: 'b'),
143141
false,
144142
);
145143

146144
check(
147-
namedRequiredParameter(type: intNone, name: 'a'),
148-
namedParameter(type: intNone, name: 'a'),
145+
namedRequiredParameter2(type: intNone, name: 'a'),
146+
namedParameter2(type: intNone, name: 'a'),
149147
false,
150148
);
151149
}

0 commit comments

Comments
 (0)