Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 667664794
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Aug 26, 2024
1 parent 0ed61f0 commit 673a892
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ import com.google.protobuf.GeneratedMessageLite
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, *>,
MOrBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>,
T : Any> MOrBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)
T : Any,
> MOrBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)

/** Sets the current value of the proto extension in this builder. */
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, B>,
B : GeneratedMessageLite.ExtendableBuilder<M, B>,
T : Any> B.set(extension: ExtensionLite<M, T>, value: T) {
T : Any,
> B.set(extension: ExtensionLite<M, T>, value: T) {
setExtension(extension, value)
}

/** Returns true if the specified extension is set. */
operator fun <
M : GeneratedMessageLite.ExtendableMessage<M, *>,
MorBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>> MorBT.contains(
extension: ExtensionLite<M, *>
): Boolean = hasExtension(extension)
MorBT : GeneratedMessageLite.ExtendableMessageOrBuilder<M, *>,
> MorBT.contains(extension: ExtensionLite<M, *>): Boolean = hasExtension(extension)
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class Proto2LiteTest {
.isEqualTo(TestUtilLite.getAllLiteSetBuilder().build())
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testGetters() {
testAllTypesLite {
Expand All @@ -176,7 +176,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testDefaultGetters() {
testAllTypesLite {
Expand All @@ -187,7 +187,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testRepeatedGettersAndSetters() {
testAllTypesLite {
Expand All @@ -208,28 +208,28 @@ class Proto2LiteTest {
repeatedGroup.addAll(
listOf(
TestAllTypesLiteKt.repeatedGroup { a = 1 },
TestAllTypesLiteKt.repeatedGroup { a = 2 }
TestAllTypesLiteKt.repeatedGroup { a = 2 },
)
)
assertThat(repeatedGroup)
.isEqualTo(
listOf(
TestAllTypesLiteKt.repeatedGroup { a = 1 },
TestAllTypesLiteKt.repeatedGroup { a = 2 }
TestAllTypesLiteKt.repeatedGroup { a = 2 },
)
)
repeatedGroup +=
listOf(
TestAllTypesLiteKt.repeatedGroup { a = 3 },
TestAllTypesLiteKt.repeatedGroup { a = 4 }
TestAllTypesLiteKt.repeatedGroup { a = 4 },
)
assertThat(repeatedGroup)
.isEqualTo(
listOf(
TestAllTypesLiteKt.repeatedGroup { a = 1 },
TestAllTypesLiteKt.repeatedGroup { a = 2 },
TestAllTypesLiteKt.repeatedGroup { a = 3 },
TestAllTypesLiteKt.repeatedGroup { a = 4 }
TestAllTypesLiteKt.repeatedGroup { a = 4 },
)
)
repeatedGroup[0] = TestAllTypesLiteKt.repeatedGroup { a = 5 }
Expand All @@ -239,7 +239,7 @@ class Proto2LiteTest {
TestAllTypesLiteKt.repeatedGroup { a = 5 },
TestAllTypesLiteKt.repeatedGroup { a = 2 },
TestAllTypesLiteKt.repeatedGroup { a = 3 },
TestAllTypesLiteKt.repeatedGroup { a = 4 }
TestAllTypesLiteKt.repeatedGroup { a = 4 },
)
)

Expand All @@ -253,7 +253,7 @@ class Proto2LiteTest {
nestedMessage { bb = 1 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 }
nestedMessage { bb = 4 },
)
)
repeatedNestedMessage[0] = nestedMessage { bb = 5 }
Expand All @@ -263,7 +263,7 @@ class Proto2LiteTest {
nestedMessage { bb = 5 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 }
nestedMessage { bb = 4 },
)
)

Expand All @@ -278,7 +278,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testHazzers() {
testAllTypesLite {
Expand Down Expand Up @@ -309,7 +309,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testClears() {
testAllTypesLite {
Expand Down Expand Up @@ -398,36 +398,36 @@ class Proto2LiteTest {
setExtension(UnittestLite.optionalBytesExtensionLite, toBytes("116"))
setExtension(
UnittestLite.optionalGroupExtensionLite,
optionalGroupExtensionLite { a = 117 }
optionalGroupExtensionLite { a = 117 },
)
setExtension(
UnittestLite.optionalNestedMessageExtensionLite,
TestAllTypesLiteKt.nestedMessage { bb = 118 }
TestAllTypesLiteKt.nestedMessage { bb = 118 },
)
setExtension(
UnittestLite.optionalForeignMessageExtensionLite,
foreignMessageLite { c = 119 }
foreignMessageLite { c = 119 },
)
setExtension(
UnittestLite.optionalImportMessageExtensionLite,
ImportMessageLite.newBuilder().setD(120).build()
ImportMessageLite.newBuilder().setD(120).build(),
)
setExtension(
UnittestLite.optionalPublicImportMessageExtensionLite,
PublicImportMessageLite.newBuilder().setE(126).build()
PublicImportMessageLite.newBuilder().setE(126).build(),
)
setExtension(
UnittestLite.optionalLazyMessageExtensionLite,
TestAllTypesLiteKt.nestedMessage { bb = 127 }
TestAllTypesLiteKt.nestedMessage { bb = 127 },
)
setExtension(
UnittestLite.optionalUnverifiedLazyMessageExtensionLite,
TestAllTypesLiteKt.nestedMessage { bb = 128 }
TestAllTypesLiteKt.nestedMessage { bb = 128 },
)
setExtension(UnittestLite.optionalNestedEnumExtensionLite, NestedEnum.BAZ)
setExtension(
UnittestLite.optionalForeignEnumExtensionLite,
ForeignEnumLite.FOREIGN_LITE_BAZ
ForeignEnumLite.FOREIGN_LITE_BAZ,
)
setExtension(UnittestLite.optionalImportEnumExtensionLite, ImportEnumLite.IMPORT_LITE_BAZ)
setExtension(UnittestLite.optionalStringPieceExtensionLite, "124")
Expand Down Expand Up @@ -521,7 +521,7 @@ class Proto2LiteTest {
.isEqualTo(TestUtilLite.getAllLiteExtensionsSet())
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testExtensionGetters() {
testAllExtensionsLite {
Expand All @@ -545,7 +545,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testRepeatedExtensionGettersAndSetters() {
testAllExtensionsLite {
Expand Down Expand Up @@ -580,7 +580,7 @@ class Proto2LiteTest {
repeatedGroupExtensionLite { a = 1 },
repeatedGroupExtensionLite { a = 2 },
repeatedGroupExtensionLite { a = 3 },
repeatedGroupExtensionLite { a = 4 }
repeatedGroupExtensionLite { a = 4 },
)
)
this[UnittestLite.repeatedGroupExtensionLite][0] = repeatedGroupExtensionLite { a = 5 }
Expand All @@ -590,7 +590,7 @@ class Proto2LiteTest {
repeatedGroupExtensionLite { a = 5 },
repeatedGroupExtensionLite { a = 2 },
repeatedGroupExtensionLite { a = 3 },
repeatedGroupExtensionLite { a = 4 }
repeatedGroupExtensionLite { a = 4 },
)
)

Expand All @@ -607,7 +607,7 @@ class Proto2LiteTest {
nestedMessage { bb = 1 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 }
nestedMessage { bb = 4 },
)
)
this[UnittestLite.repeatedNestedMessageExtensionLite][0] = nestedMessage { bb = 5 }
Expand All @@ -617,7 +617,7 @@ class Proto2LiteTest {
nestedMessage { bb = 5 },
nestedMessage { bb = 2 },
nestedMessage { bb = 3 },
nestedMessage { bb = 4 }
nestedMessage { bb = 4 },
)
)

Expand All @@ -635,7 +635,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testExtensionContains() {
testAllExtensionsLite {
Expand Down Expand Up @@ -667,7 +667,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testExtensionClears() {
testAllExtensionsLite {
Expand Down Expand Up @@ -756,7 +756,7 @@ class Proto2LiteTest {
)
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testMapGettersAndSetters() {
testMapLite {
Expand Down Expand Up @@ -788,7 +788,7 @@ class Proto2LiteTest {
1 to MapEnumLite.MAP_ENUM_FOO_LITE,
2 to MapEnumLite.MAP_ENUM_BAR_LITE,
3 to MapEnumLite.MAP_ENUM_BAZ_LITE,
4 to MapEnumLite.MAP_ENUM_FOO_LITE
4 to MapEnumLite.MAP_ENUM_FOO_LITE,
)
)

Expand All @@ -806,13 +806,13 @@ class Proto2LiteTest {
1 to foreignMessageLite { c = 1 },
2 to foreignMessageLite { c = 2 },
3 to foreignMessageLite { c = 3 },
4 to foreignMessageLite { c = 4 }
4 to foreignMessageLite { c = 4 },
)
)
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testMapRemove() {
testMapLite {
Expand All @@ -838,7 +838,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testMapClear() {
testMapLite {
Expand Down Expand Up @@ -920,7 +920,7 @@ class Proto2LiteTest {
assertThat(interface_ {}).isEqualTo(Interface.newBuilder().build())
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testHardKeywordGettersAndSetters() {
hardKeywordsAllTypesProto2 {
Expand Down Expand Up @@ -950,7 +950,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testHardKeywordHazzers() {
hardKeywordsAllTypesProto2 {
Expand All @@ -965,7 +965,7 @@ class Proto2LiteTest {
}
}

@Suppress("CheckResult")
@Suppress("CheckReturnValue")
@Test
fun testHardKeywordClears() {
hardKeywordsAllTypesProto2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,20 @@ import com.google.protobuf.GeneratedMessage
operator fun <
M : GeneratedMessage.ExtendableMessage<M>,
B : GeneratedMessage.ExtendableBuilder<M, B>,
T : Any> B.set(extension: ExtensionLite<M, T>, value: T) {
T : Any,
> B.set(extension: ExtensionLite<M, T>, value: T) {
setExtension(extension, value)
}

/** Gets the current value of the proto extension. */
operator fun <
M : GeneratedMessage.ExtendableMessage<M>,
MorBT : GeneratedMessage.ExtendableMessageOrBuilder<M>,
T : Any> MorBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)
T : Any,
> MorBT.get(extension: ExtensionLite<M, T>): T = getExtension(extension)

/** Returns true if the specified extension is set on this builder. */
operator fun <
M : GeneratedMessage.ExtendableMessage<M>,
MorBT : GeneratedMessage.ExtendableMessageOrBuilder<M>> MorBT.contains(
extension: ExtensionLite<M, *>
): Boolean = hasExtension(extension)
MorBT : GeneratedMessage.ExtendableMessageOrBuilder<M>,
> MorBT.contains(extension: ExtensionLite<M, *>): Boolean = hasExtension(extension)
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ package com.google.protobuf.kotlin
This API is only intended for use by generated protobuf code, the code generator, and their own
tests. If this does not describe your code, you should not be using this API.
""",
level = RequiresOptIn.Level.ERROR
level = RequiresOptIn.Level.ERROR,
)
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CONSTRUCTOR, AnnotationTarget.ANNOTATION_CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class DslListTest {
.addEqualityGroup(
DslList<Int, DummyProxy>(emptyList()),
DslList<String, DummyProxy>(emptyList()),
emptyList<Int>()
emptyList<Int>(),
)
.testEquals()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class DslMapTest {
.addEqualityGroup(
DslMap<Int, Int, DummyProxy>(emptyMap()),
DslMap<String, String, DummyProxy>(emptyMap()),
emptyMap<Int, Int>()
emptyMap<Int, Int>(),
)
.testEquals()
}
Expand Down
Loading

0 comments on commit 673a892

Please sign in to comment.