Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cleanup] Accept Variant<...> instead of ObjectRef when possible #17095

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lunderberg
Copy link
Contributor

Prior to the implementation of Variant<...> in #15672, functions that were polymorphic over an argument type would typically accept an ObjectRef argument, then downcast to an allowed type. This delays the catching of an error, and can accidentally omit automatic conversions applied by the FFI.

This commit updates several locations using this pattern to instead accept a Variant, templated over the allowed types. This enables C++ type checking for C++ callers, standardizes the type-checking in the FFI for non-C++ callers, and ensures that FFI type conversions are uniformly applied.

@Lunderberg
Copy link
Contributor Author

This change is split out from #16183 as an independent change for ease of review.

Prior to the implementation of `Variant<...>` in
apache#15672, functions that were
polymorphic over an argument type would typically accept an
`ObjectRef` argument, then downcast to an allowed type.  This delays
the catching of an error, and can accidentally omit automatic
conversions applied by the FFI.

This commit updates several locations using this pattern to instead
accept a `Variant`, templated over the allowed types.  This enables
C++ type checking for C++ callers, standardizes the type-checking in
the FFI for non-C++ callers, and ensures that FFI type conversions are
uniformly applied.
@Lunderberg Lunderberg force-pushed the variant_argument_instead_of_objectref branch from f9a9b84 to f6ec978 Compare June 14, 2024 20:43
@Lunderberg Lunderberg requested a review from Hzfengsy June 18, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant