Skip to content

Commit

Permalink
Fixing inlining and deprecation for repeated string fields in kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
deannagarcia committed Oct 19, 2021
1 parent a793c7f commit 33113ce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
35 changes: 17 additions & 18 deletions src/google/protobuf/compiler/java/java_string_field.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// Protocol Buffers - Google's data interchange format // Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -968,16 +967,14 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(

// property for List<String>
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(
variables_,
"public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");
printer->Print(variables_,
"$kt_deprecation$public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
" get() = com.google.protobuf.kotlin.DslList(\n"
" $kt_dsl_builder$.${$get$capitalized_name$List$}$()\n"
" )\n");

// List<String>.add(String)
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
Expand All @@ -994,13 +991,14 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
// List<String> += String
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
/* builder */ false);
printer->Print(variables_,
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"public operator fun com.google.protobuf.kotlin.DslList"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
"public inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: kotlin.String) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
" add(value)\n"
"}\n");

// List<String>.addAll(Iterable<String>)
Expand All @@ -1019,14 +1017,15 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
// List<String> += Iterable<String>
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
/* builder */ false);
printer->Print(
printer->Print(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"public operator fun com.google.protobuf.kotlin.DslList"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
"public inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
" addAll(values)\n"
"}\n");

// List<String>[Int] = String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(
variables_,
"public val $kt_name$: "
"$kt_deprecation$public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.OptIn"
Expand Down

0 comments on commit 33113ce

Please sign in to comment.