@@ -195,6 +195,8 @@ void main() {
195
195
@VisibleClass.secret()
196
196
@fieldOnly
197
197
@ClassWithStaticField.staticField
198
+ @Wrapper(someFunction)
199
+ @Wrapper(Wrapper.someFunction)
198
200
class Example {}
199
201
200
202
class Int64Like {
@@ -238,6 +240,14 @@ void main() {
238
240
static const staticField = const ClassWithStaticField._();
239
241
const ClassWithStaticField._();
240
242
}
243
+
244
+ class Wrapper {
245
+ static void someFunction(int x, String y) {}
246
+ final Function f;
247
+ const Wrapper(this.f);
248
+ }
249
+
250
+ void someFunction(int x, String y) {}
241
251
''' , (resolver) => resolver.findLibraryByName ('test_lib' ));
242
252
constants = library
243
253
.getType ('Example' )
@@ -293,5 +303,17 @@ void main() {
293
303
expect (fieldOnly.source.fragment, isEmpty);
294
304
expect (fieldOnly.accessor, 'ClassWithStaticField.staticField' );
295
305
});
306
+
307
+ test ('should decode top-level functions' , () {
308
+ final fieldOnly = constants[7 ].read ('f' ).revive ();
309
+ expect (fieldOnly.source.fragment, isEmpty);
310
+ expect (fieldOnly.accessor, 'someFunction' );
311
+ });
312
+
313
+ test ('should decode static-class functions' , () {
314
+ final fieldOnly = constants[8 ].read ('f' ).revive ();
315
+ expect (fieldOnly.source.fragment, isEmpty);
316
+ expect (fieldOnly.accessor, 'Wrapper.someFunction' );
317
+ });
296
318
});
297
319
}
0 commit comments