1diff --git a/src/google/protobuf/compiler/cpp/helpers.cc b/src/google/protobuf/compiler/cpp/helpers.cc 2index 4b7c5c9d912b1..5288fa321270b 100644 3--- a/src/google/protobuf/compiler/cpp/helpers.cc 4+++ b/src/google/protobuf/compiler/cpp/helpers.cc 5@@ -72,6 +72,14 @@ namespace { 6 static const char kAnyMessageName[] = "Any"; 7 static const char kAnyProtoFile[] = "google/protobuf/any.proto"; 8 9+// TODO(crbug.com/332939935): This is used to allow generating an AnyLite proto 10+// compatible with /third_party/medialite instead of checking in compiled 11+// protobufs that complicate rolling. 12+// Upstream should be fixed so that we don't need to generate a separate 13+// AnyLite, then this patch/change should be dropped. 14+static const char kAnyLiteMessageName[] = "AnyLite"; 15+static const char kAnyLiteProtoFile[] = "google/protobuf/any_lite.proto"; 16+ 17 std::string DotsToColons(const std::string& name) { 18 return StringReplace(name, ".", "::", true); 19 } 20@@ -1082,11 +1090,13 @@ FieldOptions::CType EffectiveStringCType(const FieldDescriptor* field, 21 } 22 23 bool IsAnyMessage(const FileDescriptor* descriptor, const Options& options) { 24- return descriptor->name() == kAnyProtoFile; 25+ return descriptor->name() == kAnyProtoFile || 26+ descriptor->name() == kAnyLiteProtoFile; 27 } 28 29 bool IsAnyMessage(const Descriptor* descriptor, const Options& options) { 30- return descriptor->name() == kAnyMessageName && 31+ return (descriptor->name() == kAnyMessageName || 32+ descriptor->name() == kAnyLiteMessageName) && 33 IsAnyMessage(descriptor->file(), options); 34 } 35 36diff --git a/src/google/protobuf/compiler/cpp/message.cc b/src/google/protobuf/compiler/cpp/message.cc 37index dd1daa30b080f..24e303c55e54a 100644 38--- a/src/google/protobuf/compiler/cpp/message.cc 39+++ b/src/google/protobuf/compiler/cpp/message.cc 40@@ -2085,13 +2085,17 @@ void MessageGenerator::GenerateClassMethods(io::Printer* printer) { 41 " message, type_url_field, value_field);\n" 42 "}\n"); 43 } 44- format( 45- "bool $classname$::ParseAnyTypeUrl(\n" 46- " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n" 47- " std::string* full_type_name) {\n" 48- " return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);\n" 49- "}\n" 50- "\n"); 51+ // TODO(crbug.com/332939935): Remove this workaround when the AnyLite patch 52+ // can go away. 53+ if (descriptor_->name() != "AnyLite") { 54+ format( 55+ "bool $classname$::ParseAnyTypeUrl(\n" 56+ " ::PROTOBUF_NAMESPACE_ID::ConstStringParam type_url,\n" 57+ " std::string* full_type_name) {\n" 58+ " return ::_pbi::ParseAnyTypeUrl(type_url, full_type_name);\n" 59+ "}\n" 60+ "\n"); 61+ } 62 } 63 64 format( 65