From 1eab2a4a80f2e7f0cb660300f6d3eb9994cf9b2f Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Tue, 4 Apr 2023 09:35:10 +0200 Subject: [PATCH] meta: fix constness detection for static functions in meta_type::invoke --- src/entt/meta/meta.hpp | 2 +- test/entt/meta/meta_type.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/entt/meta/meta.hpp b/src/entt/meta/meta.hpp index ac36ff3f2..c78249208 100644 --- a/src/entt/meta/meta.hpp +++ b/src/entt/meta/meta.hpp @@ -1389,7 +1389,7 @@ public: meta_any invoke(const id_type id, meta_handle instance, meta_any *const args, const size_type sz) const { if(node.details) { if(auto it = node.details->func.find(id); it != node.details->func.cend()) { - if(const auto *candidate = lookup(args, sz, (instance->data() == nullptr), [curr = &it->second]() mutable { return curr ? std::exchange(curr, curr->next.get()) : nullptr; }); candidate) { + if(const auto *candidate = lookup(args, sz, instance && (instance->data() == nullptr), [curr = &it->second]() mutable { return curr ? std::exchange(curr, curr->next.get()) : nullptr; }); candidate) { return candidate->invoke(*ctx, meta_handle{*ctx, std::move(instance)}, args); } } diff --git a/test/entt/meta/meta_type.cpp b/test/entt/meta/meta_type.cpp index adb6e7669..0fc7c376f 100644 --- a/test/entt/meta/meta_type.cpp +++ b/test/entt/meta/meta_type.cpp @@ -378,7 +378,10 @@ TEST_F(MetaType, Invoke) { clazz_t instance{}; ASSERT_TRUE(type.invoke("member"_hs, instance)); - ASSERT_FALSE(type.invoke("rebmem"_hs, {})); + ASSERT_FALSE(type.invoke("rebmem"_hs, instance)); + + ASSERT_TRUE(type.invoke("func"_hs, {})); + ASSERT_FALSE(type.invoke("cnuf"_hs, {})); } TEST_F(MetaType, InvokeFromBase) {