mirror of
https://github.com/dart-lang/sdk
synced 2024-07-08 12:06:26 +00:00
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> |
||
---|---|---|
.. | ||
bin | ||
docs | ||
include | ||
lib | ||
observatory | ||
platform | ||
tests | ||
tools | ||
vm | ||
.clang-tidy | ||
.gitignore | ||
BUILD.gn | ||
codereview.settings | ||
configs.gni | ||
CPPLINT.cfg | ||
OWNERS | ||
PRESUBMIT.py | ||
runtime_args.gni | ||
vm-jit.shard.cml | ||
vm.shard.cml |