Skip to content

Commit

Permalink
Hide dynamic versions of AnyPatch::patchIfTypeIs and AnyPatch::ensure…
Browse files Browse the repository at this point in the history
…AndPatch

Summary: use the same badge

Reviewed By: Mizuchi

Differential Revision: D62903158

fbshipit-source-id: 8466e1f7dbedbfcf00d88d4079af6860a701031e
  • Loading branch information
thedavekwon authored and facebook-github-bot committed Sep 18, 2024
1 parent 3f93a06 commit c299f78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions thrift/lib/thrift/detail/AnyPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@

namespace apache {
namespace thrift {
namespace protocol {
namespace detail {

struct PatchBadgeFactory;
using Badge = folly::badge<PatchBadgeFactory>;

} // namespace detail
} // namespace protocol
namespace op {
namespace detail {

Expand Down Expand Up @@ -219,7 +227,8 @@ class AnyPatch : public BaseClearPatch<Patch, AnyPatch<Patch>> {

// The provided type MUST match with the value type of patch stored in
// provided patch as Thrift Any.
void patchIfTypeIs(type::Type type, type::AnyStruct patch) {
void patchIfTypeIs(
protocol::detail::Badge, type::Type type, type::AnyStruct patch) {
if (!type.isValid()) {
throwTypeNotValid(type);
}
Expand All @@ -231,7 +240,8 @@ class AnyPatch : public BaseClearPatch<Patch, AnyPatch<Patch>> {

// The provided type in ensureAny MUST match with the value type of patch
// stored in provided patch as Thrift Any.
void ensureAndPatch(type::AnyStruct ensure, type::AnyStruct patch) {
void ensureAndPatch(
protocol::detail::Badge, type::AnyStruct ensure, type::AnyStruct patch) {
throwIfInvalidOrUnsupportedAny(ensure);
throwIfInvalidOrUnsupportedAny(patch);
type::Type type = ensure.type().value();
Expand Down
2 changes: 1 addition & 1 deletion thrift/lib/thrift/detail/DynamicPatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ op::AnyPatch DiffVisitorBase::diffAny(
anySubPatch.data() =
*serializeObject<CompactProtocolWriter>(subPatch.toObject());
anySubPatch.type() = detail::toPatchType(*src.type());
patch.patchIfTypeIs(*src.type(), std::move(anySubPatch));
patch.patchIfTypeIs(badge, *src.type(), std::move(anySubPatch));
}

return patch;
Expand Down

0 comments on commit c299f78

Please sign in to comment.