Allow message name "List" without conflict

PiperOrigin-RevId: 491380902
pull/11054/head
Deanna Garcia 2 years ago committed by Copybara-Service
parent d5f759f7a4
commit 9a1ef54b47
  1. 6
      java/kotlin-lite/src/test/kotlin/com/google/protobuf/Proto2LiteTest.kt
  2. 6
      java/kotlin/src/test/kotlin/com/google/protobuf/Proto2Test.kt
  3. 3
      java/kotlin/src/test/proto/com/google/protobuf/evil_names_proto2.proto
  4. 5
      src/google/protobuf/compiler/java/message.cc
  5. 5
      src/google/protobuf/compiler/java/message_lite.cc

@ -55,9 +55,9 @@ import com.google.protobuf.testEmptyMessageWithExtensionsLite
import protobuf_unittest.MapLiteUnittest.MapEnumLite
import protobuf_unittest.MapLiteUnittest.TestMapLite
import protobuf_unittest.testMapLite
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.EvilNamesProto2
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.HardKeywordsAllTypesProto2
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.Interface
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2
import `in`.com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2
import `in`.com.google.protobuf.kotlin.generator.Interface
import `in`.com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2Kt
import `in`.com.google.protobuf.kotlin.generator.evilNamesProto2
import `in`.com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto2

@ -60,9 +60,9 @@ import protobuf_unittest.testEmptyMessageWithExtensions
import protobuf_unittest.testEnumMap
import protobuf_unittest.testIntIntMap
import protobuf_unittest.testMaps
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.EvilNamesProto2
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.HardKeywordsAllTypesProto2
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2OuterClass.Interface
import `in`.com.google.protobuf.kotlin.generator.EvilNamesProto2
import `in`.com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2
import `in`.com.google.protobuf.kotlin.generator.Interface
import `in`.com.google.protobuf.kotlin.generator.HardKeywordsAllTypesProto2Kt
import `in`.com.google.protobuf.kotlin.generator.evilNamesProto2
import `in`.com.google.protobuf.kotlin.generator.hardKeywordsAllTypesProto2

@ -34,6 +34,7 @@ syntax = "proto2";
package protobuf.kotlin.generator;
option java_package = "in.com.google.protobuf.kotlin.generator";
option java_multiple_files = true;
message EvilNamesProto2 {
optional bool initialized = 1;
@ -67,6 +68,8 @@ message EvilNamesProto2 {
optional string by = 25;
}
message List {}
message HardKeywordsAllTypesProto2 {
message NestedMessage {
optional int32 while = 1;

@ -1396,7 +1396,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
" return if (extension.isRepeated) {\n"
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
"List<*>>) as T\n"
"kotlin.collections.List<*>>) as T\n"
" } else {\n"
" _builder.getExtension(extension)\n"
" }\n"
@ -1409,7 +1409,8 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
"public operator fun <E : kotlin.Any> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
" extension: com.google.protobuf.ExtensionLite<$message$, "
"kotlin.collections.List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
"_builder.getExtension(extension))\n"

@ -901,7 +901,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
" return if (extension.isRepeated) {\n"
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
"List<*>>) as T\n"
"kotlin.collections.List<*>>) as T\n"
" } else {\n"
" _builder.getExtension(extension)\n"
" }\n"
@ -914,7 +914,8 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
"public operator fun <E : kotlin.Any> get(\n"
" extension: com.google.protobuf.ExtensionLite<$message$, List<E>>\n"
" extension: com.google.protobuf.ExtensionLite<$message$, "
"kotlin.collections.List<E>>\n"
"): com.google.protobuf.kotlin.ExtensionList<E, $message$> {\n"
" return com.google.protobuf.kotlin.ExtensionList(extension, "
"_builder.getExtension(extension))\n"

Loading…
Cancel
Save