diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc index daf0ed3615..2d8c806106 100644 --- a/src/google/protobuf/compiler/cpp/message.cc +++ b/src/google/protobuf/compiler/cpp/message.cc @@ -1368,12 +1368,12 @@ void MessageGenerator::GenerateMapEntryClassDefinition(io::Printer* p) { R"cc( class $classname$ final : public ::$proto_ns$::internal::MapEntry< - $classname$, $key_cpp$, $val_cpp$, + $key_cpp$, $val_cpp$, ::$proto_ns$::internal::WireFormatLite::$key_wire_type$, ::$proto_ns$::internal::WireFormatLite::$val_wire_type$> { public: using SuperType = ::$proto_ns$::internal::MapEntry< - $classname$, $key_cpp$, $val_cpp$, + $key_cpp$, $val_cpp$, ::$proto_ns$::internal::WireFormatLite::$key_wire_type$, ::$proto_ns$::internal::WireFormatLite::$val_wire_type$>; $classname$(); diff --git a/src/google/protobuf/map_entry.h b/src/google/protobuf/map_entry.h index 3fbd531bfa..c21d74332a 100644 --- a/src/google/protobuf/map_entry.h +++ b/src/google/protobuf/map_entry.h @@ -30,18 +30,9 @@ namespace google { namespace protobuf { + class Arena; -namespace internal { -template -class MapField; -} -} // namespace protobuf -} // namespace google -namespace google { -namespace protobuf { namespace internal { // MapEntry is the returned google::protobuf::Message when calling AddMessage of @@ -70,8 +61,7 @@ namespace internal { // The in-memory types of primitive types can be inferred from its proto type, // while we need to explicitly specify the cpp type if proto type is // TYPE_MESSAGE to infer the in-memory type. -template class MapEntry : public Message { // Provide utilities to parse/serialize key/value. Provide utilities to @@ -119,11 +109,9 @@ class MapEntry : public Message { } _impl_; }; -template -struct MapEntry::_Internal { +struct MapEntry::_Internal { static constexpr ::int32_t kHasBitsOffset = 8 * PROTOBUF_FIELD_OFFSET(MapEntry, _impl_._has_bits_); }; diff --git a/src/google/protobuf/map_field.h b/src/google/protobuf/map_field.h index 237fd28eb0..21021560cc 100644 --- a/src/google/protobuf/map_field.h +++ b/src/google/protobuf/map_field.h @@ -26,7 +26,6 @@ #include "google/protobuf/generated_message_util.h" #include "google/protobuf/internal_visibility.h" #include "google/protobuf/map.h" -#include "google/protobuf/map_entry.h" #include "google/protobuf/map_field_lite.h" #include "google/protobuf/map_type_handler.h" #include "google/protobuf/message.h" @@ -656,9 +655,6 @@ class MapField final : public TypeDefinedMapFieldBase { typedef MapTypeHandler KeyTypeHandler; typedef MapTypeHandler ValueTypeHandler; - // Define message type for internal repeated field. - typedef Derived EntryType; - public: typedef Map MapType; static constexpr WireFormatLite::FieldType kKeyFieldType = kKeyFieldType_; @@ -678,12 +674,6 @@ class MapField final : public TypeDefinedMapFieldBase { this->MergeFromImpl(*this, from); } - // Used in the implementation of parsing. Caller should take the ownership iff - // arena_ is nullptr. - EntryType* NewEntry() const { - return Arena::Create(this->arena()); - } - private: typedef void InternalArenaConstructable_; typedef void DestructorSkippable_; @@ -712,14 +702,6 @@ bool AllAreInitialized(const TypeDefinedMapFieldBase& field) { return true; } -template -struct MapEntryToMapField< - MapEntry> { - typedef MapField MapFieldType; -}; - class PROTOBUF_EXPORT DynamicMapField final : public TypeDefinedMapFieldBase { public: diff --git a/src/google/protobuf/map_test.inc b/src/google/protobuf/map_test.inc index ed59e8999b..e2ff9da739 100644 --- a/src/google/protobuf/map_test.inc +++ b/src/google/protobuf/map_test.inc @@ -2322,7 +2322,7 @@ TEST_F(MapFieldReflectionTest, UninitializedEntry) { } class MyMapEntry - : public internal::MapEntry { public: