@@ -151,15 +151,22 @@ int f() {
151151@reflectiveTest
152152class TypePropagationTest extends PubPackageResolutionTest {
153153 test_assignment_null () async {
154- String code = r'''
154+ await resolveTestCode ( r'''
155155main() {
156156 int v; // declare
157157 v = null;
158158 return v; // return
159- }''' ;
160- await resolveTestCode (code);
161- assertType (findElement.localVar ('v' ).type, 'int' );
162- assertType (findNode.simple ('v; // return' ), 'int' );
159+ }
160+ ''' );
161+
162+ var node = findNode.simple ('v; // return' );
163+ assertResolvedNodeText (node, r'''
164+ SimpleIdentifier
165+ token: v
166+ staticElement: v@15
167+ element: v@15
168+ staticType: int
169+ ''' );
163170 }
164171
165172 test_initializer_hasStaticType () async {
@@ -168,8 +175,15 @@ f() {
168175 int v = 0;
169176 return v;
170177}''' );
171- assertType (findElement.localVar ('v' ).type, 'int' );
172- assertType (findNode.simple ('v;' ), 'int' );
178+
179+ var node = findNode.simple ('v;' );
180+ assertResolvedNodeText (node, r'''
181+ SimpleIdentifier
182+ token: v
183+ staticElement: v@12
184+ element: v@12
185+ staticType: int
186+ ''' );
173187 }
174188
175189 test_initializer_hasStaticType_parameterized () async {
@@ -178,8 +192,15 @@ f() {
178192 List<int> v = <int>[];
179193 return v;
180194}''' );
181- assertType (findElement.localVar ('v' ).type, 'List<int>' );
182- assertType (findNode.simple ('v;' ), 'List<int>' );
195+
196+ var node = findNode.simple ('v;' );
197+ assertResolvedNodeText (node, r'''
198+ SimpleIdentifier
199+ token: v
200+ staticElement: v@18
201+ element: v@18
202+ staticType: List<int>
203+ ''' );
183204 }
184205
185206 test_initializer_null () async {
@@ -188,23 +209,36 @@ main() {
188209 int v = null;
189210 return v;
190211}''' );
191- assertType (findElement.localVar ('v' ).type, 'int' );
192- assertType (findNode.simple ('v;' ), 'int' );
212+
213+ var node = findNode.simple ('v;' );
214+ assertResolvedNodeText (node, r'''
215+ SimpleIdentifier
216+ token: v
217+ staticElement: v@15
218+ element: v@15
219+ staticType: int
220+ ''' );
193221 }
194222
195223 test_invocation_target_prefixed () async {
196224 newFile ('$testPackageLibPath /a.dart' , r'''
197225int max(int x, int y) => 0;
198226''' );
227+
199228 await resolveTestCode ('''
200229import 'a.dart' as helper;
201230main() {
202231 helper.max(10, 10); // marker
203232}''' );
204- assertElement (
205- findNode.simple ('max(10, 10)' ),
206- findElement.importFind ('package:test/a.dart' ).topFunction ('max' ),
207- );
233+
234+ var node = findNode.simple ('max(10, 10)' );
235+ assertResolvedNodeText (node, r'''
236+ SimpleIdentifier
237+ token: max
238+ staticElement: package:test/a.dart::<fragment>::@function::max
239+ element: package:test/a.dart::@function::max
240+ staticType: int Function(int, int)
241+ ''' );
208242 }
209243
210244 test_is_subclass () async {
@@ -219,10 +253,27 @@ A f(A p) {
219253 }
220254 return p;
221255}''' );
222- assertElement (
223- findNode.methodInvocation ('p.m()' ),
224- findElement.method ('m' , of: 'B' ),
225- );
256+
257+ var node = findNode.methodInvocation ('p.m()' );
258+ assertResolvedNodeText (node, r'''
259+ MethodInvocation
260+ target: SimpleIdentifier
261+ token: p
262+ staticElement: <testLibraryFragment>::@function::f::@parameter::p
263+ element: <testLibraryFragment>::@function::f::@parameter::p#element
264+ staticType: B
265+ operator: .
266+ methodName: SimpleIdentifier
267+ token: m
268+ staticElement: <testLibraryFragment>::@class::B::@method::m
269+ element: <testLibraryFragment>::@class::B::@method::m#element
270+ staticType: B Function()
271+ argumentList: ArgumentList
272+ leftParenthesis: (
273+ rightParenthesis: )
274+ staticInvokeType: B Function()
275+ staticType: B
276+ ''' );
226277 }
227278
228279 test_mutatedOutsideScope () async {
@@ -296,8 +347,15 @@ main() {
296347 dynamic toString = () => null;
297348 toString(); // marker
298349}''' );
299- assertTypeDynamic (findElement.localVar ('toString' ).type);
300- assertTypeDynamic (findNode.simple ('toString(); // marker' ));
350+
351+ var node = findNode.simple ('toString(); // marker' );
352+ assertResolvedNodeText (node, r'''
353+ SimpleIdentifier
354+ token: toString
355+ staticElement: toString@19
356+ element: toString@19
357+ staticType: dynamic
358+ ''' );
301359 }
302360
303361 @failingTest
0 commit comments