Skip to content

better error message when overrider cannot be matched to method#63

Merged
jll63 merged 3 commits intoboostorg:developfrom
jll63:feature/better-error-message
Feb 28, 2026
Merged

better error message when overrider cannot be matched to method#63
jll63 merged 3 commits intoboostorg:developfrom
jll63:feature/better-error-message

Conversation

@jll63
Copy link
Collaborator

@jll63 jll63 commented Feb 28, 2026

No description provided.

@cppalliance-bot
Copy link

cppalliance-bot commented Feb 28, 2026

An automated preview of the documentation is available at https://63.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-02-28 16:10:31 UTC

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the compile-time diagnostic emitted when BOOST_OPENMETHOD_OVERRIDE cannot be matched to a corresponding method signature, and adds/adjusts CMake-based tests to validate behavior and make example tests runnable via ctest without a prior build.

Changes:

  • Improve BOOST_OPENMETHOD_OVERRIDE “method not found” error via a SFINAE-based locator with a targeted static_assert.
  • Register a new compile-fail test for the new diagnostic message.
  • Update shared library example CMake/CTest wiring to build targets via fixtures and run executables from a known output directory.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
test/CMakeLists.txt Adds a new compile-fail test registration for the updated diagnostic.
include/boost/openmethod/macros.hpp Introduces SFINAE detection and a clearer static_assert message when an overrider can’t be matched to a method.
doc/modules/ROOT/examples/shared_libs/CMakeLists.txt Adds CTest build fixtures and output directory settings for shared-lib examples.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +105 to +106
openmethod_compile_fail_test(
compile_fail_override_method_not_found "cannot find 'speak' method that accepts the same arguments as the overrider")
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This compile-fail test target references a source file compile_fail_override_method_not_found.cpp, but that file is not present under test/ in this PR. As-is, CMake configuration/build will fail because add_library(... "${testname}.cpp") points to a non-existent file. Please add the missing test/compile_fail_override_method_not_found.cpp (and ensure it triggers the new diagnostic), or remove this test registration.

Suggested change
openmethod_compile_fail_test(
compile_fail_override_method_not_found "cannot find 'speak' method that accepts the same arguments as the overrider")

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +44
add_test(NAME boost_openmethod-static
COMMAND "${shared_libs_output_dir}/boost_openmethod-static")
set_tests_properties(boost_openmethod-static PROPERTIES
FIXTURES_REQUIRED boost_openmethod-static-fixture)
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test command hardcodes the executable path as ${shared_libs_output_dir}/boost_openmethod-static. This is not robust on Windows (missing .exe) and can also break on multi-config generators where outputs may be placed under a per-config subdirectory. Prefer using $<TARGET_FILE:boost_openmethod-static> (and similarly for the other executables) so CTest runs the actual built artifact regardless of platform/config.

Copilot uses AI. Check for mistakes.
Comment on lines +59 to +62
add_test(NAME boost_openmethod-dynamic
COMMAND "${shared_libs_output_dir}/boost_openmethod-dynamic")
set_tests_properties(boost_openmethod-dynamic PROPERTIES
FIXTURES_REQUIRED "boost_openmethod-shared-fixture;boost_openmethod-dynamic-fixture")
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test command uses a manually constructed path ${shared_libs_output_dir}/boost_openmethod-dynamic, which can fail on platforms/configurations where the executable filename includes an extension (e.g., .exe) or is placed in a config-specific output directory. Use $<TARGET_FILE:boost_openmethod-dynamic> to make the test invocation generator- and platform-independent.

Copilot uses AI. Check for mistakes.
Comment on lines +90 to +93
add_test(NAME boost_openmethod-indirect
COMMAND "${shared_libs_output_dir}/boost_openmethod-indirect")
set_tests_properties(boost_openmethod-indirect PROPERTIES
FIXTURES_REQUIRED boost_openmethod-indirect-fixture)
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test command uses ${shared_libs_output_dir}/boost_openmethod-indirect, which may not exist as-is on Windows (extension) or with multi-config output layouts. Using $<TARGET_FILE:boost_openmethod-indirect> will ensure CTest executes the correct built binary.

Copilot uses AI. Check for mistakes.
@jll63 jll63 merged commit 5995745 into boostorg:develop Feb 28, 2026
48 of 49 checks passed
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.66%. Comparing base (e0ead3b) to head (5995745).
⚠️ Report is 27 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #63      +/-   ##
===========================================
+ Coverage    92.03%   92.66%   +0.63%     
===========================================
  Files           40       43       +3     
  Lines         2838     3110     +272     
  Branches      1354     1544     +190     
===========================================
+ Hits          2612     2882     +270     
- Misses         187      188       +1     
- Partials        39       40       +1     

see 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1be0f4...5995745. 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 deleted the feature/better-error-message branch February 28, 2026 20:44
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.

3 participants