-
Notifications
You must be signed in to change notification settings - Fork 15.9k
Update Message_index to account for oneof's #24181
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
base: main
Are you sure you want to change the base?
Conversation
|
@jez - could you rebase this? I doubt your changes are the reason C++ tests failed |
This is mostly patterned off of `Message_method_missing`, but that function does a bunch of extra stuff (to handle, e.g., `has_` and `clear_` and setter methods), while `Message_index` only needs to handle getter methods. So instead of copying the `Message_method_missing` implementation verbatim, we can "constant fold" away the parts of the method that we know cannot (or should not) happen for `msg[...]` calls.
|
@JasonLunn apologies, I rebased. I should have checked that before developing. |
|
The Ruby test failures look real - |
- method_missing is not a public API (doesn't work in the FFI version) - the kind of TypeError that they raise is different (`::TypeError` vs `::Google::Protobuf::TypeError`) Neither of these are what was broken, nor do we need to change anything about it, so I'm just omitting it from the test so that it can pass in FFI and non-FFI mode.
I've factored a helper function `get_which_oneof` to show that I modeled the implementation off of something that already exists, namely the generated `msg.my_oneof` methods (because `msg["my_oneof"]` should be the same), and to alert anyone making future changes that if they're changing one place, they almost certainly want their changes to apply to both places.
|
@JasonLunn I've added alternative implementations in the two files you mentioned. I tested that the FFI version in I was unable to get the Java version to run locally. If you can give me a bazel invocation that you expect to work to run the tests under JRuby locally, I would appreciate it. Otherwise, I guess I'll just await the GitHub Action results. |
|
|
||
| if (args.length == 1) { | ||
| // If we find a Oneof return it's name (use lookupOneof because it has an index) | ||
| IRubyObject oneofDescriptor = rubyDescriptor.lookupOneof(context, args[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of this declaration is causing the remaining code below, starting on line 409, to error out during Java compilation because oneofDescriptor is no longer declared.
|
Fixes #21736
This is mostly patterned off of
Message_method_missing, but that function does a bunch of extra stuff (to handle, e.g.,has_andclear_and setter methods), whileMessage_indexonly needs to handle getter methods. So instead of copying theMessage_method_missingimplementation verbatim, we can "constant fold" away the parts of the method that we know cannot (or should not) happen formsg[...]calls.Commit summary
Add test showing current behavior (72935ab)
A note: I struggled to get the test to fail when run via Bazel. e.g.
bazel test //ruby/tests/...would not cause this test to fail when I edited this test to intentionally be incorrect. By contrast, it would fail when I ran it viabundle exec rake test.I'm not sure whether that's because I'm using Bazel wrong locally, or whether there's something incorrect causing the tests to not actually execute when invoked via Bazel.
field→f(to match Message_method_missing) (640a776)This is a no-op style change that aligns one name with
Message_method_missing.Update Message_index to account for oneof's (df2d787)
In this commit, you can see the behavior change in the test.