Skip to content

overrider: report a registry mismatch instead of "cannot find method" - #112

Merged
jll63 merged 1 commit into
boostorg:developfrom
jll63:fix/overrider-registry-diagnostic
Sep 16, 2026
Merged

jll63 merged 1 commit into
boostorg:developfrom
jll63:fix/overrider-registry-diagnostic

Conversation

@jll63

@jll63 jll63 commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

(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> against virtual_ptr<Animal, zoo_registry>. The guide declared by BOOST_OPENMETHOD fails to match, and BOOST_OPENMETHOD_OVERRIDE reported only:

cannot find 'poke' method that accepts the same arguments as the overrider

which points nowhere near the cause. With this change:

static assertion failed: registry mismatch

and the instantiation trace names both registries — clang spells it std::is_same_v<zoo_registry, kennel_registry>.

How

BOOST_OPENMETHOD 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 (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_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 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, expecting registry mismatch.

compile_fail_override_method_not_found.cpp still produces the old generic message, deliberately: that is the proof a genuinely absent method is unaffected.

Verified on the tree as committed:

  • gcc 13, Debug — 186/186
  • g++-16, -DBOOST_OPENMETHOD_ENABLE_REFLECTION=ON -DBUILD_SHARED_LIBS=ON — 192/192
  • compile-fail diagnostics also matched under clang 18

Note for anyone building this locally: the compile_fail_*.cpp glob has no CONFIGURE_DEPENDS, so the new file needs a manual cmake re-run before ctest sees it.

🤖 Generated with Claude Code

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>
@cppalliance-bot

Copy link
Copy Markdown

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

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.25%. Comparing base (d44aa59) to head (e89fe7c).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             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              
Files with missing lines Coverage Δ
include/boost/openmethod/core.hpp 91.60% <ø> (-1.49%) ⬇️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8db9d0c...e89fe7c. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jll63
jll63 merged commit 261ebed into boostorg:develop Sep 16, 2026
54 of 56 checks passed
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.

2 participants