Merge pull request #9494 from protocolbuffers/ktExport
Fixing Kotlin tests
This commit is contained in:
commit
9eb5b19964
16
BUILD
16
BUILD
@ -1485,6 +1485,7 @@ genrule(
|
||||
outs = [
|
||||
"TestAllTypesKt.kt",
|
||||
"ForeignMessageKt.kt",
|
||||
"Int32MessageKt.kt",
|
||||
"TestAllExtensionsKt.kt",
|
||||
"TestEmptyMessageKt.kt",
|
||||
"TestEmptyMessageWithExtensionsKt.kt",
|
||||
@ -1505,6 +1506,8 @@ genrule(
|
||||
"$(location TestAllTypesKt.kt) && " +
|
||||
"cp $(@D)/protobuf_unittest/ForeignMessageKt.kt " +
|
||||
"$(location ForeignMessageKt.kt) && " +
|
||||
"cp $(@D)/protobuf_unittest/Int32MessageKt.kt " +
|
||||
"$(location Int32MessageKt.kt) && " +
|
||||
"cp $(@D)/protobuf_unittest/TestAllExtensionsKt.kt " +
|
||||
"$(location TestAllExtensionsKt.kt) && " +
|
||||
"cp $(@D)/protobuf_unittest/TestEmptyMessageKt.kt " +
|
||||
@ -1568,3 +1571,16 @@ genrule(
|
||||
tools = ["//:protoc"],
|
||||
)
|
||||
|
||||
genrule(
|
||||
name = "gen_kotlin_any",
|
||||
srcs = ["src/google/protobuf/any.proto"],
|
||||
outs = ["AnyKt.kt"],
|
||||
visibility = ["//java:__subpackages__"],
|
||||
cmd = "$(location //:protoc) " +
|
||||
"--kotlin_out=shared,immutable:$(@D) -Isrc/ " +
|
||||
"$(location src/google/protobuf/any.proto) && " +
|
||||
"cp $(@D)/com/google/protobuf/AnyKt.kt " +
|
||||
"$(location AnyKt.kt)",
|
||||
tools = ["//:protoc"],
|
||||
)
|
||||
|
||||
|
@ -35,7 +35,10 @@ kt_jvm_library(
|
||||
|
||||
kt_jvm_library(
|
||||
name = "full_extensions",
|
||||
srcs = ["src/main/kotlin/com/google/protobuf/ExtendableMessageExtensions.kt"],
|
||||
srcs = [
|
||||
"src/main/kotlin/com/google/protobuf/Anies.kt",
|
||||
"src/main/kotlin/com/google/protobuf/ExtendableMessageExtensions.kt",
|
||||
],
|
||||
deps = ["//java/core"],
|
||||
)
|
||||
|
||||
@ -106,11 +109,15 @@ java_test(
|
||||
|
||||
kt_jvm_library(
|
||||
name = "test_extensions_library",
|
||||
srcs = ["src/test/kotlin/com/google/protobuf/ExtendableMessageExtensionsTest.kt"],
|
||||
srcs = [
|
||||
"src/test/kotlin/com/google/protobuf/AniesTest.kt",
|
||||
"src/test/kotlin/com/google/protobuf/ExtendableMessageExtensionsTest.kt",
|
||||
],
|
||||
deps = [
|
||||
":example_extensible_message_java_proto",
|
||||
":full_extensions",
|
||||
"//java/lite",
|
||||
"//java/core:core",
|
||||
":kotlin_unittest",
|
||||
":only_for_use_in_proto_generated_code_its_generator_and_tests",
|
||||
":shared_runtime",
|
||||
"@com_github_jetbrains_kotlin//:kotlin-test",
|
||||
@ -221,6 +228,7 @@ kt_jvm_library(
|
||||
name = "kotlin_unittest",
|
||||
srcs = [
|
||||
":gen_evil_names_proto2",
|
||||
"//:gen_kotlin_any",
|
||||
"//:gen_kotlin_unittest",
|
||||
],
|
||||
deps = [
|
||||
|
@ -3,6 +3,7 @@
|
||||
<mkdir dir="${generated.sources.dir}"/>
|
||||
<exec executable="${protoc}">
|
||||
<arg value="--kotlin_out=${generated.sources.dir}"/>
|
||||
<arg value="--java_out=${generated.sources.dir}"/>
|
||||
<arg value="--proto_path=${protobuf.source.dir}"/>
|
||||
<arg value="${protobuf.source.dir}/google/protobuf/any.proto"/>
|
||||
<arg value="${protobuf.source.dir}/google/protobuf/api.proto"/>
|
||||
|
@ -1526,7 +1526,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
|
||||
printer->Print(
|
||||
"@Suppress(\"UNCHECKED_CAST\")\n"
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"public operator fun <T> get(extension: "
|
||||
"public operator fun <T : kotlin.Any> get(extension: "
|
||||
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
|
||||
" return if (extension.isRepeated) {\n"
|
||||
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
|
||||
@ -1542,7 +1542,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
|
||||
"@kotlin.OptIn"
|
||||
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
|
||||
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
|
||||
"public operator fun <E> get(\n"
|
||||
"public operator fun <E : kotlin.Any> 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, "
|
||||
@ -1571,7 +1571,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"@kotlin.PublishedApi\n"
|
||||
"internal fun <T> setExtension(extension: "
|
||||
"internal fun <T : kotlin.Any> setExtension(extension: "
|
||||
"com.google.protobuf.ExtensionLite<$message$, T>, "
|
||||
"value: T) {\n"
|
||||
" _builder.setExtension(extension, value)\n"
|
||||
@ -1614,7 +1614,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
|
||||
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"public fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"public fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.add(value: E) {\n"
|
||||
" _builder.addExtension(this.extension, value)\n"
|
||||
"}\n\n",
|
||||
@ -1623,7 +1623,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"@Suppress(\"NOTHING_TO_INLINE\")\n"
|
||||
"public inline operator fun <E> "
|
||||
"public inline operator fun <E : kotlin.Any> "
|
||||
"com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.plusAssign"
|
||||
"(value: E) {\n"
|
||||
@ -1633,7 +1633,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
|
||||
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"public fun <E> com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"public fun <E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.addAll(values: Iterable<E>) {\n"
|
||||
" for (value in values) {\n"
|
||||
" add(value)\n"
|
||||
@ -1644,7 +1644,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"@Suppress(\"NOTHING_TO_INLINE\")\n"
|
||||
"public inline operator fun <E> "
|
||||
"public inline operator fun <E : kotlin.Any> "
|
||||
"com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.plusAssign(values: "
|
||||
"Iterable<E>) {\n"
|
||||
@ -1654,7 +1654,7 @@ void ImmutableMessageGenerator::GenerateKotlinExtensions(
|
||||
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"public operator fun <E> "
|
||||
"public operator fun <E : kotlin.Any> "
|
||||
"com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.set(index: Int, value: "
|
||||
"E) {\n"
|
||||
|
@ -1438,7 +1438,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"add(value: $kt_type$) {\n"
|
||||
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
|
||||
/* builder */ false);
|
||||
@ -1450,7 +1450,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"plusAssign(value: $kt_type$) {\n"
|
||||
" add(value)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
|
||||
/* builder */ false);
|
||||
@ -1461,7 +1461,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
|
||||
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
|
||||
/* builder */ false);
|
||||
@ -1474,7 +1474,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
|
||||
" addAll(values)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
|
||||
/* builder */ false);
|
||||
@ -1486,7 +1486,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"set(index: kotlin.Int, value: $kt_type$) {\n"
|
||||
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
|
||||
/* builder */ false);
|
||||
@ -1497,7 +1497,7 @@ void RepeatedImmutableMessageFieldGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"clear() {\n"
|
||||
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
|
||||
"}");
|
||||
"}\n\n");
|
||||
}
|
||||
|
||||
} // namespace java
|
||||
|
@ -825,7 +825,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"add(value: $kt_type$) {\n"
|
||||
" $kt_dsl_builder$.${$add$capitalized_name$$}$(value)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, LIST_ADDER,
|
||||
/* builder */ false);
|
||||
@ -837,7 +837,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"plusAssign(value: $kt_type$) {\n"
|
||||
" add(value)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
|
||||
/* builder */ false);
|
||||
@ -848,7 +848,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"addAll(values: kotlin.collections.Iterable<$kt_type$>) {\n"
|
||||
" $kt_dsl_builder$.${$addAll$capitalized_name$$}$(values)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, LIST_MULTI_ADDER,
|
||||
/* builder */ false);
|
||||
@ -861,7 +861,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"plusAssign(values: kotlin.collections.Iterable<$kt_type$>) {\n"
|
||||
" addAll(values)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, LIST_INDEXED_SETTER,
|
||||
/* builder */ false);
|
||||
@ -873,7 +873,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"set(index: kotlin.Int, value: $kt_type$) {\n"
|
||||
" $kt_dsl_builder$.${$set$capitalized_name$$}$(index, value)\n"
|
||||
"}");
|
||||
"}\n");
|
||||
|
||||
WriteFieldAccessorDocComment(printer, descriptor_, CLEARER,
|
||||
/* builder */ false);
|
||||
@ -884,7 +884,7 @@ void RepeatedImmutableMessageFieldLiteGenerator::GenerateKotlinDslMembers(
|
||||
"<$kt_type$, ${$$kt_capitalized_name$Proxy$}$>."
|
||||
"clear() {\n"
|
||||
" $kt_dsl_builder$.${$clear$capitalized_name$$}$()\n"
|
||||
"}");
|
||||
"}\n");
|
||||
}
|
||||
|
||||
} // namespace java
|
||||
|
@ -847,7 +847,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
|
||||
printer->Print(
|
||||
"@Suppress(\"UNCHECKED_CAST\")\n"
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"public operator fun <T> get(extension: "
|
||||
"public operator fun <T : kotlin.Any> get(extension: "
|
||||
"com.google.protobuf.ExtensionLite<$message$, T>): T {\n"
|
||||
" return if (extension.isRepeated) {\n"
|
||||
" get(extension as com.google.protobuf.ExtensionLite<$message$, "
|
||||
@ -863,7 +863,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
|
||||
"@kotlin.OptIn"
|
||||
"(com.google.protobuf.kotlin.OnlyForUseByGeneratedProtoCode::class)\n"
|
||||
"@kotlin.jvm.JvmName(\"-getRepeatedExtension\")\n"
|
||||
"public operator fun <E> get(\n"
|
||||
"public operator fun <E : kotlin.Any> 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, "
|
||||
@ -892,7 +892,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"@kotlin.PublishedApi\n"
|
||||
"internal fun <T> setExtension(extension: "
|
||||
"internal fun <T : kotlin.Any> setExtension(extension: "
|
||||
"com.google.protobuf.ExtensionLite<$message$, T>, "
|
||||
"value: T) {\n"
|
||||
" _builder.setExtension(extension, value)\n"
|
||||
@ -935,7 +935,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
|
||||
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"public fun<E> com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.add(value: E) {\n"
|
||||
" _builder.addExtension(this.extension, value)\n"
|
||||
"}\n\n",
|
||||
@ -944,7 +944,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"@Suppress(\"NOTHING_TO_INLINE\")\n"
|
||||
"public inline operator fun <E> "
|
||||
"public inline operator fun <E : kotlin.Any> "
|
||||
"com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.plusAssign"
|
||||
"(value: E) {\n"
|
||||
@ -954,7 +954,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
|
||||
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"public fun<E> com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"public fun<E : kotlin.Any> com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.addAll(values: Iterable<E>) {\n"
|
||||
" for (value in values) {\n"
|
||||
" add(value)\n"
|
||||
@ -965,7 +965,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"@Suppress(\"NOTHING_TO_INLINE\")\n"
|
||||
"public inline operator fun <E> "
|
||||
"public inline operator fun <E : kotlin.Any> "
|
||||
"com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.plusAssign(values: "
|
||||
"Iterable<E>) {\n"
|
||||
@ -975,7 +975,7 @@ void ImmutableMessageLiteGenerator::GenerateKotlinExtensions(
|
||||
|
||||
printer->Print(
|
||||
"@kotlin.jvm.JvmSynthetic\n"
|
||||
"public operator fun <E> "
|
||||
"public operator fun <E : kotlin.Any> "
|
||||
"com.google.protobuf.kotlin.ExtensionList<E, "
|
||||
"$message$>.set(index: Int, value: "
|
||||
"E) {\n"
|
||||
|
Loading…
Reference in New Issue
Block a user