@@ -31,10 +31,6 @@ void expectInstances(dynamic value, dynamic expected, Compiler compiler) {
3131
3232  final  Equality <Object ?> equality;
3333  if  (compiler ==  Compiler .dart2js) {
34-     // Ignore comparing nonConstantLocations in web dills because it will have 
35-     // extra fields. 
36-     (value as  Map <String , Object ?>).remove ('nonConstantLocations' );
37-     (expected as  Map <String , Object ?>).remove ('nonConstantLocations' );
3834    equality =  const  Dart2JSDeepCollectionEquality ();
3935  } else  {
4036    equality =  const  DeepCollectionEquality ();
@@ -69,9 +65,7 @@ void _checkConsts(String dillPath, Compiler compiler) {
6965    classLibraryUri:  'package:const_finder_fixtures/target.dart' ,
7066    className:  'Target' ,
7167  );
72-   expectInstances (
73-     finder.findInstances (),
74-     < String , dynamic > {
68+   final  Map <String , Object ?> expectation =  < String , dynamic > {
7569      'constantInstances' :  < Map <String , dynamic >> [
7670        < String , dynamic > {'stringValue' :  '100' , 'intValue' :  100 , 'targetValue' :  null },
7771        < String , dynamic > {'stringValue' :  '102' , 'intValue' :  102 , 'targetValue' :  null },
@@ -95,7 +89,27 @@ void _checkConsts(String dillPath, Compiler compiler) {
9589        < String , dynamic > {'stringValue' :  'package' , 'intValue' : - 1 , 'targetValue' :  null },
9690      ],
9791      'nonConstantLocations' :  < dynamic > [],
98-     },
92+     };
93+   if  (compiler ==  Compiler .aot) {
94+     expectation['nonConstantLocations' ] =  < Object ? > [];
95+   } else  {
96+     final  String  fixturesUrl =  Platform .isWindows
97+       ?  '/$fixtures ' .replaceAll (Platform .pathSeparator, '/' )
98+       :  fixtures;
99+ 
100+     // Without true tree-shaking, there is a non-const reference in a 
101+     // never-invoked function that will be present in the dill. 
102+     expectation['nonConstantLocations' ] =  < Object ? > [
103+       < String , dynamic > {
104+         'file' :  'file://$fixturesUrl /pkg/package.dart' ,
105+         'line' :  14 ,
106+         'column' :  25 ,
107+       },
108+     ];
109+   }
110+   expectInstances (
111+     finder.findInstances (),
112+     expectation,
99113    compiler,
100114  );
101115
@@ -125,8 +139,9 @@ void _checkAnnotation(String dillPath, Compiler compiler) {
125139    annotationClassName:  'StaticIconProvider' ,
126140    annotationClassLibraryUri:  'package:const_finder_fixtures/static_icon_provider.dart' ,
127141  );
142+   final  Map <String , dynamic > instances =  finder.findInstances ();
128143  expectInstances (
129-     finder. findInstances () ,
144+     instances ,
130145    < String , dynamic > {
131146      'constantInstances' :  < Map <String , Object ?>> [
132147        < String , Object ? > {
@@ -140,6 +155,8 @@ void _checkAnnotation(String dillPath, Compiler compiler) {
140155          'targetValue' :  null ,
141156        },
142157      ],
158+       // TODO(fujino): This should have non-constant locations from the use of 
159+       // a tear-off, see https://github.com/flutter/flutter/issues/116797 
143160      'nonConstantLocations' :  < Object ? > [],
144161    },
145162    compiler,
@@ -212,6 +229,9 @@ void _checkNonConstsWeb(String dillPath, Compiler compiler) {
212229    className:  'Target' ,
213230  );
214231
232+   final  String  fixturesUrl =  Platform .isWindows
233+     ?  '/$fixtures ' .replaceAll (Platform .pathSeparator, '/' )
234+     :  fixtures;
215235  expectInstances (
216236    finder.findInstances (),
217237    < String , dynamic > {
@@ -225,7 +245,33 @@ void _checkNonConstsWeb(String dillPath, Compiler compiler) {
225245        < String , dynamic > {'stringValue' :  '7' , 'intValue' :  7 , 'targetValue' :  null },
226246        < String , dynamic > {'stringValue' :  'package' , 'intValue' :  - 1 , 'targetValue' :  null },
227247      ],
228-       'nonConstantLocations' :  < dynamic > []
248+       'nonConstantLocations' :  < dynamic > [
249+         < String , dynamic > {
250+           'file' :  'file://$fixturesUrl /lib/consts_and_non.dart' ,
251+           'line' :  14 ,
252+           'column' :  26 ,
253+         },
254+         < String , dynamic > {
255+           'file' :  'file://$fixturesUrl /lib/consts_and_non.dart' ,
256+           'line' :  16 ,
257+           'column' :  26 ,
258+         },
259+         < String , dynamic > {
260+           'file' :  'file://$fixturesUrl /lib/consts_and_non.dart' ,
261+           'line' :  16 ,
262+           'column' :  41 ,
263+         },
264+         < String , dynamic > {
265+           'file' :  'file://$fixturesUrl /lib/consts_and_non.dart' ,
266+           'line' :  17 ,
267+           'column' :  26 ,
268+         },
269+         < String , dynamic > {
270+           'file' :  'file://$fixturesUrl /pkg/package.dart' ,
271+           'line' :  14 ,
272+           'column' :  25 ,
273+         }
274+       ],
229275    },
230276    compiler,
231277  );
0 commit comments