Skip to content

Commit 77c8282

Browse files
stefanhausteincopybara-github
authored andcommitted
BEGIN_PUBLIC
Support static method access via FooBarCompanion.shared END_PUBLIC PiperOrigin-RevId: 817617303
1 parent 5c71a42 commit 77c8282

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void MessageGenerator::GenerateHeader(io::Printer* printer) {
212212
"\n"
213213
"@class $classname$;"
214214
"\n"
215-
"@protocol $classname$_Companion\n"
215+
"@protocol $classname$Companion\n"
216216
"- (nonnull $classname$_Builder *)newBuilder OBJC_METHOD_FAMILY_NONE;\n"
217217
"- (nonnull $classname$ *)getDefaultInstance;\n"
218218
"- (nonnull $classname$ *)parseFromWithComGoogleProtobufByteString:"
@@ -224,7 +224,9 @@ void MessageGenerator::GenerateHeader(io::Printer* printer) {
224224
"// in j2objc_message.cc \n"
225225
"@interface $classname$ : $superclassname$<$classname$OrBuilder>\n\n"
226226
"@property (nonnull, readonly, class)"
227-
" id<$classname$_Companion> companion;\n",
227+
" id<$classname$Companion> companion;\n"
228+
"@property (nonnull, readonly, class)"
229+
" id<$classname$Companion> shared;\n",
228230
"classname", ClassName(descriptor_), "superclassname", superclassName);
229231
} else {
230232
printer->Print(
@@ -440,8 +442,11 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
440442

441443
if (IsGenerateProperties(descriptor_->file())) {
442444
printer->Print(
443-
"+ (nonnull id<$classname$_Companion>)companion {\n"
444-
" return (id<$classname$_Companion>) [self class];\n"
445+
"+ (nonnull id<$classname$Companion>)shared {\n"
446+
" return (id<$classname$Companion>) [self class];\n"
447+
"}\n"
448+
"+ (nonnull id<$classname$Companion>)companion {\n"
449+
" return (id<$classname$Companion>) [self class];\n"
445450
"}\n",
446451
"classname", ClassName(descriptor_));
447452
for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {

0 commit comments

Comments
 (0)