Files
sdk/tests/language/closure/dynamic_closure_param_test.dart
Nate Biggs e8b8ecfd52 [dart2wasm] Fix signature selection for direct closure invocation.
Direct closure invocation on tearoffs was using the signature of the raw
member reference rather than the checked entry function. These don't
always have the same signature and therefore it was possible to generate
an invalid code by putting the incorrect # of parameters on the stack.

The added test fails prior to this fix when assertions are enabled.

Also include some small changes that helped with debugging this.

Change-Id: I8c50dca3999781213ea251c6ab97eb1eaf7d0c8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467500
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2025-12-11 00:32:20 -08:00

37 lines
658 B
Dart

// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
class Arg {}
abstract class Base<T> {
void foo(T a);
}
class A extends Base<Arg> {
@override
void foo(Arg a, [String? b]) {
print(a);
print(b);
}
}
class B extends A {
@override
void foo(Arg a, [String? b, int c = 0]) {
print(a);
print(b);
print(c);
}
}
void check(void Function(Arg) closure) {
closure(Arg());
}
void main() {
final closure = A().foo;
check(closure);
B().foo(Arg(), 'b', 3);
}