Skip to content

Commit 33113ce

Browse files
committed
Fixing inlining and deprecation for repeated string fields in kotlin
1 parent a793c7f commit 33113ce

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

src/google/protobuf/compiler/java/java_string_field.cc

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// Protocol Buffers - Google's data interchange format
2-
// Copyright 2008 Google Inc. All rights reserved.
1+
// Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved.
32
// https://developers.google.com/protocol-buffers/
43
//
54
// Redistribution and use in source and binary forms, with or without
@@ -968,16 +967,14 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
968967

969968
// property for List<String>
970969
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
971-
printer->Print(
972-
variables_,
973-
"public val $kt_name$: "
974-
"com.google.protobuf.kotlin.DslList"
975-
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
976-
" @kotlin.OptIn"
977-
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
978-
" get() = com.google.protobuf.kotlin.DslList(\n"
979-
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
980-
" )\n");
970+
printer->Print(variables_,
971+
"$kt_deprecation$public val $kt_name$: "
972+
"com.google.protobuf.kotlin.DslList"
973+
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
974+
" @kotlin.jvm.JvmSynthetic\n"
975+
" get() = com.google.protobuf.kotlin.DslList(\n"
976+
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
977+
" )\n");
981978

982979
// List<String>.add(String)
983980
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
@@ -994,13 +991,14 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
994991
// List<String> += String
995992
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
996993
/* builder */ false);
997-
printer->Print(variables_,
994+
printer->Print(variables_,
998995
"@kotlin.jvm.JvmSynthetic\n"
999996
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
1000-
"public operator fun com.google.protobuf.kotlin.DslList"
997+
"@Suppress(\"NOTHING_TO_INLINE\")\n"
998+
"public inline operator fun com.google.protobuf.kotlin.DslList"
1001999
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
10021000
"plusAssign(value: kotlin.String) {\n"
1003-
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
1001+
" add(value)\n"
10041002
"}\n");
10051003

10061004
// List<String>.addAll(Iterable<String>)
@@ -1019,14 +1017,15 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
10191017
// List<String> += Iterable<String>
10201018
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
10211019
/* builder */ false);
1022-
printer->Print(
1020+
printer->Print(
10231021
variables_,
10241022
"@kotlin.jvm.JvmSynthetic\n"
10251023
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
1026-
"public operator fun com.google.protobuf.kotlin.DslList"
1024+
"@Suppress(\"NOTHING_TO_INLINE\")\n"
1025+
"public inline operator fun com.google.protobuf.kotlin.DslList"
10271026
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
10281027
"plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
1029-
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
1028+
" addAll(values)\n"
10301029
"}\n");
10311030

10321031
// List<String>[Int] = String

src/google/protobuf/compiler/java/java_string_field_lite.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
755755
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
756756
printer->Print(
757757
variables_,
758-
"public val $kt_name$: "
758+
"$kt_deprecation$public val $kt_name$: "
759759
"com.google.protobuf.kotlin.DslList"
760760
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
761761
" @kotlin.OptIn"

0 commit comments

Comments
 (0)