Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import com.squareup.wire.ReverseProtoWriter
import com.squareup.wire.Syntax.PROTO_2
import com.squareup.wire.WireField
import com.squareup.wire.`internal`.JvmField
import com.squareup.wire.`internal`.immutableCopyOf
import kotlin.Any
import kotlin.Boolean
import kotlin.Deprecated
Expand All @@ -38,17 +37,15 @@ public class MutablePacket(
schemaIndex = 0,
)
public var header_: MutableHeader? = null,
payload: List<MutablePayload> = emptyList(),
override var unknownFields: ByteString = ByteString.EMPTY,
) : Message<MutablePacket, Nothing>(ADAPTER, unknownFields) {
@field:WireField(
tag = 2,
adapter = "squareup.wire.mutable.MutablePayload#ADAPTER",
label = WireField.Label.REPEATED,
schemaIndex = 1,
)
public var payload: List<MutablePayload> = immutableCopyOf("payload", payload)

public var payload: List<MutablePayload> = emptyList(),
override var unknownFields: ByteString = ByteString.EMPTY,
) : Message<MutablePacket, Nothing>(ADAPTER, unknownFields) {
@Deprecated(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import com.squareup.wire.WireEnum
import com.squareup.wire.WireField
import com.squareup.wire.`internal`.JvmField
import com.squareup.wire.`internal`.JvmStatic
import com.squareup.wire.`internal`.immutableCopyOf
import com.squareup.wire.`internal`.sanitize
import kotlin.Any
import kotlin.Boolean
Expand Down Expand Up @@ -53,17 +52,15 @@ public class MutablePayload(
schemaIndex = 2,
)
public var type: Type? = null,
footers: List<String> = emptyList(),
override var unknownFields: ByteString = ByteString.EMPTY,
) : Message<MutablePayload, Nothing>(ADAPTER, unknownFields) {
@field:WireField(
tag = 4,
adapter = "com.squareup.wire.ProtoAdapter#STRING",
label = WireField.Label.REPEATED,
schemaIndex = 3,
)
public var footers: List<String> = immutableCopyOf("footers", footers)

public var footers: List<String> = emptyList(),
override var unknownFields: ByteString = ByteString.EMPTY,
) : Message<MutablePayload, Nothing>(ADAPTER, unknownFields) {
@Deprecated(
message = "Shouldn't be used in Kotlin",
level = DeprecationLevel.HIDDEN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1251,12 +1251,17 @@ class KotlinGenerator private constructor(
CodeBlock.of(if (buildersOnly) "builder.$fieldName" else fieldName)
}
field.isRepeated || field.isMap -> {
CodeBlock.of(
if (buildersOnly) "%M(%S, builder.%N)" else "%M(%S, %N)",
MemberName("com.squareup.wire.internal", "immutableCopyOf"),
fieldName,
fieldName,
)
if (mutableTypes) {
// For mutable types, don't bother using immutableCopyOf(...)
CodeBlock.of("%N", fieldName)
} else {
CodeBlock.of(
if (buildersOnly) "%M(%S, builder.%N)" else "%M(%S, %N)",
MemberName("com.squareup.wire.internal", "immutableCopyOf"),
fieldName,
fieldName,
)
}
}
!field.isRepeated && !field.isMap && field.isRequired && buildersOnly -> {
CodeBlock.of("builder.%N!!", fieldName)
Expand Down
Loading