1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-08 12:06:26 +00:00
dart-sdk/runtime
Liam Appelbe dff831dbfc [ffi] Fix callback subtyping test
Previously we were reusing the ensureNativeTypeToDartType function to
check that Dart function passed as a callback matches the native type.
This works if the types exactly match, but the subtyping test is
backwards, so it doesn't allow certain cases that should be allowed. The
main case is that when the native function type returns void, the Dart
function should be allowed to return anything.

So I added ensureDartTypeToNativeType, which reverses the subtype test.

As well as making the return types more permissive, this has also
changed what parameters are allowed to be passed to callbacks. For
example, in tests/ffi/vmspecific_static_checks_typeddata_test.dart:80,
passing a Handle to a function expecting an Int8List used to work, but
is now a compile error. I think this change is an improvement, because
previously it would have been possible to pass any type of object to
that callback. So this change turns some potential runtime type errors
into compile errors. But technically I think this is a breaking change.

Fixes: https://github.com/dart-lang/sdk/issues/53659
Bug: https://github.com/dart-lang/sdk/issues/53659
Change-Id: I6846a59fc309ec897cba8f985d7dd0a63b912b42
TEST=tests/ffi/function_callbacks_subtype_test.dart and others
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346440
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-02-05 03:19:01 +00:00
..
bin [ffi] Fix callback subtyping test 2024-02-05 03:19:01 +00:00
docs [vm, gc] Mark through new-space. 2024-01-26 18:58:54 +00:00
include Expose Dart_Null_DL from dart_api_dl.h 2023-12-11 21:06:37 +00:00
lib [vm] Avoid allocation when printing type names. 2024-01-29 23:53:19 +00:00
observatory [ Service ] Remove steal_breakpoint_test.dart 2024-01-31 20:23:10 +00:00
platform [vm, gc] Mark through new-space. 2024-01-26 18:58:54 +00:00
tests [gardening] Skip test that requires aot on ia32. 2024-02-01 16:07:49 +00:00
tools [vm/ffi] Refactor dart:ffi generator 2024-02-02 18:11:00 +00:00
vm [vm/ffi] Update inner pointer accesses in IL 2024-02-01 18:28:53 +00:00
.clang-tidy
.gitignore
BUILD.gn [build] Omit SDK and Git hashes on RBE. 2023-12-20 12:23:56 +00:00
codereview.settings
configs.gni [Runtime] Add extra_product_deps and extra_nonproduct_deps params to "library_for_all_configs_with_compiler" template 2023-04-14 19:51:40 +00:00
CPPLINT.cfg [cpplint] Disable runtime/references lint 2023-01-23 18:21:48 +00:00
OWNERS
PRESUBMIT.py Reland "Reland "[VM] Begin supporting Perfetto file recorder"" 2023-04-18 19:39:05 +00:00
runtime_args.gni [vm] Cleanup old TODO. 2024-01-18 22:56:40 +00:00
vm-jit.shard.cml [test] Cleanup building Fuchsia packages/components. 2023-10-31 17:11:51 +00:00
vm.shard.cml [test] Cleanup building Fuchsia packages/components. 2023-10-31 17:11:51 +00:00