diff --git a/pkg/dart2wasm/lib/io_util.dart b/pkg/dart2wasm/lib/io_util.dart index 2d8666a3f54..f57035fb857 100644 --- a/pkg/dart2wasm/lib/io_util.dart +++ b/pkg/dart2wasm/lib/io_util.dart @@ -127,7 +127,8 @@ class CompilerPhaseInputOutputManager { final wasmOptPath = options.wasmOptPath?.toFilePath() ?? 'wasm-opt'; final result = await _runProcess(wasmOptPath, args); if (result.exitCode != 0) { - throw Exception('wasm-opt failed with exit code ${result.exitCode}:' + throw Exception( + 'wasm-opt failed on module $inputModuleName with exit code ${result.exitCode}:' '\n${result.stdout}\n${result.stderr}'); } } diff --git a/pkg/dart2wasm/lib/translator.dart b/pkg/dart2wasm/lib/translator.dart index 6ce0069cd2e..64572748046 100644 --- a/pkg/dart2wasm/lib/translator.dart +++ b/pkg/dart2wasm/lib/translator.dart @@ -1695,10 +1695,13 @@ class Translator with KernelNodes { return null; } + final entryReference = + getFunctionEntry(member.reference, uncheckedEntry: false); + return SingleClosureTarget._( member, - paramInfoForDirectCall(member.reference), - signatureForDirectCall(member.reference), + paramInfoForDirectCall(entryReference), + signatureForDirectCall(entryReference), null, ); } else { diff --git a/pkg/dart2wasm/tool/compile_benchmark b/pkg/dart2wasm/tool/compile_benchmark index c1e900eeae8..f5aa8e28863 100755 --- a/pkg/dart2wasm/tool/compile_benchmark +++ b/pkg/dart2wasm/tool/compile_benchmark @@ -72,6 +72,7 @@ VM_ARGS=() DART2WASM_ARGS=("--require-js-string-builtin") DART_FILE="" OUTPUT_FILE="" +PHASES="" while [ $# -gt 0 ]; do case "$1" in --compile-benchmark=*) @@ -102,6 +103,11 @@ while [ $# -gt 0 ]; do shift ;; + --phases=*) + PHASES="${1#--phases=}" + shift + ;; + --extra-compiler-option=--platform=*) PLATFORM_FILENAME="${1#--extra-compiler-option=--platform=}" shift @@ -156,6 +162,10 @@ if [ -z "$DART_FILE" -o -z "$OUTPUT_FILE" ]; then exit 1 fi +if [ -z "$PHASES" ]; then + PHASES="cfe,tfa,codegen" +fi + PLATFORM_ARG="--platform=$PLATFORM_FILENAME" DART2WASM_AOT_SNAPSHOT="$BIN_DIR/$SNAPSHOT_NAME.snapshot" @@ -192,9 +202,9 @@ COMPILER_GZIP_SIZE=0 function run_compiler() { if [ $RUN_SRC -eq 1 ]; then - dart2wasm_command=("$DART" "${VM_ARGS[@]}" "$DART2WASM_SRC" "$LIBRARIES_JSON_ARG" "${DART2WASM_ARGS[@]}" "--phases=cfe,tfa,codegen" "$DART_FILE" "$OUTPUT_FILE") + dart2wasm_command=("$DART" "${VM_ARGS[@]}" "$DART2WASM_SRC" "$LIBRARIES_JSON_ARG" "${DART2WASM_ARGS[@]}" "--phases=$PHASES" "$DART_FILE" "$OUTPUT_FILE") else - dart2wasm_command=("$DART_AOT_RUNTIME" "${VM_ARGS[@]}" "$DART2WASM_AOT_SNAPSHOT" "$PLATFORM_ARG" "${DART2WASM_ARGS[@]}" "--phases=cfe,tfa,codegen" "$DART_FILE" "$OUTPUT_FILE") + dart2wasm_command=("$DART_AOT_RUNTIME" "${VM_ARGS[@]}" "$DART2WASM_AOT_SNAPSHOT" "$PLATFORM_ARG" "${DART2WASM_ARGS[@]}" "--phases=$PHASES" "$DART_FILE" "$OUTPUT_FILE") fi if [ -n "$COMPILE_BENCHMARK_BASE_NAME" ]; then diff --git a/tests/language/closure/dynamic_closure_param_test.dart b/tests/language/closure/dynamic_closure_param_test.dart new file mode 100644 index 00000000000..c16111ab5d9 --- /dev/null +++ b/tests/language/closure/dynamic_closure_param_test.dart @@ -0,0 +1,36 @@ +// 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 { + void foo(T a); +} + +class A extends Base { + @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); +}