From e18532fe067bde119a894e444f2c1952fdee212e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 14:02:23 +1100 Subject: [PATCH] xo-facet: bugfix: carefuly GCConversion w/ DVariantPlaceholder --- xo-facet/include/xo/facet/OObject.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xo-facet/include/xo/facet/OObject.hpp b/xo-facet/include/xo/facet/OObject.hpp index 234a84df..6d14cf91 100644 --- a/xo-facet/include/xo/facet/OObject.hpp +++ b/xo-facet/include/xo/facet/OObject.hpp @@ -233,7 +233,7 @@ namespace xo { * Provided when actual type of @ref data_ is not DRepr, * because DRepr is DVariantPlaceholder. * - * We can't rely on dynamic_cast here, because DRepr's + * NOTE: We can't rely on dynamic_cast here, because DRepr's * don't need to be related as far as c++ type system is * concerned. **/ @@ -241,9 +241,14 @@ namespace xo { DOther * downcast() const requires (std::is_same_v) { - if (data_ && (typeseq::id() == this->iface()->_typeseq())) { + if constexpr (std::is_same_v) { + /* trivialconversion from type-erased to type-erased. + * Don't need to inspect runtime type + */ + return data_; + } else if (data_ && (typeseq::id() == this->iface()->_typeseq())) { /* actual runtime type for data_ is DOther, - * safe to reinterpret + * reported by _typseq() -> safe to reinterpret */ return reinterpret_cast(data_); } else {