From c24e7529eb7a709285a5e61d8d05a347576de7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89amonn=20McManus?= Date: Tue, 30 Apr 2024 07:24:51 -0700 Subject: [PATCH] Automated rollback of commit e9c9970eb4ac488d9fb94e8dea6945d3881c405d. PiperOrigin-RevId: 629405086 --- .../kotlin/com/google/protobuf/Proto2Test.kt | 28 +++------- .../kotlin/com/google/protobuf/Proto3Test.kt | 14 +---- .../google/protobuf/evil_names_proto2.proto | 9 --- .../google/protobuf/evil_names_proto3.proto | 6 -- src/google/protobuf/compiler/java/BUILD.bazel | 1 - .../protobuf/compiler/java/field_common.cc | 56 ------------------- .../compiler/java/immutable/enum_field.cc | 10 ++-- .../compiler/java/immutable/map_field.cc | 2 +- .../compiler/java/immutable/message_field.cc | 6 +- .../java/immutable/primitive_field.cc | 31 +++------- .../compiler/java/immutable/string_field.cc | 6 +- .../protobuf/compiler/java/lite/enum_field.cc | 10 ++-- .../protobuf/compiler/java/lite/map_field.cc | 2 +- .../compiler/java/lite/message_field.cc | 6 +- .../compiler/java/lite/primitive_field.cc | 38 +++++-------- .../compiler/java/lite/string_field.cc | 6 +- 16 files changed, 57 insertions(+), 174 deletions(-) diff --git a/java/kotlin/src/test/kotlin/com/google/protobuf/Proto2Test.kt b/java/kotlin/src/test/kotlin/com/google/protobuf/Proto2Test.kt index 7c319bfaac..c9fee8a78f 100644 --- a/java/kotlin/src/test/kotlin/com/google/protobuf/Proto2Test.kt +++ b/java/kotlin/src/test/kotlin/com/google/protobuf/Proto2Test.kt @@ -225,7 +225,7 @@ class Proto2Test { TestAllTypesKt.repeatedGroup { a = 1 }, TestAllTypesKt.repeatedGroup { a = 2 }, TestAllTypesKt.repeatedGroup { a = 3 }, - TestAllTypesKt.repeatedGroup { a = 4 }, + TestAllTypesKt.repeatedGroup { a = 4 } ) ) repeatedGroup[0] = TestAllTypesKt.repeatedGroup { a = 5 } @@ -235,7 +235,7 @@ class Proto2Test { TestAllTypesKt.repeatedGroup { a = 5 }, TestAllTypesKt.repeatedGroup { a = 2 }, TestAllTypesKt.repeatedGroup { a = 3 }, - TestAllTypesKt.repeatedGroup { a = 4 }, + TestAllTypesKt.repeatedGroup { a = 4 } ) ) @@ -249,7 +249,7 @@ class Proto2Test { nestedMessage { bb = 1 }, nestedMessage { bb = 2 }, nestedMessage { bb = 3 }, - nestedMessage { bb = 4 }, + nestedMessage { bb = 4 } ) ) repeatedNestedMessage[0] = nestedMessage { bb = 5 } @@ -259,7 +259,7 @@ class Proto2Test { nestedMessage { bb = 5 }, nestedMessage { bb = 2 }, nestedMessage { bb = 3 }, - nestedMessage { bb = 4 }, + nestedMessage { bb = 4 } ) ) @@ -548,7 +548,7 @@ class Proto2Test { repeatedGroupExtension { a = 1 }, repeatedGroupExtension { a = 2 }, repeatedGroupExtension { a = 3 }, - repeatedGroupExtension { a = 4 }, + repeatedGroupExtension { a = 4 } ) ) this[UnittestProto.repeatedGroupExtension][0] = repeatedGroupExtension { a = 5 } @@ -558,7 +558,7 @@ class Proto2Test { repeatedGroupExtension { a = 5 }, repeatedGroupExtension { a = 2 }, repeatedGroupExtension { a = 3 }, - repeatedGroupExtension { a = 4 }, + repeatedGroupExtension { a = 4 } ) ) @@ -575,7 +575,7 @@ class Proto2Test { nestedMessage { bb = 1 }, nestedMessage { bb = 2 }, nestedMessage { bb = 3 }, - nestedMessage { bb = 4 }, + nestedMessage { bb = 4 } ) ) this[UnittestProto.repeatedNestedMessageExtension][0] = nestedMessage { bb = 5 } @@ -585,7 +585,7 @@ class Proto2Test { nestedMessage { bb = 5 }, nestedMessage { bb = 2 }, nestedMessage { bb = 3 }, - nestedMessage { bb = 4 }, + nestedMessage { bb = 4 } ) ) @@ -757,7 +757,7 @@ class Proto2Test { 1 to Proto2MapEnum.PROTO2_MAP_ENUM_FOO, 2 to Proto2MapEnum.PROTO2_MAP_ENUM_BAR, 3 to Proto2MapEnum.PROTO2_MAP_ENUM_BAZ, - 4 to Proto2MapEnum.PROTO2_MAP_ENUM_FOO, + 4 to Proto2MapEnum.PROTO2_MAP_ENUM_FOO ) ) } @@ -844,11 +844,6 @@ class Proto2Test { cachedSize_ = "foo" serializedSize_ = true by = "foo" - dEPRECATEDFoo = "foo" - DEPRECATEDBar = "foo" - iD = "foo" - aBNotification = "foo" - notDEPRECATEDFoo = "foo" } ) .isEqualTo( @@ -874,11 +869,6 @@ class Proto2Test { .setCachedSize_("foo") .setSerializedSize_(true) .setBy("foo") - .setDEPRECATEDFoo("foo") - .setDEPRECATEDBar("foo") - .setID("foo") - .setABNotification("foo") - .setNotDEPRECATEDFoo("foo") .build() ) diff --git a/java/kotlin/src/test/kotlin/com/google/protobuf/Proto3Test.kt b/java/kotlin/src/test/kotlin/com/google/protobuf/Proto3Test.kt index 72ab8e1f80..0b270e6e75 100644 --- a/java/kotlin/src/test/kotlin/com/google/protobuf/Proto3Test.kt +++ b/java/kotlin/src/test/kotlin/com/google/protobuf/Proto3Test.kt @@ -81,7 +81,7 @@ class Proto3Test { nestedMessage { bb = 1 }, nestedMessage { bb = 2 }, nestedMessage { bb = 3 }, - nestedMessage { bb = 4 }, + nestedMessage { bb = 4 } ) ) repeatedNestedMessage[0] = nestedMessage { bb = 5 } @@ -91,7 +91,7 @@ class Proto3Test { nestedMessage { bb = 5 }, nestedMessage { bb = 2 }, nestedMessage { bb = 3 }, - nestedMessage { bb = 4 }, + nestedMessage { bb = 4 } ) ) @@ -200,11 +200,6 @@ class Proto3Test { pairs["foo"] = 1 LeadingUnderscore = "foo" option = 1 - dEPRECATEDFoo = "foo" - iD = "foo" - aBNotification = "foo" - DEPRECATEDBar = "foo" - notDEPRECATEDFoo = "foo" } ) .isEqualTo( @@ -242,11 +237,6 @@ class Proto3Test { .putPairs("foo", 1) .setLeadingUnderscore("foo") .setOption(1) - .setDEPRECATEDFoo("foo") - .setID("foo") - .setABNotification("foo") - .setDEPRECATEDBar("foo") - .setNotDEPRECATEDFoo("foo") .build() ) diff --git a/java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto2.proto b/java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto2.proto index f771bf97bf..ba0827422b 100644 --- a/java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto2.proto +++ b/java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto2.proto @@ -43,15 +43,6 @@ message EvilNamesProto2 { optional string cached_size = 23; optional bool serialized_size = 24; optional string by = 25; - - optional string DEPRECATED_foo = 26; - optional group DEPRECATED_NavigationImageRequested = 27 { - optional int32 DEPRECATED_FooBar = 28; - } - optional string __DEPRECATED_Bar = 29; - optional string ID = 30; - optional string a_b_notification = 31; - optional string not_DEPRECATED_foo = 32; } message List {} diff --git a/java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto3.proto b/java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto3.proto index 238bebc06b..2c9b5a2d68 100644 --- a/java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto3.proto +++ b/java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto3.proto @@ -56,12 +56,6 @@ message EvilNamesProto3 { oneof _leading_underscore_oneof { int32 option = 34; } - - optional string DEPRECATED_foo = 35; - optional string ID = 36; - optional string a_b_notification = 37; - optional string __DEPRECATED_Bar = 38; - optional string not_DEPRECATED_foo = 39; } message HardKeywordsAllTypesProto3 { diff --git a/src/google/protobuf/compiler/java/BUILD.bazel b/src/google/protobuf/compiler/java/BUILD.bazel index 915b370309..39f862f6cc 100644 --- a/src/google/protobuf/compiler/java/BUILD.bazel +++ b/src/google/protobuf/compiler/java/BUILD.bazel @@ -144,7 +144,6 @@ cc_library( "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/log:absl_check", "@com_google_absl//absl/log:absl_log", - "@com_google_absl//absl/strings", "@com_google_absl//absl/strings:string_view", ], ) diff --git a/src/google/protobuf/compiler/java/field_common.cc b/src/google/protobuf/compiler/java/field_common.cc index bb3cd6a748..4acafabe36 100644 --- a/src/google/protobuf/compiler/java/field_common.cc +++ b/src/google/protobuf/compiler/java/field_common.cc @@ -1,11 +1,8 @@ #include "google/protobuf/compiler/java/field_common.h" -#include #include -#include "absl/strings/str_cat.h" #include "google/protobuf/compiler/java/helpers.h" -#include "google/protobuf/compiler/java/names.h" #include "google/protobuf/descriptor.h" namespace google { @@ -13,8 +10,6 @@ namespace protobuf { namespace compiler { namespace java { -std::string GetKotlinPropertyName(const FieldDescriptor* descriptor); - void SetCommonFieldVariables( const FieldDescriptor* descriptor, const FieldGeneratorInfo* info, absl::flat_hash_map* variables) { @@ -35,11 +30,6 @@ void SetCommonFieldVariables( (*variables)["kt_name"] = IsForbiddenKotlin(info->name) ? absl::StrCat(info->name, "_") : info->name; - auto kt_property_name = GetKotlinPropertyName(descriptor); - (*variables)["kt_property_name"] = kt_property_name; - (*variables)["kt_safe_name"] = IsForbiddenKotlin(kt_property_name) - ? absl::StrCat("`", kt_property_name, "`") - : kt_property_name; (*variables)["kt_capitalized_name"] = IsForbiddenKotlin(info->name) ? absl::StrCat(info->capitalized_name, "_") : info->capitalized_name; @@ -61,52 +51,6 @@ void SetCommonFieldVariables( } } -// Locale-independent ASCII upper and lower case munging. -static bool IsUpper(char c) { - return static_cast(c - 'A') <= 'Z' - 'A'; -} - -static char ToLower(char c) { return IsUpper(c) ? c - 'A' + 'a' : c; } - -// Returns the name by which the generated Java getters and setters should be -// referenced from Kotlin as properties. In the simplest case, the original name -// is something like `foo_bar`, which gets translated into `getFooBar()` etc, -// and that in turn can be referenced from Kotlin as `fooBar`. -// -// The algorithm for translating proto names into Java getters and setters is -// straightforward. The first letter of each underscore-separated word gets -// uppercased and the underscores are deleted. There are no other changes, so in -// particular if the proto name has a string of capitals then those remain -// as-is. -// -// The algorithm that the Kotlin compiler uses to derive the property name is -// slightly more complicated. If the first character after `get` (etc) is a -// capital and the second isn't, then the property name is just that string with -// its first letter lowercased. So `getFoo` becomes `foo` and `getX` becomes -// `x`. But if there is more than one capital, then all but the last get -// lowercased. So `getHTMLPage` becomes `htmlPage`. If there are only capitals -// then they all get lowercased, so `getID` becomes `id`. -// TODO: move this to a Kotlin-specific location -std::string GetKotlinPropertyName(const FieldDescriptor* descriptor) { - // Find the first non-capital. If it is the second character, then we just - // need to lowercase the first one. Otherwise we need to lowercase everything - // up to but not including the last capital, except that if everything is - // capitals then everything must be lowercased. - std::string capitalized_name = CapitalizedFieldName(descriptor); - std::string kt_property_name = capitalized_name; - size_t first_non_capital; - for (first_non_capital = 0; first_non_capital < capitalized_name.length() && - IsUpper(capitalized_name[first_non_capital]); - first_non_capital++) { - } - size_t stop = first_non_capital; - if (stop > 1 && stop < capitalized_name.length()) stop--; - for (size_t i = 0; i < stop; i++) { - kt_property_name[i] = ToLower(kt_property_name[i]); - } - return kt_property_name; -} - void SetCommonOneofVariables( const FieldDescriptor* descriptor, const OneofGeneratorInfo* info, absl::flat_hash_map* variables) { diff --git a/src/google/protobuf/compiler/java/immutable/enum_field.cc b/src/google/protobuf/compiler/java/immutable/enum_field.cc index 4a64460fb5..2cb734f498 100644 --- a/src/google/protobuf/compiler/java/immutable/enum_field.cc +++ b/src/google/protobuf/compiler/java/immutable/enum_field.cc @@ -273,10 +273,10 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" " set(value) {\n" - " $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n" + " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n" " }\n"); if (SupportUnknownEnumValue(descriptor_)) { @@ -284,10 +284,10 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers( variables_, "$kt_deprecation$public var $kt_name$Value: kotlin.Int\n" " @JvmName(\"${$get$kt_capitalized_name$Value$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_property_name$Value$}$\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$Value$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$Value$}$\")\n" " set(value) {\n" - " $kt_dsl_builder$.${$$kt_property_name$Value$}$ = value\n" + " $kt_dsl_builder$.${$set$capitalized_name$Value$}$(value)\n" " }\n"); } @@ -1100,7 +1100,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$$kt_property_name$List$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" " )\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, diff --git a/src/google/protobuf/compiler/java/immutable/map_field.cc b/src/google/protobuf/compiler/java/immutable/map_field.cc index 13e6319b79..02e85874c0 100644 --- a/src/google/protobuf/compiler/java/immutable/map_field.cc +++ b/src/google/protobuf/compiler/java/immutable/map_field.cc @@ -981,7 +981,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers( " @kotlin.jvm.JvmSynthetic\n" " @JvmName(\"get$kt_capitalized_name$Map\")\n" " get() = com.google.protobuf.kotlin.DslMap(\n" - " $kt_dsl_builder$.${$$kt_property_name$Map$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n" " )\n"); WriteFieldDocComment(printer, descriptor_, context_->options(), diff --git a/src/google/protobuf/compiler/java/immutable/message_field.cc b/src/google/protobuf/compiler/java/immutable/message_field.cc index 31eb0ea858..1b76fc2f63 100644 --- a/src/google/protobuf/compiler/java/immutable/message_field.cc +++ b/src/google/protobuf/compiler/java/immutable/message_field.cc @@ -378,10 +378,10 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" " set(value) {\n" - " $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n" + " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n" " }\n"); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, @@ -1376,7 +1376,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$$kt_property_name$List$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" " )\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, diff --git a/src/google/protobuf/compiler/java/immutable/primitive_field.cc b/src/google/protobuf/compiler/java/immutable/primitive_field.cc index 3dc402e5c2..eb31a7b756 100644 --- a/src/google/protobuf/compiler/java/immutable/primitive_field.cc +++ b/src/google/protobuf/compiler/java/immutable/primitive_field.cc @@ -291,27 +291,14 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_, context_->options(), /* kdoc */ true); - if (descriptor_->name() == "is_initialized") { - printer->Print( - variables_, - "// TODO: remove this hack; we should access properties\n" - "$kt_deprecation$public var $kt_name$: $kt_type$\n" - " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$get$kt_capitalized_name$$}$()\n" - " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" - " set(value) {\n" - " $kt_dsl_builder$.${$set$kt_capitalized_name$$}$(value)\n" - " }\n"); - } else { - printer->Print(variables_, - "$kt_deprecation$public var $kt_name$: $kt_type$\n" - " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n" - " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" - " set(value) {\n" - " $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n" - " }\n"); - } + printer->Print(variables_, + "$kt_deprecation$public var $kt_name$: $kt_type$\n" + " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" + " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" + " set(value) {\n" + " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n" + " }\n"); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, context_->options(), @@ -861,7 +848,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$$kt_property_name$List$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" " )\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, diff --git a/src/google/protobuf/compiler/java/immutable/string_field.cc b/src/google/protobuf/compiler/java/immutable/string_field.cc index df12b05f07..c9ac5f4e7c 100644 --- a/src/google/protobuf/compiler/java/immutable/string_field.cc +++ b/src/google/protobuf/compiler/java/immutable/string_field.cc @@ -372,10 +372,10 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "$kt_deprecation$public var $kt_name$: kotlin.String\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" " set(value) {\n" - " $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n" + " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n" " }\n"); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, @@ -992,7 +992,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers( "\n" " @kotlin.jvm.JvmSynthetic\n" " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$$kt_property_name$List$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" " )\n"); // List.add(String) diff --git a/src/google/protobuf/compiler/java/lite/enum_field.cc b/src/google/protobuf/compiler/java/lite/enum_field.cc index b9cde7a483..f2fb340b1b 100644 --- a/src/google/protobuf/compiler/java/lite/enum_field.cc +++ b/src/google/protobuf/compiler/java/lite/enum_field.cc @@ -308,10 +308,10 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" " set(value) {\n" - " $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n" + " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n" " }\n"); if (SupportUnknownEnumValue(descriptor_)) { @@ -319,10 +319,10 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( variables_, "$kt_deprecation$public var $kt_name$Value: kotlin.Int\n" " @JvmName(\"${$get$kt_capitalized_name$Value$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_property_name$Value$}$\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$Value$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$Value$}$\")\n" " set(value) {\n" - " $kt_dsl_builder$.${$$kt_property_name$Value$}$ = value\n" + " $kt_dsl_builder$.${$set$capitalized_name$Value$}$(value)\n" " }\n"); } @@ -914,7 +914,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$$kt_property_name$List$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" " )\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, diff --git a/src/google/protobuf/compiler/java/lite/map_field.cc b/src/google/protobuf/compiler/java/lite/map_field.cc index 491523df91..74fc93f347 100644 --- a/src/google/protobuf/compiler/java/lite/map_field.cc +++ b/src/google/protobuf/compiler/java/lite/map_field.cc @@ -857,7 +857,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers( " @kotlin.jvm.JvmSynthetic\n" " @JvmName(\"get$kt_capitalized_name$Map\")\n" " get() = com.google.protobuf.kotlin.DslMap(\n" - " $kt_dsl_builder$.${$$kt_property_name$Map$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$Map$}$()\n" " )\n"); WriteFieldDocComment(printer, descriptor_, context_->options(), diff --git a/src/google/protobuf/compiler/java/lite/message_field.cc b/src/google/protobuf/compiler/java/lite/message_field.cc index c46407bf51..7c5cc3cf77 100644 --- a/src/google/protobuf/compiler/java/lite/message_field.cc +++ b/src/google/protobuf/compiler/java/lite/message_field.cc @@ -283,10 +283,10 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "$kt_deprecation$public var $kt_name$: $kt_type$\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" " set(value) {\n" - " $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n" + " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n" " }\n"); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, @@ -818,7 +818,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$$kt_property_name$List$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" " )\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, diff --git a/src/google/protobuf/compiler/java/lite/primitive_field.cc b/src/google/protobuf/compiler/java/lite/primitive_field.cc index c9b3a2947a..69924c9c83 100644 --- a/src/google/protobuf/compiler/java/lite/primitive_field.cc +++ b/src/google/protobuf/compiler/java/lite/primitive_field.cc @@ -217,9 +217,10 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateMembers( "private static final $field_type$ $bytes_default$ = $default$;\n"); } if (!context_->options().opensource_runtime) { - printer->Print(variables_, - "@com.google.protobuf.ProtoField(\n" - " isRequired=$required$)\n"); + printer->Print( + variables_, + "@com.google.protobuf.ProtoField(\n" + " isRequired=$required$)\n"); if (HasHasbit(descriptor_)) { printer->Print(variables_, "@com.google.protobuf.ProtoPresenceCheckedField(\n" @@ -328,27 +329,14 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateBuilderMembers( void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( io::Printer* printer) const { WriteFieldDocComment(printer, descriptor_, context_->options()); - if (descriptor_->name() == "is_initialized") { - printer->Print( - variables_, - "// TODO: b/336400327 - remove this hack; we should access properties\n" - "$kt_deprecation$public var $kt_name$: $kt_type$\n" - " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.get${$$kt_capitalized_name$$}$()\n" - " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" - " set(value) {\n" - " $kt_dsl_builder$.${$set$kt_capitalized_name$$}$(value)\n" - " }\n"); - } else { - printer->Print(variables_, - "$kt_deprecation$public var $kt_name$: $kt_type$\n" - " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n" - " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" - " set(value) {\n" - " $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n" - " }\n"); - } + printer->Print(variables_, + "$kt_deprecation$public var $kt_name$: $kt_type$\n" + " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" + " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" + " set(value) {\n" + " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n" + " }\n"); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, context_->options(), @@ -730,7 +718,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers( "<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n" " @kotlin.jvm.JvmSynthetic\n" " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$$kt_property_name$List$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" " )\n"); WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER, diff --git a/src/google/protobuf/compiler/java/lite/string_field.cc b/src/google/protobuf/compiler/java/lite/string_field.cc index a08bae50b6..833f415585 100644 --- a/src/google/protobuf/compiler/java/lite/string_field.cc +++ b/src/google/protobuf/compiler/java/lite/string_field.cc @@ -336,10 +336,10 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( printer->Print(variables_, "$kt_deprecation$public var $kt_name$: kotlin.String\n" " @JvmName(\"${$get$kt_capitalized_name$$}$\")\n" - " get() = $kt_dsl_builder$.${$$kt_safe_name$$}$\n" + " get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n" " @JvmName(\"${$set$kt_capitalized_name$$}$\")\n" " set(value) {\n" - " $kt_dsl_builder$.${$$kt_safe_name$$}$ = value\n" + " $kt_dsl_builder$.${$set$capitalized_name$$}$(value)\n" " }\n"); WriteFieldAccessorDocComment(printer, descriptor_, CLEARER, @@ -825,7 +825,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers( "@kotlin.OptIn" "(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n" " get() = com.google.protobuf.kotlin.DslList(\n" - " $kt_dsl_builder$.${$$kt_property_name$List$}$\n" + " $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n" " )\n"); // List.add(String)