[VM/Service] Ensure that wildcard_test.dart exercises the VM Service's `Frame` building code

The test didn't catch https://github.com/dart-lang/sdk/issues/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
https://github.com/dart-lang/sdk/commit/411ca9ceac3a762628e239bb6b32af7916e7d416
and fails without them.

Issue: https://github.com/dart-lang/sdk/issues/60121
Change-Id: I67b17b0b1656cb49fc72a9c695e2494b6d9dd184
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410220
Reviewed-by: Jessy Yameogo <yjessy@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
diff --git a/pkg/vm_service/test/wildcard_test.dart b/pkg/vm_service/test/wildcard_test.dart
index 3d87728..4271353 100644
--- a/pkg/vm_service/test/wildcard_test.dart
+++ b/pkg/vm_service/test/wildcard_test.dart
@@ -18,13 +18,17 @@
 import 'common/service_test_common.dart';
 import 'common/test_helper.dart';
 
-// ignore: duplicate_definition, avoid_types_as_parameter_names
-void foo<_>(i, _, _) {
-  final int _ = 42;
-  debugger();
-}
-
 void test() {
+  // We define an anonymous function instead of a named one because wildcard
+  // parameters can be optimized out of named functions by the compiler, so
+  // defining a named function would prevent this test from exercising the
+  // wildcard filtering logic in the VM Service's [Frame] building code.
+  // ignore: prefer_function_declarations_over_variables
+  final foo = <_>(i, _, _) {
+    final int _ = 42;
+    debugger();
+  };
+
   foo<String>(0, 1, 2);
 }
 
@@ -45,7 +49,7 @@
     final frame = stack.frames!.first;
     final function =
         await service.getObject(isolateId, frame.function!.id!) as Func;
-    expect(function.name, 'foo');
+    expect(function.name, '<anonymous closure>');
 
     // Type parameter names are replaced with synthetic names in general so we
     // don't need to check for the name '_' here.