overrider: report a registry mismatch instead of "cannot find method" - #112
Merged
Merged
Conversation
Since boostorg#96 a class can declare a registry of its own through `boost_openmethod_registry`, so an overrider whose class resolves to a different registry than the method's has parameters that simply do not convert - `virtual_ptr<Poodle, kennel_registry>` against `virtual_ptr<Animal, zoo_registry>`. The guide declared by BOOST_OPENMETHOD then fails to match, and BOOST_OPENMETHOD_OVERRIDE reported only that it "cannot find 'poke' method that accepts the same arguments as the overrider", which points nowhere near the cause. BOOST_OPENMETHOD now declares a second, relaxed guide beside the real one, `<id>_guide_any_registry`, driven by `enable_guide_ignoring_registry`: it rewrites every `virtual_ptr` parameter into the method's own registry, through `rebind_parameter_registry` and its reference forms, before trying the call. An overrider that matches that guide and not the strict one differs from the method in nothing but a registry. The guide never finds a method to call; it exists only to be asked. BOOST_OPENMETHOD_DETAIL_LOCATE_METHOD grows a rung under its existing fallback. The old generic static_assert moves into `..._explain_method_aux`, whose specialization fires when the relaxed guide succeeds and inherits `explain_overrider_mismatch`. That pairs the method's parameters with the overrider's through `validate_overrider_parameter` - the same instantiation a call through the thunk would perform - so the diagnosis is "registry mismatch", with both registries in the trace. The chain is now: strict guide, then the relaxed guide for the mismatch, then "cannot find". Diagnostics only: nothing that compiled before stops compiling. test/compile_fail_overrider_registry_mismatch.cpp covers it. The compile_fail glob has no CONFIGURE_DEPENDS, so a new file needs a manual cmake re-run before ctest sees it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
An automated preview of the documentation is available at https://112.openmethod.prtest3.cppalliance.org/libs/openmethod/doc/html/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-09-15 22:12:09 UTC |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #112 +/- ##
===========================================
- Coverage 93.51% 93.25% -0.26%
===========================================
Files 22 22
Lines 1695 1706 +11
Branches 504 509 +5
===========================================
+ Hits 1585 1591 +6
- Misses 66 71 +5
Partials 44 44
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Written by Claude Code, on behalf of @jll63.)
Diagnostics only — nothing that compiled before stops compiling.
The problem
Since #96 a class can declare a registry of its own through
boost_openmethod_registry. An overrider whose class resolves to a different registry than the method's therefore has parameters that simply do not convert —virtual_ptr<Poodle, kennel_registry>againstvirtual_ptr<Animal, zoo_registry>. The guide declared byBOOST_OPENMETHODfails to match, andBOOST_OPENMETHOD_OVERRIDEreported only:which points nowhere near the cause. With this change:
and the instantiation trace names both registries — clang spells it
std::is_same_v<zoo_registry, kennel_registry>.How
BOOST_OPENMETHODdeclares a second, relaxed guide beside the real one,<id>_guide_any_registry, driven byenable_guide_ignoring_registry: it rewrites everyvirtual_ptrparameter into the method's own registry (rebind_parameter_registry, plus its reference forms) before trying the call. An overrider that matches that guide and not the strict one differs from the method in nothing but a registry. The guide never finds a method to call; it exists only to be asked.BOOST_OPENMETHOD_DETAIL_LOCATE_METHODgrows a rung under its existing fallback. The old genericstatic_assertmoves into..._explain_method_aux, whose specialization fires when the relaxed guide succeeds and inheritsexplain_overrider_mismatch. That pairs the method's parameters with the overrider's throughvalidate_overrider_parameter— the same instantiation a call through the thunk would perform — so the diagnosis is the one the user would have got had the guide not failed first. The chain is now: strict guide → relaxed guide (registry mismatch) → "cannot find".Tests
test/compile_fail_overrider_registry_mismatch.cpp, expectingregistry mismatch.compile_fail_override_method_not_found.cppstill produces the old generic message, deliberately: that is the proof a genuinely absent method is unaffected.Verified on the tree as committed:
-DBOOST_OPENMETHOD_ENABLE_REFLECTION=ON -DBUILD_SHARED_LIBS=ON— 192/192Note for anyone building this locally: the
compile_fail_*.cppglob has noCONFIGURE_DEPENDS, so the new file needs a manualcmakere-run beforectestsees it.🤖 Generated with Claude Code