aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangskz <89936743+zhangskz@users.noreply.github.com>2021-09-14 09:39:58 -0700
committerGitHub <noreply@github.com>2021-09-14 09:39:58 -0700
commit69b0a78315b464e6d4b1b87845cab409cc87dfe7 (patch)
tree4360ecd5111a6b84d1b57259920d3283bda1e71d
parent5f55fe1d6b2ee4b8d54d83eb49279089e5b67b9f (diff)
parent0fe47f3971b2363a82c4f29bfd9f1c49af56a110 (diff)
downloadprotobuf-69b0a78315b464e6d4b1b87845cab409cc87dfe7.tar.gz
Merge pull request #8968 from zhangskz/sync-stage
Integrate from Piper for C++, Java, and Python
-rw-r--r--CHANGES.txt9
-rwxr-xr-xconformance/conformance_nodejs.js61
-rw-r--r--java/core/src/main/java/com/google/protobuf/CodedInputStream.java6
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java33
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapForProto2Test.java41
-rw-r--r--java/core/src/test/java/com/google/protobuf/MapTest.java34
-rwxr-xr-xpython/google/protobuf/internal/_parameterized.py4
-rwxr-xr-xpython/setup.py26
-rw-r--r--src/google/protobuf/arena.h2
-rw-r--r--src/google/protobuf/arena_impl.h5
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc6
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc2
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field.cc29
-rw-r--r--src/google/protobuf/compiler/java/java_enum_field_lite.cc29
-rw-r--r--src/google/protobuf/compiler/java/java_map_field.cc23
-rw-r--r--src/google/protobuf/compiler/java/java_map_field_lite.cc14
-rw-r--r--src/google/protobuf/compiler/java/java_message.cc45
-rw-r--r--src/google/protobuf/compiler/java/java_message_field.cc29
-rw-r--r--src/google/protobuf/compiler/java/java_message_field_lite.cc29
-rw-r--r--src/google/protobuf/compiler/java/java_message_lite.cc45
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field.cc29
-rw-r--r--src/google/protobuf/compiler/java/java_primitive_field_lite.cc29
-rw-r--r--src/google/protobuf/compiler/java/java_string_field.cc29
-rw-r--r--src/google/protobuf/compiler/java/java_string_field_lite.cc29
-rw-r--r--src/google/protobuf/descriptor.cc124
-rw-r--r--src/google/protobuf/descriptor.h55
-rw-r--r--src/google/protobuf/extension_set.cc5
-rw-r--r--src/google/protobuf/extension_set.h5
-rw-r--r--src/google/protobuf/generated_message_reflection.cc18
-rw-r--r--src/google/protobuf/io/tokenizer.cc3
-rw-r--r--src/google/protobuf/message.h2
31 files changed, 461 insertions, 339 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 835281ff5..fd20488e4 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,7 @@
Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
+ Protocol Compiler
+ * Make proto2::Message::DiscardUnknownFields() non-virtual
+
Python
* Removed Python 2.x support.
* Pure python descriptor_pool.AddSerializedFile() will always build the
@@ -11,10 +14,16 @@ Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++
* Generated code now uses the c++11 standard integer types int{32,64}_t and
uint{32,64}_t
+ * Reduce memory usage of the DescriptorPool type.
Java
* Add @deprecated javadoc for set/get/has methods
* correctly decode \? escape sequence in text protos
+ * Avoid depending on Objects.requireNonNull() until we can verify that no users are depending on older Android versions.
+ * disallow null string map values in put and putAll
+
+ Kotlin
+ * Generated Kotlin code is Explicit API mode compatible
Unreleased Changes (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
C++
diff --git a/conformance/conformance_nodejs.js b/conformance/conformance_nodejs.js
index 4d96a3851..95da893f7 100755
--- a/conformance/conformance_nodejs.js
+++ b/conformance/conformance_nodejs.js
@@ -1,36 +1,33 @@
#!/usr/bin/env node
-
-/*
- * 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
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
+// 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
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
var conformance = require('conformance_pb');
var test_messages_proto3 = require('google/protobuf/test_messages_proto3_pb');
diff --git a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
index 0b935cb5a..6e9c0f620 100644
--- a/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
+++ b/java/core/src/main/java/com/google/protobuf/CodedInputStream.java
@@ -404,9 +404,9 @@ public abstract class CodedInputStream {
*
* <p>Set the maximum message size. In order to prevent malicious messages from exhausting memory
* or causing integer overflows, {@code CodedInputStream} limits how large a message may be. The
- * default limit is {@code Integer.MAX_INT}. You should set this limit as small as you can without
- * harming your app's functionality. Note that size limits only apply when reading from an {@code
- * InputStream}, not when constructed around a raw byte array.
+ * default limit is {@code Integer.MAX_VALUE}. You should set this limit as small as you can
+ * without harming your app's functionality. Note that size limits only apply when reading from an
+ * {@code InputStream}, not when constructed around a raw byte array.
*
* <p>If you want to read several messages from a single CodedInputStream, you could call {@link
* #resetSizeCounter()} after each one to avoid hitting the size limit.
diff --git a/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java b/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
index b143dce9b..ed0773988 100644
--- a/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
+++ b/java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java
@@ -32,6 +32,7 @@ package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.fail;
import map_lite_test.MapForProto2TestProto.BizarroTestMap;
import map_lite_test.MapForProto2TestProto.TestMap;
@@ -43,6 +44,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
+import java.util.TreeMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -803,4 +805,35 @@ public final class MapForProto2LiteTest {
// expected
}
}
+
+ @Test
+ public void testPutAllWithNullStringValue() throws Exception {
+ TestMap.Builder sourceBuilder = TestMap.newBuilder();
+
+ // order preserving map used here to help test rollback
+ Map<Integer, String> data = new TreeMap<>();
+ data.put(7, "foo");
+ data.put(8, "bar");
+ data.put(9, null);
+ try {
+ sourceBuilder.putAllInt32ToStringField(data);
+ fail("allowed null string value");
+ } catch (NullPointerException expected) {
+ // Verify rollback of previously added values.
+ // They all go in or none do.
+ assertThat(sourceBuilder.getInt32ToStringFieldMap()).isEmpty();
+ }
+ }
+
+ @Test
+ public void testPutNullStringValue() throws Exception {
+ TestMap.Builder sourceBuilder = TestMap.newBuilder();
+
+ try {
+ sourceBuilder.putInt32ToStringField(8, null);
+ fail("allowed null string value");
+ } catch (NullPointerException expected) {
+ }
+ }
+
}
diff --git a/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
index 821b93cf2..1d6a0ddea 100644
--- a/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
+++ b/java/core/src/test/java/com/google/protobuf/MapForProto2Test.java
@@ -32,6 +32,8 @@ package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import com.google.protobuf.Descriptors.FieldDescriptor;
import map_test.MapForProto2TestProto.BizarroTestMap;
@@ -51,6 +53,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -485,13 +488,6 @@ public class MapForProto2Test {
TestMap.Builder builder = TestMap.newBuilder();
try {
- builder.putInt32ToStringField(1, null);
- assertWithMessage("expected exception").fail();
- } catch (NullPointerException e) {
- // expected.
- }
-
- try {
builder.putInt32ToBytesField(1, null);
assertWithMessage("expected exception").fail();
} catch (NullPointerException e) {
@@ -1218,4 +1214,35 @@ public class MapForProto2Test {
assertThat(message.getInt32ToEnumFieldMap()).isEqualTo(message.getInt32ToEnumFieldMap());
assertThat(message.getInt32ToMessageFieldMap()).isEqualTo(message.getInt32ToMessageFieldMap());
}
+
+ @Test
+ public void testPutAllWithNullStringValue() throws Exception {
+ TestMap.Builder sourceBuilder = TestMap.newBuilder();
+
+ // order preserving map used here to help test rollback
+ Map<Integer, String> data = new TreeMap<>();
+ data.put(7, "foo");
+ data.put(8, "bar");
+ data.put(9, null);
+ try {
+ sourceBuilder.putAllInt32ToStringField(data);
+ fail("allowed null string value");
+ } catch (NullPointerException expected) {
+ // Verify rollback of previously added values.
+ // They all go in or none do.
+ assertThat(sourceBuilder.getInt32ToStringFieldMap()).isEmpty();
+ }
+ }
+
+ @Test
+ public void testPutNullStringValue() throws Exception {
+ TestMap.Builder sourceBuilder = TestMap.newBuilder();
+
+ try {
+ sourceBuilder.putInt32ToStringField(8, null);
+ fail("allowed null string value");
+ } catch (NullPointerException expected) {
+ assertNotNull(expected.getMessage());
+ }
+ }
}
diff --git a/java/core/src/test/java/com/google/protobuf/MapTest.java b/java/core/src/test/java/com/google/protobuf/MapTest.java
index cc7a1217d..34df94523 100644
--- a/java/core/src/test/java/com/google/protobuf/MapTest.java
+++ b/java/core/src/test/java/com/google/protobuf/MapTest.java
@@ -32,6 +32,8 @@ package com.google.protobuf;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.EnumDescriptor;
@@ -50,6 +52,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -465,6 +468,37 @@ public class MapTest {
}
@Test
+ public void testPutAllWithNullStringValue() throws Exception {
+ TestMap.Builder sourceBuilder = TestMap.newBuilder();
+
+ // order preserving map used here to help test rollback
+ Map<Integer, String> data = new TreeMap<>();
+ data.put(7, "foo");
+ data.put(8, "bar");
+ data.put(9, null);
+ try {
+ sourceBuilder.putAllInt32ToStringField(data);
+ fail("allowed null string value");
+ } catch (NullPointerException expected) {
+ // Verify rollback of previously added values.
+ // They all go in or none do.
+ assertThat(sourceBuilder.getInt32ToStringFieldMap()).isEmpty();
+ }
+ }
+
+ @Test
+ public void testPutNullStringValue() throws Exception {
+ TestMap.Builder sourceBuilder = TestMap.newBuilder();
+
+ try {
+ sourceBuilder.putInt32ToStringField(8, null);
+ fail("allowed null string value");
+ } catch (NullPointerException expected) {
+ assertNotNull(expected.getMessage());
+ }
+ }
+
+ @Test
public void testPutAllForUnknownEnumValues() throws Exception {
TestMap source =
TestMap.newBuilder()
diff --git a/python/google/protobuf/internal/_parameterized.py b/python/google/protobuf/internal/_parameterized.py
index 287ba689b..2229671ed 100755
--- a/python/google/protobuf/internal/_parameterized.py
+++ b/python/google/protobuf/internal/_parameterized.py
@@ -178,8 +178,8 @@ def _StrClass(cls):
def _NonStringIterable(obj):
- return (isinstance(obj, collections_abc.Iterable) and not
- isinstance(obj, str))
+ return (isinstance(obj, collections_abc.Iterable) and
+ not isinstance(obj, str))
def _FormatParameterList(testcase_params):
diff --git a/python/setup.py b/python/setup.py
index 7450445a1..33d74203c 100755
--- a/python/setup.py
+++ b/python/setup.py
@@ -158,19 +158,21 @@ class build_py(_build_py):
if not any(fnmatch.fnmatchcase(fil, pat=pat) for pat in exclude)]
class build_ext(_build_ext):
+
def get_ext_filename(self, ext_name):
- # since python3.5, python extensions' shared libraries use a suffix that corresponds to the value
- # of sysconfig.get_config_var('EXT_SUFFIX') and contains info about the architecture the library targets.
- # E.g. on x64 linux the suffix is ".cpython-XYZ-x86_64-linux-gnu.so"
- # When crosscompiling python wheels, we need to be able to override this suffix
- # so that the resulting file name matches the target architecture and we end up with a well-formed
- # wheel.
- filename = _build_ext.get_ext_filename(self, ext_name)
- orig_ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
- new_ext_suffix = os.getenv("PROTOCOL_BUFFERS_OVERRIDE_EXT_SUFFIX")
- if new_ext_suffix and filename.endswith(orig_ext_suffix):
- filename = filename[:-len(orig_ext_suffix)] + new_ext_suffix
- return filename
+ # since python3.5, python extensions' shared libraries use a suffix that
+ # corresponds to the value of sysconfig.get_config_var('EXT_SUFFIX') and
+ # contains info about the architecture the library targets. E.g. on x64
+ # linux the suffix is ".cpython-XYZ-x86_64-linux-gnu.so" When
+ # crosscompiling python wheels, we need to be able to override this
+ # suffix so that the resulting file name matches the target architecture
+ # and we end up with a well-formed wheel.
+ filename = _build_ext.get_ext_filename(self, ext_name)
+ orig_ext_suffix = sysconfig.get_config_var("EXT_SUFFIX")
+ new_ext_suffix = os.getenv("PROTOCOL_BUFFERS_OVERRIDE_EXT_SUFFIX")
+ if new_ext_suffix and filename.endswith(orig_ext_suffix):
+ filename = filename[:-len(orig_ext_suffix)] + new_ext_suffix
+ return filename
class test_conformance(_build_py):
target = 'test_python'
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h
index f6d873be6..54a765021 100644
--- a/src/google/protobuf/arena.h
+++ b/src/google/protobuf/arena.h
@@ -497,7 +497,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
return new (ptr) T(static_cast<Args&&>(args)...);
}
- static T* New() {
+ static inline PROTOBUF_ALWAYS_INLINE T* New() {
return new T(nullptr);
}
diff --git a/src/google/protobuf/arena_impl.h b/src/google/protobuf/arena_impl.h
index d7e69c117..302d4cd43 100644
--- a/src/google/protobuf/arena_impl.h
+++ b/src/google/protobuf/arena_impl.h
@@ -476,9 +476,8 @@ class PROTOBUF_EXPORT ThreadSafeArena {
};
static CacheAlignedLifecycleIdGenerator lifecycle_id_generator_;
#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)
- // Android ndk does not support __thread keyword so we use a custom thread
- // local storage class we implemented.
- // iOS also does not support the __thread keyword.
+ // iOS does not support __thread keyword so we use a custom thread local
+ // storage class we implemented.
static ThreadCache& thread_cache();
#elif defined(PROTOBUF_USE_DLLS)
// Thread local variables cannot be exposed through DLL interface but we can
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index 7dc7e89af..21faff39d 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -1716,12 +1716,6 @@ void MessageGenerator::GenerateClassDefinition(io::Printer* printer) {
"$uint8$* _InternalSerialize(\n"
" $uint8$* target, ::$proto_ns$::io::EpsCopyOutputStream* stream) "
"const final;\n");
-
- // DiscardUnknownFields() is implemented in message.cc using reflections.
- // We need to implement this function in generated code for messages.
- if (!UseUnknownFieldSet(descriptor_->file(), options_)) {
- format("void DiscardUnknownFields()$ full_final$;\n");
- }
}
}
diff --git a/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc b/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
index 8b181206d..cf264173d 100644
--- a/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_parse_function_generator.cc
@@ -859,7 +859,7 @@ void ParseFunctionGenerator::GenerateFieldBody(
field->number());
}
} else {
- std::string size = (field->type() == FieldDescriptor::TYPE_INT32 ||
+ std::string size = (field->type() == FieldDescriptor::TYPE_INT32 ||
field->type() == FieldDescriptor::TYPE_SINT32 ||
field->type() == FieldDescriptor::TYPE_UINT32)
? "32"
diff --git a/src/google/protobuf/compiler/java/java_enum_field.cc b/src/google/protobuf/compiler/java/java_enum_field.cc
index a9216b716..0dad42ada 100644
--- a/src/google/protobuf/compiler/java/java_enum_field.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field.cc
@@ -280,7 +280,7 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$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"
@@ -291,16 +291,17 @@ void ImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
}
@@ -1081,12 +1082,12 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -1099,7 +1100,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -1111,7 +1112,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -1122,7 +1123,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -1135,7 +1136,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
@@ -1147,7 +1148,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
@@ -1158,7 +1159,7 @@ void RepeatedImmutableEnumFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_enum_field_lite.cc b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
index a6037a12a..ca3a2e880 100644
--- a/src/google/protobuf/compiler/java/java_enum_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_enum_field_lite.cc
@@ -285,7 +285,7 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$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"
@@ -296,16 +296,17 @@ void ImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
}
@@ -823,12 +824,12 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -841,7 +842,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -853,7 +854,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -864,7 +865,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -877,7 +878,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
@@ -889,7 +890,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
@@ -900,7 +901,7 @@ void RepeatedImmutableEnumFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_map_field.cc b/src/google/protobuf/compiler/java/java_map_field.cc
index 29c710912..8a8910071 100644
--- a/src/google/protobuf/compiler/java/java_map_field.cc
+++ b/src/google/protobuf/compiler/java/java_map_field.cc
@@ -111,11 +111,13 @@ void SetMessageVariables(const FieldDescriptor* descriptor, int messageBitIndex,
(*variables)["key_default_value"] = DefaultValue(key, true, name_resolver);
(*variables)["key_null_check"] =
IsReferenceType(keyJavaType)
- ? "if (key == null) { throw new java.lang.NullPointerException(); }"
+ ? "if (key == null) { throw new NullPointerException(\"map key\"); }"
: "";
(*variables)["value_null_check"] =
- IsReferenceType(valueJavaType)
- ? "if (value == null) { throw new java.lang.NullPointerException(); }"
+ valueJavaType != JAVATYPE_ENUM && IsReferenceType(valueJavaType)
+ ? "if (value == null) {\n"
+ " throw new NullPointerException(\"map value\");\n"
+ "}\n"
: "";
if (valueJavaType == JAVATYPE_ENUM) {
// We store enums as Integers internally.
@@ -435,6 +437,7 @@ void ImmutableMapFieldGenerator::GenerateBuilderMembers(
" $key_type$ key,\n"
" $value_type$ value) {\n"
" $key_null_check$\n"
+ " $value_null_check$\n"
" internalGetMutable$capitalized_name$().getMutableMap()\n"
" .put(key, value);\n"
" return this;\n"
@@ -679,13 +682,13 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -698,7 +701,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
printer->Print(
variables_,
"@JvmName(\"put$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .put(key: $kt_key_type$, value: $kt_value_type$) {\n"
" $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n"
@@ -710,7 +713,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"set$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslMap"
+ "public inline operator fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .set(key: $kt_key_type$, value: $kt_value_type$) {\n"
" put(key, value)\n"
@@ -721,7 +724,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"remove$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .remove(key: $kt_key_type$) {\n"
" $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n"
@@ -732,7 +735,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"putAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) "
"{\n"
@@ -744,7 +747,7 @@ void ImmutableMapFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_map_field_lite.cc b/src/google/protobuf/compiler/java/java_map_field_lite.cc
index e8ba20fcf..e71116866 100644
--- a/src/google/protobuf/compiler/java/java_map_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_map_field_lite.cc
@@ -822,13 +822,13 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(
variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -841,7 +841,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(
variables_,
"@JvmName(\"put$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .put(key: $kt_key_type$, value: $kt_value_type$) {\n"
" $kt_dsl_builder$.${$put$capitalized_name$$}$(key, value)\n"
@@ -853,7 +853,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"set$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslMap"
+ "public inline operator fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .set(key: $kt_key_type$, value: $kt_value_type$) {\n"
" put(key, value)\n"
@@ -864,7 +864,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"remove$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .remove(key: $kt_key_type$) {\n"
" $kt_dsl_builder$.${$remove$capitalized_name$$}$(key)\n"
@@ -875,7 +875,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"putAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .putAll(map: kotlin.collections.Map<$kt_key_type$, $kt_value_type$>) "
"{\n"
@@ -887,7 +887,7 @@ void ImmutableMapFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslMap"
+ "public fun com.google.protobuf.kotlin.DslMap"
"<$kt_key_type$, $kt_value_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" .clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc
index 99e2aa2e3..27d1014f6 100644
--- a/src/google/protobuf/compiler/java/java_message.cc
+++ b/src/google/protobuf/compiler/java/java_message.cc
@@ -1407,10 +1407,10 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@com.google.protobuf.kotlin.ProtoDslMarker\n");
printer->Print(
- "class Dsl private constructor(\n"
+ "public class Dsl private constructor(\n"
" private val _builder: $message$.Builder\n"
") {\n"
- " companion object {\n"
+ " public companion object {\n"
" @kotlin.jvm.JvmSynthetic\n"
" @kotlin.PublishedApi\n"
" internal fun _create(builder: $message$.Builder): Dsl = "
@@ -1432,10 +1432,10 @@ void ImmutableMessageGenerator::GenerateKotlinDsl(io::Printer* printer) const {
for (auto oneof : oneofs_) {
printer->Print(
- "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
+ "public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
" @JvmName(\"get$oneof_capitalized_name$Case\")\n"
" get() = _builder.get$oneof_capitalized_name$Case()\n\n"
- "fun clear$oneof_capitalized_name$() {\n"
+ "public fun clear$oneof_capitalized_name$() {\n"
" _builder.clear$oneof_capitalized_name$()\n"
"}\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
@@ -1456,7 +1456,8 @@ void ImmutableMessageGenerator::GenerateKotlinMembers(
io::Printer* printer) const {
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> kotlin.Unit): "
+ "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
+ "kotlin.Unit): "
"$message$ "
"=\n"
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
@@ -1465,7 +1466,7 @@ void ImmutableMessageGenerator::GenerateKotlinMembers(
"message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
"message", name_resolver_->GetClassName(descriptor_, true));
- printer->Print("object $name$Kt {\n", "name", descriptor_->name());
+ printer->Print("public object $name$Kt {\n", "name", descriptor_->name());
printer->Indent();
GenerateKotlinDsl(printer);
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
@@ -1481,7 +1482,8 @@ void ImmutableMessageGenerator::GenerateTopLevelKotlinMembers(
io::Printer* printer) const {
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "inline fun $message$.copy(block: $message_kt$.Dsl.() -> kotlin.Unit): "
+ "public inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
+ "kotlin.Unit): "
"$message$ =\n"
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
"}._build()\n",
@@ -1502,7 +1504,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun <T> get(extension: "
+ "public operator fun <T> get(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
" return if (extension.isRepeated) {\n"
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
@@ -1518,7 +1520,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "operator fun <E> get(\n"
+ "public operator fun <E> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
@@ -1528,7 +1530,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun contains(extension: "
+ "public operator fun contains(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>): "
"Boolean {\n"
" return _builder.hasExtension(extension)\n"
@@ -1537,7 +1539,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun clear(extension: com.google.protobuf.ExtensionLite<$message$, *>) "
+ "public fun clear(extension: "
+ "com.google.protobuf.ExtensionLite<$message$, *>) "
"{\n"
" _builder.clearExtension(extension)\n"
"}\n\n",
@@ -1556,7 +1559,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <T : Comparable<T>> set(\n"
+ "public inline operator fun <T : Comparable<T>> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -1567,7 +1570,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun set(\n"
+ "public inline operator fun set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, "
"com.google.protobuf.ByteString>,\n"
" value: com.google.protobuf.ByteString\n"
@@ -1579,7 +1582,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
+ "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -1589,7 +1592,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.add(value: E) {\n"
" _builder.addExtension(this.extension, value)\n"
"}\n\n",
@@ -1598,7 +1601,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public inline operator fun <E> "
+ "com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
" add(value)\n"
@@ -1607,7 +1611,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.addAll(values: Iterable<E>) {\n"
" for (value in values) {\n"
" add(value)\n"
@@ -1618,7 +1622,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public inline operator fun <E> "
+ "com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
" addAll(values)\n"
@@ -1627,7 +1632,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"
" _builder.setExtension(this.extension, index, value)\n"
@@ -1637,7 +1642,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
+ "public inline fun com.google.protobuf.kotlin.ExtensionList<*, "
"$message$>.clear() {\n"
" clear(extension)\n"
"}\n\n",
diff --git a/src/google/protobuf/compiler/java/java_message_field.cc b/src/google/protobuf/compiler/java/java_message_field.cc
index 137e3e203..8aae96145 100644
--- a/src/google/protobuf/compiler/java/java_message_field.cc
+++ b/src/google/protobuf/compiler/java/java_message_field.cc
@@ -417,7 +417,7 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$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"
@@ -428,15 +428,16 @@ void ImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
void ImmutableMessageFieldGenerator::GenerateFieldBuilderInitializationCode(
@@ -1403,12 +1404,12 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -1421,7 +1422,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -1433,7 +1434,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -1444,7 +1445,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -1457,7 +1458,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
@@ -1469,7 +1470,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
@@ -1480,7 +1481,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_message_field_lite.cc b/src/google/protobuf/compiler/java/java_message_field_lite.cc
index d9e44c92d..1c4d016d3 100644
--- a/src/google/protobuf/compiler/java/java_message_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_field_lite.cc
@@ -287,7 +287,7 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$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"
@@ -298,15 +298,16 @@ void ImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
void ImmutableMessageFieldLiteGenerator::GenerateFieldInfo(
@@ -793,12 +794,12 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -811,7 +812,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -823,7 +824,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -834,7 +835,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -847,7 +848,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
@@ -859,7 +860,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
@@ -870,7 +871,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc
index 7e67349a5..c2c278890 100644
--- a/src/google/protobuf/compiler/java/java_message_lite.cc
+++ b/src/google/protobuf/compiler/java/java_message_lite.cc
@@ -731,10 +731,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@com.google.protobuf.kotlin.ProtoDslMarker\n");
printer->Print(
- "class Dsl private constructor(\n"
+ "public class Dsl private constructor(\n"
" private val _builder: $message$.Builder\n"
") {\n"
- " companion object {\n"
+ " public companion object {\n"
" @kotlin.jvm.JvmSynthetic\n"
" @kotlin.PublishedApi\n"
" internal fun _create(builder: $message$.Builder): Dsl = "
@@ -756,10 +756,10 @@ void ImmutableMessageLiteGenerator::GenerateKotlinDsl(
for (auto oneof : oneofs_) {
printer->Print(
- "val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
+ "public val $oneof_name$Case: $message$.$oneof_capitalized_name$Case\n"
" @JvmName(\"get$oneof_capitalized_name$Case\")\n"
" get() = _builder.get$oneof_capitalized_name$Case()\n\n"
- "fun clear$oneof_capitalized_name$() {\n"
+ "public fun clear$oneof_capitalized_name$() {\n"
" _builder.clear$oneof_capitalized_name$()\n"
"}\n",
"oneof_name", context_->GetOneofGeneratorInfo(oneof)->name,
@@ -780,7 +780,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
io::Printer* printer) const {
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> kotlin.Unit): "
+ "public inline fun $camelcase_name$(block: $message_kt$.Dsl.() -> "
+ "kotlin.Unit): "
"$message$ =\n"
" $message_kt$.Dsl._create($message$.newBuilder()).apply { block() "
"}._build()\n",
@@ -788,7 +789,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
"message_kt", name_resolver_->GetKotlinExtensionsClassName(descriptor_),
"message", name_resolver_->GetClassName(descriptor_, true));
- printer->Print("object $name$Kt {\n", "name", descriptor_->name());
+ printer->Print("public object $name$Kt {\n", "name", descriptor_->name());
printer->Indent();
GenerateKotlinDsl(printer);
for (int i = 0; i < descriptor_->nested_type_count(); i++) {
@@ -803,7 +804,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinMembers(
void ImmutableMessageLiteGenerator::GenerateTopLevelKotlinMembers(
io::Printer* printer) const {
printer->Print(
- "inline fun $message$.copy(block: $message_kt$.Dsl.() -> kotlin.Unit): "
+ "public inline fun $message$.copy(block: $message_kt$.Dsl.() -> "
+ "kotlin.Unit): "
"$message$ =\n"
" $message_kt$.Dsl._create(this.toBuilder()).apply { block() "
"}._build()\n",
@@ -824,7 +826,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@Suppress(\"UNCHECKED_CAST\")\n"
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun <T> get(extension: "
+ "public operator fun <T> get(extension: "
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
" return if (extension.isRepeated) {\n"
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
@@ -840,7 +842,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
- "operator fun <E> get(\n"
+ "public operator fun <E> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
@@ -850,7 +852,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun contains(extension: "
+ "public operator fun contains(extension: "
"com.google.protobuf.ExtensionLite<$message$, *>): "
"Boolean {\n"
" return _builder.hasExtension(extension)\n"
@@ -859,7 +861,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun clear(extension: com.google.protobuf.ExtensionLite<$message$, *>) "
+ "public fun clear(extension: "
+ "com.google.protobuf.ExtensionLite<$message$, *>) "
"{\n"
" _builder.clearExtension(extension)\n"
"}\n\n",
@@ -878,7 +881,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <T : Comparable<T>> set(\n"
+ "public inline operator fun <T : Comparable<T>> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -889,7 +892,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun set(\n"
+ "public inline operator fun set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, "
"com.google.protobuf.ByteString>,\n"
" value: com.google.protobuf.ByteString\n"
@@ -901,7 +904,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
+ "public inline operator fun <T : com.google.protobuf.MessageLite> set(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, T>,\n"
" value: T\n"
") {\n"
@@ -911,7 +914,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public fun<E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.add(value: E) {\n"
" _builder.addExtension(this.extension, value)\n"
"}\n\n",
@@ -920,7 +923,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public inline operator fun <E> "
+ "com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign"
"(value: E) {\n"
" add(value)\n"
@@ -929,7 +933,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public fun<E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.addAll(values: Iterable<E>) {\n"
" for (value in values) {\n"
" add(value)\n"
@@ -940,7 +944,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public inline operator fun <E> "
+ "com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.plusAssign(values: "
"Iterable<E>) {\n"
" addAll(values)\n"
@@ -949,7 +954,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
- "operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
+ "public operator fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
"$message$>.set(index: Int, value: "
"E) {\n"
" _builder.setExtension(this.extension, index, value)\n"
@@ -959,7 +964,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
printer->Print(
"@kotlin.jvm.JvmSynthetic\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline fun com.google.protobuf.kotlin.ExtensionList<*, "
+ "public inline fun com.google.protobuf.kotlin.ExtensionList<*, "
"$message$>.clear() {\n"
" clear(extension)\n"
"}\n\n",
diff --git a/src/google/protobuf/compiler/java/java_primitive_field.cc b/src/google/protobuf/compiler/java/java_primitive_field.cc
index 8cf8c3b38..6e51c16e3 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field.cc
@@ -307,7 +307,7 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$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"
@@ -318,16 +318,17 @@ void ImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
}
@@ -835,12 +836,12 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -853,7 +854,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -865,7 +866,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -876,7 +877,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -889,7 +890,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
@@ -901,7 +902,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
@@ -912,7 +913,7 @@ void RepeatedImmutablePrimitiveFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
index 4ff7152df..8167aa647 100644
--- a/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_primitive_field_lite.cc
@@ -313,7 +313,7 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: $kt_type$\n"
+ "$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"
@@ -324,16 +324,17 @@ void ImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
}
@@ -658,12 +659,12 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$ val $kt_name$: "
+ "$kt_deprecation$ public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.jvm.JvmSynthetic\n"
@@ -676,7 +677,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: $kt_type$) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -688,7 +689,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: $kt_type$) {\n"
" add(value)\n"
@@ -699,7 +700,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -712,7 +713,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
" addAll(values)\n"
@@ -724,7 +725,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: $kt_type$) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
@@ -735,7 +736,7 @@ void RepeatedImmutablePrimitiveFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_string_field.cc b/src/google/protobuf/compiler/java/java_string_field.cc
index 248e98ccb..28164c763 100644
--- a/src/google/protobuf/compiler/java/java_string_field.cc
+++ b/src/google/protobuf/compiler/java/java_string_field.cc
@@ -379,7 +379,7 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: kotlin.String\n"
+ "$kt_deprecation$public var $kt_name$: kotlin.String\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -390,16 +390,17 @@ void ImmutableStringFieldGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
}
@@ -962,14 +963,14 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
// property for List<String>
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(
variables_,
- "val $kt_name$: "
+ "public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.OptIn"
@@ -984,7 +985,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: kotlin.String) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -996,7 +997,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public 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"
@@ -1009,7 +1010,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -1022,7 +1023,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public 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"
@@ -1035,7 +1036,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: kotlin.String) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
@@ -1046,7 +1047,7 @@ void RepeatedImmutableStringFieldGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/compiler/java/java_string_field_lite.cc b/src/google/protobuf/compiler/java/java_string_field_lite.cc
index a0408f186..57cd43677 100644
--- a/src/google/protobuf/compiler/java/java_string_field_lite.cc
+++ b/src/google/protobuf/compiler/java/java_string_field_lite.cc
@@ -313,7 +313,7 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
io::Printer* printer) const {
WriteFieldDocComment(printer, descriptor_);
printer->Print(variables_,
- "$kt_deprecation$var $kt_name$: kotlin.String\n"
+ "$kt_deprecation$public var $kt_name$: kotlin.String\n"
" @JvmName(\"${$get$kt_capitalized_name$$}$\")\n"
" get() = $kt_dsl_builder$.${$get$capitalized_name$$}$()\n"
" @JvmName(\"${$set$kt_capitalized_name$$}$\")\n"
@@ -324,16 +324,17 @@ void ImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
/* builder */ false);
printer->Print(variables_,
- "fun ${$clear$kt_capitalized_name$$}$() {\n"
+ "public fun ${$clear$kt_capitalized_name$$}$() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
"}\n");
if (HasHazzer(descriptor_)) {
WriteFieldAccessorDocComment(printer, descriptor_, HAZZER);
- printer->Print(variables_,
- "fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
- " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
- "}\n");
+ printer->Print(
+ variables_,
+ "public fun ${$has$kt_capitalized_name$$}$(): kotlin.Boolean {\n"
+ " return $kt_dsl_builder$.${$has$capitalized_name$$}$()\n"
+ "}\n");
}
}
@@ -747,14 +748,14 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
" */\n"
"@kotlin.OptIn"
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
- "class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
+ "public class ${$$kt_capitalized_name$Proxy$}$ private constructor()"
" : com.google.protobuf.kotlin.DslProxy()\n");
// property for List<String>
WriteFieldAccessorDocComment(printer, descriptor_, LIST_GETTER);
printer->Print(
variables_,
- "val $kt_name$: "
+ "public val $kt_name$: "
"com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>\n"
" @kotlin.OptIn"
@@ -769,7 +770,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"add$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"add(value: kotlin.String) {\n"
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
@@ -782,7 +783,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssign$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(value: kotlin.String) {\n"
" add(value)\n"
@@ -795,7 +796,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"addAll$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"addAll(values: kotlin.collections.Iterable<kotlin.String>) {\n"
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
@@ -809,7 +810,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"plusAssignAll$kt_capitalized_name$\")\n"
"@Suppress(\"NOTHING_TO_INLINE\")\n"
- "inline operator fun com.google.protobuf.kotlin.DslList"
+ "public inline operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"plusAssign(values: kotlin.collections.Iterable<kotlin.String>) {\n"
" addAll(values)\n"
@@ -822,7 +823,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"set$kt_capitalized_name$\")\n"
- "operator fun com.google.protobuf.kotlin.DslList"
+ "public operator fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"set(index: kotlin.Int, value: kotlin.String) {\n"
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
@@ -833,7 +834,7 @@ void RepeatedImmutableStringFieldLiteGenerator::GenerateKotlinDslMembers(
printer->Print(variables_,
"@kotlin.jvm.JvmSynthetic\n"
"@kotlin.jvm.JvmName(\"clear$kt_capitalized_name$\")\n"
- "fun com.google.protobuf.kotlin.DslList"
+ "public fun com.google.protobuf.kotlin.DslList"
"<kotlin.String, ${$$kt_capitalized_name$Proxy$}$>."
"clear() {\n"
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc
index c164f88f5..aa3f8b781 100644
--- a/src/google/protobuf/descriptor.cc
+++ b/src/google/protobuf/descriptor.cc
@@ -52,6 +52,7 @@
#include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/any.h>
#include <google/protobuf/descriptor.pb.h>
+#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
@@ -1148,6 +1149,10 @@ class DescriptorPool::Tables {
// The string is initialized to the given value for convenience.
const std::string* AllocateString(StringPiece value);
+ // Copy the input into a NUL terminated string whose lifetime is managed by
+ // the pool.
+ const char* Strdup(StringPiece value);
+
// Allocates an array of strings which will be destroyed when the pool is
// destroyed. The array is initialized with the input values.
template <typename... In>
@@ -1168,9 +1173,11 @@ class DescriptorPool::Tables {
const std::string& scope,
const std::string* opt_json_name);
- // Allocate a LazyInitData which will be destroyed when the pool is
- // destroyed.
- internal::LazyInitData* AllocateLazyInit();
+ // Create an object that will be deleted when the pool is destroyed.
+ // The object is value initialized, and its destructor will be called if
+ // non-trivial.
+ template <typename Type>
+ Type* Create();
// Allocate a protocol message object. Some older versions of GCC have
// trouble understanding explicit template instantiations in some cases, so
@@ -1690,6 +1697,13 @@ const std::string* DescriptorPool::Tables::AllocateString(
return arena_.Create<std::string>(value);
}
+const char* DescriptorPool::Tables::Strdup(StringPiece value) {
+ char* p = AllocateArray<char>(static_cast<int>(value.size() + 1));
+ memcpy(p, value.data(), value.size());
+ p[value.size()] = 0;
+ return p;
+}
+
template <typename... In>
const std::string* DescriptorPool::Tables::AllocateStringArray(In&&... values) {
auto& array = *arena_.Create<std::array<std::string, sizeof...(In)>>();
@@ -1770,8 +1784,9 @@ DescriptorPool::Tables::AllocateFieldNames(const std::string& name,
return result;
}
-internal::LazyInitData* DescriptorPool::Tables::AllocateLazyInit() {
- return arena_.Create<internal::LazyInitData>();
+template <typename Type>
+Type* DescriptorPool::Tables::Create() {
+ return arena_.Create<Type>();
}
template <typename Type>
@@ -4959,17 +4974,18 @@ FileDescriptor* DescriptorBuilder::BuildFileImpl(
result->dependencies_[i] = dependency;
if (pool_->lazily_build_dependencies_ && !dependency) {
if (result->dependencies_once_ == nullptr) {
- result->dependencies_once_ = tables_->AllocateLazyInit();
- result->dependencies_once_->file.dependencies_names =
- tables_->AllocateArray<const std::string*>(proto.dependency_size());
+ result->dependencies_once_ =
+ tables_->Create<FileDescriptor::LazyInitData>();
+ result->dependencies_once_->dependencies_names =
+ tables_->AllocateArray<const char*>(proto.dependency_size());
if (proto.dependency_size() > 0) {
- std::fill_n(result->dependencies_once_->file.dependencies_names,
+ std::fill_n(result->dependencies_once_->dependencies_names,
proto.dependency_size(), nullptr);
}
}
- result->dependencies_once_->file.dependencies_names[i] =
- tables_->AllocateString(proto.dependency(i));
+ result->dependencies_once_->dependencies_names[i] =
+ tables_->Strdup(proto.dependency(i));
}
}
@@ -6108,12 +6124,12 @@ void DescriptorBuilder::CrossLinkField(FieldDescriptor* field,
// Save the symbol names for later for lookup, and allocate the once
// object needed for the accessors.
std::string name = proto.type_name();
- field->type_once_ = tables_->AllocateLazyInit();
- field->type_once_->field.type_name = tables_->AllocateString(name);
- if (proto.has_default_value()) {
- field->type_once_->field.default_value_enum_name =
- tables_->AllocateString(proto.default_value());
- }
+ field->type_once_ = tables_->Create<internal::once_flag>();
+ field->type_descriptor_.lazy_type_name = tables_->Strdup(name);
+ field->lazy_default_value_enum_name_ =
+ proto.has_default_value() ? tables_->Strdup(proto.default_value())
+ : nullptr;
+
// AddFieldByNumber and AddExtension are done later in this function,
// and can/must be done if the field type was not found. The related
// error checking is not necessary when in lazily_build_dependencies_
@@ -7769,32 +7785,32 @@ Symbol DescriptorPool::CrossLinkOnDemandHelper(StringPiece name,
void FieldDescriptor::InternalTypeOnceInit() const {
GOOGLE_CHECK(file()->finished_building_ == true);
const EnumDescriptor* enum_type = nullptr;
- if (type_once_->field.type_name) {
- Symbol result = file()->pool()->CrossLinkOnDemandHelper(
- *type_once_->field.type_name, type_ == FieldDescriptor::TYPE_ENUM);
- if (result.type() == Symbol::MESSAGE) {
- type_ = FieldDescriptor::TYPE_MESSAGE;
- type_descriptor_.message_type = result.descriptor();
- } else if (result.type() == Symbol::ENUM) {
- type_ = FieldDescriptor::TYPE_ENUM;
- enum_type = type_descriptor_.enum_type = result.enum_descriptor();
- }
- }
- if (enum_type && !default_value_enum_) {
- if (type_once_->field.default_value_enum_name) {
+ Symbol result = file()->pool()->CrossLinkOnDemandHelper(
+ type_descriptor_.lazy_type_name, type_ == FieldDescriptor::TYPE_ENUM);
+ if (result.type() == Symbol::MESSAGE) {
+ type_ = FieldDescriptor::TYPE_MESSAGE;
+ type_descriptor_.message_type = result.descriptor();
+ } else if (result.type() == Symbol::ENUM) {
+ type_ = FieldDescriptor::TYPE_ENUM;
+ enum_type = type_descriptor_.enum_type = result.enum_descriptor();
+ }
+
+ if (enum_type) {
+ if (lazy_default_value_enum_name_) {
// Have to build the full name now instead of at CrossLink time,
// because enum_type may not be known at the time.
std::string name = enum_type->full_name();
// Enum values reside in the same scope as the enum type.
std::string::size_type last_dot = name.find_last_of('.');
if (last_dot != std::string::npos) {
- name = name.substr(0, last_dot) + "." +
- *type_once_->field.default_value_enum_name;
+ name = name.substr(0, last_dot) + "." + lazy_default_value_enum_name_;
} else {
- name = *type_once_->field.default_value_enum_name;
+ name = lazy_default_value_enum_name_;
}
Symbol result = file()->pool()->CrossLinkOnDemandHelper(name, true);
default_value_enum_ = result.enum_value_descriptor();
+ } else {
+ default_value_enum_ = nullptr;
}
if (!default_value_enum_) {
// We use the first defined value as the default
@@ -7814,7 +7830,7 @@ void FieldDescriptor::TypeOnceInit(const FieldDescriptor* to_init) {
// import building and cross linking of a field of a message.
const Descriptor* FieldDescriptor::message_type() const {
if (type_once_) {
- internal::call_once(type_once_->once, FieldDescriptor::TypeOnceInit, this);
+ internal::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
}
return type_ == TYPE_MESSAGE || type_ == TYPE_GROUP
? type_descriptor_.message_type
@@ -7823,14 +7839,14 @@ const Descriptor* FieldDescriptor::message_type() const {
const EnumDescriptor* FieldDescriptor::enum_type() const {
if (type_once_) {
- internal::call_once(type_once_->once, FieldDescriptor::TypeOnceInit, this);
+ internal::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
}
return type_ == TYPE_ENUM ? type_descriptor_.enum_type : nullptr;
}
const EnumValueDescriptor* FieldDescriptor::default_value_enum() const {
if (type_once_) {
- internal::call_once(type_once_->once, FieldDescriptor::TypeOnceInit, this);
+ internal::call_once(*type_once_, FieldDescriptor::TypeOnceInit, this);
}
return default_value_enum_;
}
@@ -7846,10 +7862,10 @@ const std::string& FieldDescriptor::PrintableNameForExtension() const {
void FileDescriptor::InternalDependenciesOnceInit() const {
GOOGLE_CHECK(finished_building_ == true);
- auto* names = dependencies_once_->file.dependencies_names;
+ auto* names = dependencies_once_->dependencies_names;
for (int i = 0; i < dependency_count(); i++) {
if (names[i]) {
- dependencies_[i] = pool_->FindFileByName(*names[i]);
+ dependencies_[i] = pool_->FindFileByName(names[i]);
}
}
}
@@ -7869,11 +7885,11 @@ const FileDescriptor* FileDescriptor::dependency(int index) const {
}
const Descriptor* MethodDescriptor::input_type() const {
- return input_type_.Get();
+ return input_type_.Get(service());
}
const Descriptor* MethodDescriptor::output_type() const {
- return output_type_.Get();
+ return output_type_.Get(service());
}
@@ -7891,31 +7907,21 @@ void LazyDescriptor::SetLazy(StringPiece name,
GOOGLE_CHECK(file && file->pool_);
GOOGLE_CHECK(file->pool_->lazily_build_dependencies_);
GOOGLE_CHECK(!file->finished_building_);
- once_ = file->pool_->tables_->AllocateLazyInit();
- once_->descriptor.file = file;
- once_->descriptor.name = file->pool_->tables_->AllocateString(name);
+ once_ = file->pool_->tables_->Create<internal::once_flag>();
+ lazy_name_ = file->pool_->tables_->Strdup(name);
}
-void LazyDescriptor::Once() {
+void LazyDescriptor::Once(const ServiceDescriptor* service) {
if (once_) {
- internal::call_once(once_->once, LazyDescriptor::OnceStatic, this);
+ internal::call_once(*once_, [&] {
+ auto* file = service->file();
+ GOOGLE_CHECK(file->finished_building_);
+ descriptor_ =
+ file->pool_->CrossLinkOnDemandHelper(lazy_name_, false).descriptor();
+ });
}
}
-void LazyDescriptor::OnceStatic(LazyDescriptor* lazy) { lazy->OnceInternal(); }
-
-void LazyDescriptor::OnceInternal() {
- auto* file = once_->descriptor.file;
- auto* name = once_->descriptor.name;
- GOOGLE_CHECK(file->finished_building_);
- if (!descriptor_ && name) {
- auto* descriptor =
- file->pool_->CrossLinkOnDemandHelper(*name, false).descriptor();
- if (descriptor != nullptr) {
- descriptor_ = descriptor;
- }
- }
-}
} // namespace internal
} // namespace protobuf
diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h
index a23f19d38..a87f1cb47 100644
--- a/src/google/protobuf/descriptor.h
+++ b/src/google/protobuf/descriptor.h
@@ -184,29 +184,6 @@ struct DebugStringOptions {
// Must be instantiated as mutable in a descriptor.
namespace internal {
-// Data required to do lazy initialization.
-struct PROTOBUF_EXPORT LazyInitData {
-#ifndef SWIG
- internal::once_flag once;
-#endif
- struct Field {
- const std::string* type_name;
- const std::string* default_value_enum_name;
- };
- struct Descriptor {
- const std::string* name;
- const FileDescriptor* file;
- };
- struct File {
- const std::string** dependencies_names;
- };
- union {
- Field field;
- Descriptor descriptor;
- File file;
- };
-};
-
class PROTOBUF_EXPORT LazyDescriptor {
public:
// Init function to be called at init time of a descriptor containing
@@ -232,18 +209,19 @@ class PROTOBUF_EXPORT LazyDescriptor {
// Returns the current value of the descriptor, thread-safe. If SetLazy(...)
// has been called, will do a one-time cross link of the type specified,
// building the descriptor file that contains the type if necessary.
- inline const Descriptor* Get() {
- Once();
+ inline const Descriptor* Get(const ServiceDescriptor* service) {
+ Once(service);
return descriptor_;
}
private:
- static void OnceStatic(LazyDescriptor* lazy);
- void OnceInternal();
- void Once();
+ void Once(const ServiceDescriptor* service);
- const Descriptor* descriptor_;
- LazyInitData* once_;
+ union {
+ const Descriptor* descriptor_;
+ const char* lazy_name_;
+ };
+ internal::once_flag* once_;
};
class PROTOBUF_EXPORT SymbolBase {
@@ -935,7 +913,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
const std::string* all_names_;
const FileDescriptor* file_;
- internal::LazyInitData* type_once_;
+ internal::once_flag* type_once_;
static void TypeOnceInit(const FieldDescriptor* to_init);
void InternalTypeOnceInit() const;
const Descriptor* containing_type_;
@@ -946,6 +924,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
union {
mutable const Descriptor* message_type;
mutable const EnumDescriptor* enum_type;
+ const char* lazy_type_name;
} type_descriptor_;
const FieldOptions* options_;
// IMPORTANT: If you add a new field, make sure to search for all instances
@@ -962,6 +941,7 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase {
bool default_value_bool_;
mutable const EnumValueDescriptor* default_value_enum_;
+ const char* lazy_default_value_enum_name_;
const std::string* default_value_string_;
mutable std::atomic<const Message*> default_generated_instance_;
};
@@ -1616,7 +1596,16 @@ class PROTOBUF_EXPORT FileDescriptor {
const std::string* name_;
const std::string* package_;
const DescriptorPool* pool_;
- internal::LazyInitData* dependencies_once_;
+
+ // Data required to do lazy initialization.
+ struct PROTOBUF_EXPORT LazyInitData {
+#ifndef SWIG
+ internal::once_flag once;
+#endif
+ const char** dependencies_names;
+ };
+
+ LazyInitData* dependencies_once_;
static void DependenciesOnceInit(const FileDescriptor* to_init);
void InternalDependenciesOnceInit() const;
@@ -2250,7 +2239,7 @@ inline FieldDescriptor::Label FieldDescriptor::label() const {
inline FieldDescriptor::Type FieldDescriptor::type() const {
if (type_once_) {
- internal::call_once(type_once_->once, &FieldDescriptor::TypeOnceInit, this);
+ internal::call_once(*type_once_, &FieldDescriptor::TypeOnceInit, this);
}
return static_cast<Type>(type_);
}
diff --git a/src/google/protobuf/extension_set.cc b/src/google/protobuf/extension_set.cc
index 7a0ae5f1f..df95bc0ee 100644
--- a/src/google/protobuf/extension_set.cc
+++ b/src/google/protobuf/extension_set.cc
@@ -695,7 +695,7 @@ void ExtensionSet::SetAllocatedMessage(int number, FieldType type,
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
if (extension->is_lazy) {
- extension->lazymessage_value->SetAllocatedMessage(message);
+ extension->lazymessage_value->SetAllocatedMessage(message, arena_);
} else {
if (arena_ == nullptr) {
delete extension->message_value;
@@ -731,7 +731,8 @@ void ExtensionSet::UnsafeArenaSetAllocatedMessage(
} else {
GOOGLE_DCHECK_TYPE(*extension, OPTIONAL_FIELD, MESSAGE);
if (extension->is_lazy) {
- extension->lazymessage_value->UnsafeArenaSetAllocatedMessage(message);
+ extension->lazymessage_value->UnsafeArenaSetAllocatedMessage(message,
+ arena_);
} else {
if (arena_ == nullptr) {
delete extension->message_value;
diff --git a/src/google/protobuf/extension_set.h b/src/google/protobuf/extension_set.h
index e21de264c..150502039 100644
--- a/src/google/protobuf/extension_set.h
+++ b/src/google/protobuf/extension_set.h
@@ -580,8 +580,9 @@ class PROTOBUF_EXPORT ExtensionSet {
Arena* arena) const = 0;
virtual MessageLite* MutableMessage(const MessageLite& prototype,
Arena* arena) = 0;
- virtual void SetAllocatedMessage(MessageLite* message) = 0;
- virtual void UnsafeArenaSetAllocatedMessage(MessageLite* message) = 0;
+ virtual void SetAllocatedMessage(MessageLite* message, Arena* arena) = 0;
+ virtual void UnsafeArenaSetAllocatedMessage(MessageLite* message,
+ Arena* arena) = 0;
virtual PROTOBUF_MUST_USE_RESULT MessageLite* ReleaseMessage(
const MessageLite& prototype, Arena* arena) = 0;
virtual MessageLite* UnsafeArenaReleaseMessage(const MessageLite& prototype,
diff --git a/src/google/protobuf/generated_message_reflection.cc b/src/google/protobuf/generated_message_reflection.cc
index a84fb3542..99c0c258f 100644
--- a/src/google/protobuf/generated_message_reflection.cc
+++ b/src/google/protobuf/generated_message_reflection.cc
@@ -53,7 +53,9 @@
#include <google/protobuf/stubs/strutil.h>
+// clang-format off
#include <google/protobuf/port_def.inc>
+// clang-format on
#define GOOGLE_PROTOBUF_HAS_ONEOF
@@ -2491,12 +2493,18 @@ bool Reflection::HasBit(const Message& message,
// (which uses HasField()) needs to be consistent with this.
switch (field->cpp_type()) {
case FieldDescriptor::CPPTYPE_STRING:
- if (IsInlined(field)) {
- return !GetField<InlinedStringField>(message, field)
- .GetNoArena()
- .empty();
+ switch (field->options().ctype()) {
+ default: {
+ if (IsInlined(field)) {
+ return !GetField<InlinedStringField>(message, field)
+ .GetNoArena()
+ .empty();
+ }
+
+ return GetField<ArenaStringPtr>(message, field).Get().size() > 0;
+ }
}
- return GetField<ArenaStringPtr>(message, field).Get().size() > 0;
+ return false;
case FieldDescriptor::CPPTYPE_BOOL:
return GetRaw<bool>(message, field) != false;
case FieldDescriptor::CPPTYPE_INT32:
diff --git a/src/google/protobuf/io/tokenizer.cc b/src/google/protobuf/io/tokenizer.cc
index 4bb6612c0..d6456bcc9 100644
--- a/src/google/protobuf/io/tokenizer.cc
+++ b/src/google/protobuf/io/tokenizer.cc
@@ -817,7 +817,8 @@ bool Tokenizer::NextWithComments(std::string* prev_trailing_comments,
// Ignore unicode byte order mark(BOM) if it appears at the file
// beginning. Only UTF-8 BOM (0xEF 0xBB 0xBF) is accepted.
if (TryConsume(static_cast<char>(0xEF))) {
- if (!TryConsume(static_cast<char>(0xBB)) || !TryConsume(static_cast<char>(0xBF))) {
+ if (!TryConsume(static_cast<char>(0xBB)) ||
+ !TryConsume(static_cast<char>(0xBF))) {
AddError(
"Proto file starts with 0xEF but not UTF-8 BOM. "
"Only UTF-8 is accepted for proto file.");
diff --git a/src/google/protobuf/message.h b/src/google/protobuf/message.h
index ca33dbe83..90b4e4999 100644
--- a/src/google/protobuf/message.h
+++ b/src/google/protobuf/message.h
@@ -293,7 +293,7 @@ class PROTOBUF_EXPORT Message : public MessageLite {
// method after parsing.
//
// See Reflection::GetUnknownFields() for more on unknown fields.
- virtual void DiscardUnknownFields();
+ void DiscardUnknownFields();
// Computes (an estimate of) the total number of bytes currently used for
// storing the message in memory. The default implementation calls the