Skip to content

Commit c339839

Browse files
derekxu16Commit Queue
authored andcommitted
[VM/Service] Ensure that wildcard_test.dart exercises the VM Service's Frame building code
The test didn't catch #60121 because it was defining a named function and the compiler can optimize wildcard parameters out of named functions. TEST=confirmed that wildcard_test test passes with the changes in 411ca9c and fails without them. Issue: #60121 Change-Id: I67b17b0b1656cb49fc72a9c695e2494b6d9dd184 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410220 Reviewed-by: Jessy Yameogo <[email protected]> Commit-Queue: Derek Xu <[email protected]>
1 parent 64a9566 commit c339839

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pkg/vm_service/test/wildcard_test.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,17 @@ import 'package:vm_service/vm_service.dart';
1818
import 'common/service_test_common.dart';
1919
import 'common/test_helper.dart';
2020

21-
// ignore: duplicate_definition, avoid_types_as_parameter_names
22-
void foo<_>(i, _, _) {
23-
final int _ = 42;
24-
debugger();
25-
}
26-
2721
void test() {
22+
// We define an anonymous function instead of a named one because wildcard
23+
// parameters can be optimized out of named functions by the compiler, so
24+
// defining a named function would prevent this test from exercising the
25+
// wildcard filtering logic in the VM Service's [Frame] building code.
26+
// ignore: prefer_function_declarations_over_variables
27+
final foo = <_>(i, _, _) {
28+
final int _ = 42;
29+
debugger();
30+
};
31+
2832
foo<String>(0, 1, 2);
2933
}
3034

@@ -45,7 +49,7 @@ final tests = <IsolateTest>[
4549
final frame = stack.frames!.first;
4650
final function =
4751
await service.getObject(isolateId, frame.function!.id!) as Func;
48-
expect(function.name, 'foo');
52+
expect(function.name, '<anonymous closure>');
4953

5054
// Type parameter names are replaced with synthetic names in general so we
5155
// don't need to check for the name '_' here.

0 commit comments

Comments
 (0)