In kotlin/native compatibility methods, include the name of the first parameter in the method name to match k/n @ObjCName mapping. PiperOrigin-RevId: 745934253
diff --git a/protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_field.cc b/protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_field.cc index eb9c657..72e68e7 100644 --- a/protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_field.cc +++ b/protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_field.cc
@@ -330,7 +330,7 @@ "- (nonnull $classname$_Builder *)set$capitalized_name$With$parameter_type$:\n" " ($nonnull_type$)value;\n" "- (nonnull $classname$_Builder *)clear$capitalized_name$;\n"); - + if (CanGenerateProperty(descriptor_)) { printer->Print(GetStorageType(descriptor_) == GetNonNullType(descriptor_) ? "@property (" : "@property (nonnull, retain, "); @@ -340,7 +340,7 @@ "setter=Set$capitalized_name$With$parameter_type$:) " "$storage_type$ $camelcase_name$;\n"); } - + if (GetJavaType(descriptor_) == JAVATYPE_MESSAGE) { printer->Print(variables_, "- (nonnull $classname$_Builder*)\n" @@ -417,7 +417,7 @@ if (IsGenerateProperties(descriptor_->file())) { printer->Print( variables_, - "- (nonnull $classname$_Builder *)add$capitalized_name$:\n" + "- (nonnull $classname$_Builder *)add$capitalized_name$Value:\n" " ($nonnull_type$)value;\n"); } if (GetJavaType(descriptor_) == JAVATYPE_MESSAGE) { @@ -523,11 +523,11 @@ "*)put$capitalized_name$With$key_parameter_type$:" "($key_storage_type$)key with$value_parameter_type$:" "($value_nonnull_type$)value;\n"); - + if (IsGenerateProperties(descriptor_->file())) { printer->Print( variables_, - "- (nonnull $classname$_Builder *)put$capitalized_name$:" + "- (nonnull $classname$_Builder *)put$capitalized_name$Key:" "($key_nonnull_type$)key value:($value_nonnull_type$)value;\n"); } } @@ -565,7 +565,7 @@ "with$value_parameter_type$:($value_nonnull_type$)defaultValue;\n" "- ($value_nonnull_type$)get$capitalized_name$OrThrowWith" "$key_parameter_type$:($key_storage_type$)key;\n"); - + if (IsGenerateProperties(descriptor_->file())) { printer->Print( variables_,
diff --git a/protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm b/protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm index 30649997..e660a10 100644 --- a/protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm +++ b/protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm
@@ -1179,7 +1179,7 @@ ComGoogleProtobufDescriptors_FieldDescriptor *field = fieldsBuf[i]; const char *tail = selName; if (MatchesName(&tail, field) && - (Matches(&tail, "With", 4) ? MatchesKeyword(&tail, field) : true)) { + (Matches(&tail, "With", 4) ? MatchesKeyword(&tail, field) : Matches(&tail, "Value", 5))) { if (MatchesEnd(tail, ":")) { return AddAdderMethod(cls, sel, field); } else if (MatchesEnd(tail, "_Builder:")) { @@ -1234,7 +1234,7 @@ MatchesEnd(tail, ":")) { return AddPutMethod(cls, sel, field); } - if (Matches(&tail, ":value", 6) && MatchesEnd(tail, ":")) { + if (Matches(&tail, "Key", 3) && Matches(&tail, ":value", 6) && MatchesEnd(tail, ":")) { return AddPutMethod(cls, sel, field); } }