@@ -85,7 +85,205 @@ DotShorthandConstructorInvocation
85
85
substitution: {T: dynamic}
86
86
staticType: int
87
87
rightParenthesis: )
88
- staticType: C<dynamic>?
88
+ staticType: C<dynamic>
89
+ ''' );
90
+ }
91
+
92
+ test_equality () async {
93
+ await assertNoErrorsInCode (r'''
94
+ class C {
95
+ int x;
96
+ C.named(this.x);
97
+ }
98
+
99
+ void main() {
100
+ C lhs = C.named(2);
101
+ bool b = lhs == .named(1);
102
+ print(b);
103
+ }
104
+ ''' );
105
+
106
+ var identifier = findNode.singleDotShorthandConstructorInvocation;
107
+ assertResolvedNodeText (identifier, r'''
108
+ DotShorthandConstructorInvocation
109
+ period: .
110
+ constructorName: SimpleIdentifier
111
+ token: named
112
+ element: <testLibraryFragment>::@class::C::@constructor::named#element
113
+ staticType: null
114
+ argumentList: ArgumentList
115
+ leftParenthesis: (
116
+ arguments
117
+ IntegerLiteral
118
+ literal: 1
119
+ correspondingParameter: <testLibraryFragment>::@class::C::@constructor::named::@parameter::x#element
120
+ staticType: int
121
+ rightParenthesis: )
122
+ correspondingParameter: dart:core::<fragment>::@class::Object::@method::==::@parameter::other#element
123
+ staticType: C
124
+ ''' );
125
+ }
126
+
127
+ test_equality_inferTypeParameters () async {
128
+ await assertNoErrorsInCode ('''
129
+ void main() {
130
+ bool x = <int>[] == .filled(2, '2');
131
+ print(x);
132
+ }
133
+ ''' );
134
+
135
+ var identifier = findNode.singleDotShorthandConstructorInvocation;
136
+ assertResolvedNodeText (identifier, r'''
137
+ DotShorthandConstructorInvocation
138
+ period: .
139
+ constructorName: SimpleIdentifier
140
+ token: filled
141
+ element: ConstructorMember
142
+ baseElement: dart:core::<fragment>::@class::List::@constructor::filled#element
143
+ substitution: {E: String}
144
+ staticType: null
145
+ argumentList: ArgumentList
146
+ leftParenthesis: (
147
+ arguments
148
+ IntegerLiteral
149
+ literal: 2
150
+ correspondingParameter: ParameterMember
151
+ baseElement: dart:core::<fragment>::@class::List::@constructor::filled::@parameter::length#element
152
+ substitution: {E: String}
153
+ staticType: int
154
+ SimpleStringLiteral
155
+ literal: '2'
156
+ rightParenthesis: )
157
+ correspondingParameter: dart:core::<fragment>::@class::Object::@method::==::@parameter::other#element
158
+ staticType: List<String>
159
+ ''' );
160
+ }
161
+
162
+ @FailingTest (
163
+ issue: 'https://github.com/dart-lang/sdk/issues/59835' ,
164
+ reason:
165
+ 'Constant evaluation for dot shorthand constructor invocations needs '
166
+ 'to be implemented.' ,
167
+ )
168
+ test_equality_pattern () async {
169
+ await assertNoErrorsInCode (r'''
170
+ class C {
171
+ int x;
172
+ C.named(this.x);
173
+ }
174
+
175
+ void main() {
176
+ C c = C.named(1);
177
+ if (c case == .named(2)) print('ok');
178
+ }
179
+ ''' );
180
+
181
+ var identifier = findNode.singleDotShorthandConstructorInvocation;
182
+ assertResolvedNodeText (identifier, r'''
183
+ DotShorthandConstructorInvocation
184
+ period: .
185
+ constructorName: SimpleIdentifier
186
+ token: named
187
+ element: <testLibraryFragment>::@class::C::@constructor::named#element
188
+ staticType: null
189
+ argumentList: ArgumentList
190
+ leftParenthesis: (
191
+ arguments
192
+ IntegerLiteral
193
+ literal: 1
194
+ correspondingParameter: <testLibraryFragment>::@class::C::@constructor::named::@parameter::x#element
195
+ staticType: int
196
+ rightParenthesis: )
197
+ correspondingParameter: dart:core::<fragment>::@class::Object::@method::==::@parameter::other#element
198
+ staticType: C
199
+ ''' );
200
+ }
201
+
202
+ test_nested_invocation () async {
203
+ await assertNoErrorsInCode (r'''
204
+ class C<T> {
205
+ static C member() => C(1);
206
+ T x;
207
+ C(this.x);
208
+ }
209
+
210
+ void main() {
211
+ C<C> c = .new(.member());
212
+ print(c);
213
+ }
214
+ ''' );
215
+
216
+ var node = findNode.singleDotShorthandConstructorInvocation;
217
+ assertResolvedNodeText (node, r'''
218
+ DotShorthandConstructorInvocation
219
+ period: .
220
+ constructorName: SimpleIdentifier
221
+ token: new
222
+ element: ConstructorMember
223
+ baseElement: <testLibraryFragment>::@class::C::@constructor::new#element
224
+ substitution: {T: C<dynamic>}
225
+ staticType: null
226
+ argumentList: ArgumentList
227
+ leftParenthesis: (
228
+ arguments
229
+ DotShorthandInvocation
230
+ period: .
231
+ memberName: SimpleIdentifier
232
+ token: member
233
+ element: <testLibraryFragment>::@class::C::@method::member#element
234
+ staticType: C<dynamic> Function()
235
+ argumentList: ArgumentList
236
+ leftParenthesis: (
237
+ rightParenthesis: )
238
+ correspondingParameter: FieldFormalParameterMember
239
+ baseElement: <testLibraryFragment>::@class::C::@constructor::new::@parameter::x#element
240
+ substitution: {T: C<dynamic>}
241
+ staticInvokeType: C<dynamic> Function()
242
+ staticType: C<dynamic>
243
+ rightParenthesis: )
244
+ staticType: C<C<dynamic>>
245
+ ''' );
246
+ }
247
+
248
+ test_nested_property () async {
249
+ await assertNoErrorsInCode (r'''
250
+ class C<T> {
251
+ static C get member => C(1);
252
+ T x;
253
+ C(this.x);
254
+ }
255
+
256
+ void main() {
257
+ C<C> c = .new(.member);
258
+ print(c);
259
+ }
260
+ ''' );
261
+
262
+ var node = findNode.singleDotShorthandConstructorInvocation;
263
+ assertResolvedNodeText (node, r'''
264
+ DotShorthandConstructorInvocation
265
+ period: .
266
+ constructorName: SimpleIdentifier
267
+ token: new
268
+ element: ConstructorMember
269
+ baseElement: <testLibraryFragment>::@class::C::@constructor::new#element
270
+ substitution: {T: C<dynamic>}
271
+ staticType: null
272
+ argumentList: ArgumentList
273
+ leftParenthesis: (
274
+ arguments
275
+ DotShorthandPropertyAccess
276
+ period: .
277
+ propertyName: SimpleIdentifier
278
+ token: member
279
+ element: <testLibraryFragment>::@class::C::@getter::member#element
280
+ staticType: C<dynamic>
281
+ correspondingParameter: FieldFormalParameterMember
282
+ baseElement: <testLibraryFragment>::@class::C::@constructor::new::@parameter::x#element
283
+ substitution: {T: C<dynamic>}
284
+ staticType: C<dynamic>
285
+ rightParenthesis: )
286
+ staticType: C<C<dynamic>>
89
287
''' );
90
288
}
91
289
0 commit comments