Skip to content

Commit

Permalink
Merge pull request #3260 from square/fix_missing_proto_message_confor…
Browse files Browse the repository at this point in the history
…mance

[swift] Fix conformance to ProtoMessage for heap allocated protos
  • Loading branch information
dnkoutso authored Jan 23, 2025
2 parents 81f9533 + 931f8fa commit e8d52ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ class SwiftGenerator private constructor(
.build()
fileMembers += FileMemberSpec.builder(structProtoCodableExtension).build()

val structMessageConformanceExtension = ExtensionSpec.builder(structType)
.messageConformanceExtension(type)
.build()
fileMembers += FileMemberSpec.builder(structMessageConformanceExtension).build()

val structCodableExtension = heapCodableExtension(structType, storageName, storageType)
fileMembers += FileMemberSpec.builder(structCodableExtension)
.addGuard("!$FLAG_REMOVE_CODABLE")
Expand Down
8 changes: 8 additions & 0 deletions wire-tests-swift/no-manifest/src/main/swift/AllTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1911,6 +1911,14 @@ extension AllTypes : Proto2Codable {

}

extension AllTypes : ProtoMessage {

public static func protoMessageTypeURL() -> String {
return "type.googleapis.com/squareup.protos.kotlin.alltypes.AllTypes"
}

}

#if !WIRE_REMOVE_CODABLE
extension AllTypes : Codable {

Expand Down

0 comments on commit e8d52ce

Please sign in to comment.