Skip to content

Commit ec0df81

Browse files
stefanhausteincopybara-github
authored andcommitted
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
1 parent a804c3b commit ec0df81

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

protobuf/compiler/src/google/protobuf/compiler/j2objc/j2objc_field.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void SingleFieldGenerator::GenerateFieldBuilderHeader(io::Printer* printer)
330330
"- (nonnull $classname$_Builder *)set$capitalized_name$With$parameter_type$:\n"
331331
" ($nonnull_type$)value;\n"
332332
"- (nonnull $classname$_Builder *)clear$capitalized_name$;\n");
333-
333+
334334
if (CanGenerateProperty(descriptor_)) {
335335
printer->Print(GetStorageType(descriptor_) == GetNonNullType(descriptor_)
336336
? "@property (" : "@property (nonnull, retain, ");
@@ -340,7 +340,7 @@ void SingleFieldGenerator::GenerateFieldBuilderHeader(io::Printer* printer)
340340
"setter=Set$capitalized_name$With$parameter_type$:) "
341341
"$storage_type$ $camelcase_name$;\n");
342342
}
343-
343+
344344
if (GetJavaType(descriptor_) == JAVATYPE_MESSAGE) {
345345
printer->Print(variables_,
346346
"- (nonnull $classname$_Builder*)\n"
@@ -417,7 +417,7 @@ void RepeatedFieldGenerator::GenerateFieldBuilderHeader(io::Printer* printer)
417417
if (IsGenerateProperties(descriptor_->file())) {
418418
printer->Print(
419419
variables_,
420-
"- (nonnull $classname$_Builder *)add$capitalized_name$:\n"
420+
"- (nonnull $classname$_Builder *)add$capitalized_name$Value:\n"
421421
" ($nonnull_type$)value;\n");
422422
}
423423
if (GetJavaType(descriptor_) == JAVATYPE_MESSAGE) {
@@ -523,11 +523,11 @@ void MapFieldGenerator::GenerateFieldBuilderHeader(io::Printer* printer) const {
523523
"*)put$capitalized_name$With$key_parameter_type$:"
524524
"($key_storage_type$)key with$value_parameter_type$:"
525525
"($value_nonnull_type$)value;\n");
526-
526+
527527
if (IsGenerateProperties(descriptor_->file())) {
528528
printer->Print(
529529
variables_,
530-
"- (nonnull $classname$_Builder *)put$capitalized_name$:"
530+
"- (nonnull $classname$_Builder *)put$capitalized_name$Key:"
531531
"($key_nonnull_type$)key value:($value_nonnull_type$)value;\n");
532532
}
533533
}
@@ -565,7 +565,7 @@ void MapFieldGenerator::GenerateMessageOrBuilderProtocol(
565565
"with$value_parameter_type$:($value_nonnull_type$)defaultValue;\n"
566566
"- ($value_nonnull_type$)get$capitalized_name$OrThrowWith"
567567
"$key_parameter_type$:($key_storage_type$)key;\n");
568-
568+
569569
if (IsGenerateProperties(descriptor_->file())) {
570570
printer->Print(
571571
variables_,

protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ static BOOL ResolveAddAccessor(Class cls, CGPDescriptor *descriptor, SEL sel, co
11791179
ComGoogleProtobufDescriptors_FieldDescriptor *field = fieldsBuf[i];
11801180
const char *tail = selName;
11811181
if (MatchesName(&tail, field) &&
1182-
(Matches(&tail, "With", 4) ? MatchesKeyword(&tail, field) : true)) {
1182+
(Matches(&tail, "With", 4) ? MatchesKeyword(&tail, field) : Matches(&tail, "Value", 5))) {
11831183
if (MatchesEnd(tail, ":")) {
11841184
return AddAdderMethod(cls, sel, field);
11851185
} else if (MatchesEnd(tail, "_Builder:")) {
@@ -1234,7 +1234,7 @@ static BOOL ResolvePutAccessor(Class cls, CGPDescriptor *descriptor, SEL sel, co
12341234
MatchesEnd(tail, ":")) {
12351235
return AddPutMethod(cls, sel, field);
12361236
}
1237-
if (Matches(&tail, ":value", 6) && MatchesEnd(tail, ":")) {
1237+
if (Matches(&tail, "Key", 3) && Matches(&tail, ":value", 6) && MatchesEnd(tail, ":")) {
12381238
return AddPutMethod(cls, sel, field);
12391239
}
12401240
}

0 commit comments

Comments
 (0)