diff --git a/include/rfl/capnproto/is_named_type.hpp b/include/rfl/capnproto/is_named_type.hpp index cad64d631..a45a4986d 100644 --- a/include/rfl/capnproto/is_named_type.hpp +++ b/include/rfl/capnproto/is_named_type.hpp @@ -1,6 +1,8 @@ #ifndef RFL_CAPNPROTO_IS_NAMED_TYPE_HPP_ #define RFL_CAPNPROTO_IS_NAMED_TYPE_HPP_ +#include + #include "../parsing/schema/Type.hpp" namespace rfl::capnproto { @@ -8,10 +10,15 @@ namespace rfl::capnproto { inline bool is_named_type(const parsing::schema::Type& _type) { return _type.variant_.visit([&](const auto& _v) -> bool { using T = std::remove_cvref_t; - return std::is_same() || - std::is_same() || - std::is_same() || - std::is_same(); + if constexpr (std::is_same_v || + std::is_same_v) { + return is_named_type(*_v.type_); + } else { + return std::is_same() || + std::is_same() || + std::is_same() || + std::is_same(); + } }); } diff --git a/src/rfl/avro/to_schema.cpp b/src/rfl/avro/to_schema.cpp index 5b8e25a3b..6d4184ec0 100644 --- a/src/rfl/avro/to_schema.cpp +++ b/src/rfl/avro/to_schema.cpp @@ -35,8 +35,13 @@ namespace rfl::avro { inline bool is_named_type(const parsing::schema::Type& _type) { return _type.variant_.visit([&](const auto& _v) -> bool { using T = std::remove_cvref_t; - return std::is_same() || - std::is_same(); + if constexpr (std::is_same_v || + std::is_same_v) { + return is_named_type(*_v.type_); + } else { + return std::is_same() || + std::is_same(); + } }); } diff --git a/src/rfl/capnproto/to_schema.cpp b/src/rfl/capnproto/to_schema.cpp index 6d166e286..c97669e8b 100644 --- a/src/rfl/capnproto/to_schema.cpp +++ b/src/rfl/capnproto/to_schema.cpp @@ -139,6 +139,18 @@ schema::Type reference_to_capnproto_schema_type( } } +inline bool is_literal_type(const parsing::schema::Type& _type) { + return _type.variant_.visit([](const auto& _v) -> bool { + using T = std::remove_cvref_t; + if constexpr (std::is_same_v || + std::is_same_v) { + return is_literal_type(*_v.type_); + } else { + return std::is_same_v; + } + }); +} + schema::Type string_map_to_capnproto_schema_type( const parsing::schema::Type::StringMap& _map, const std::map& _definitions, @@ -151,12 +163,7 @@ schema::Type string_map_to_capnproto_schema_type( if constexpr (std::is_same_v) { const auto it = _definitions.find(_value.type_name); return _cnp_types->enums_.contains(_value.type_name) || - (it != _definitions.end() && - it->second.variant_.visit([](const auto& _definition) { - return std::is_same_v< - std::remove_cvref_t, - parsing::schema::Type::Literal>; - })); + (it != _definitions.end() && is_literal_type(it->second)); } else { return !std::is_same_v && !std::is_same_v && !std::is_same_v && !std::is_same_v &&