-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2658 from square/add_missing_parameterized_imports
[swift] Ensure imports of parameterized type names are emitted
- Loading branch information
Showing
51 changed files
with
637 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ gradlew.bat | |
# Maven | ||
plugin*.xml | ||
|
||
# SPM | ||
.build | ||
|
||
# Special Mkdocs files | ||
docs/3.x | ||
docs/changelog.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
wire-tests-swift/manifest/module_one/SwiftModuleOneType.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Code generated by Wire protocol buffer compiler, do not edit. | ||
// Source: squareup.protos.kotlin.swift_modules.SwiftModuleOneType in swift_module_one.proto | ||
import Foundation | ||
import Wire | ||
|
||
public enum SwiftModuleOneType : UInt32, CaseIterable, ProtoEnum { | ||
|
||
case DO_NOT_USE = 0 | ||
case ONE = 1 | ||
case TWO = 2 | ||
|
||
public var description: String { | ||
switch self { | ||
case .DO_NOT_USE: return "DO_NOT_USE" | ||
case .ONE: return "ONE" | ||
case .TWO: return "TWO" | ||
} | ||
} | ||
|
||
} | ||
|
||
#if swift(>=5.5) | ||
extension SwiftModuleOneType : Sendable { | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
plugins { | ||
id("swift-library") | ||
id("xcode") | ||
id("xctest") | ||
} | ||
|
||
library { | ||
dependencies { | ||
api(projects.wireRuntimeSwift) | ||
} | ||
|
||
module.set("module_one") | ||
|
||
source.from(file(".")) | ||
} |
190 changes: 190 additions & 0 deletions
190
wire-tests-swift/manifest/module_three/SwiftModuleThreeMessage.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
// Code generated by Wire protocol buffer compiler, do not edit. | ||
// Source: squareup.protos.kotlin.swift_modules.SwiftModuleThreeMessage in swift_module_three.proto | ||
import Foundation | ||
import Wire | ||
import module_one | ||
|
||
public struct SwiftModuleThreeMessage { | ||
|
||
public var name: String? | ||
public var unknownFields: Foundation.Data = .init() | ||
|
||
public init(configure: (inout Self) -> Swift.Void = { _ in }) { | ||
configure(&self) | ||
} | ||
|
||
} | ||
|
||
#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER | ||
extension SwiftModuleThreeMessage { | ||
|
||
@_disfavoredOverload | ||
@available(*, deprecated) | ||
public init(name: Swift.String? = nil) { | ||
self.name = name | ||
} | ||
|
||
} | ||
#endif | ||
|
||
#if !WIRE_REMOVE_EQUATABLE | ||
extension SwiftModuleThreeMessage : Equatable { | ||
} | ||
#endif | ||
|
||
#if !WIRE_REMOVE_HASHABLE | ||
extension SwiftModuleThreeMessage : Hashable { | ||
} | ||
#endif | ||
|
||
#if swift(>=5.5) | ||
extension SwiftModuleThreeMessage : Sendable { | ||
} | ||
#endif | ||
|
||
extension SwiftModuleThreeMessage : ProtoMessage { | ||
|
||
public static func protoMessageTypeURL() -> Swift.String { | ||
return "type.googleapis.com/squareup.protos.kotlin.swift_modules.SwiftModuleThreeMessage" | ||
} | ||
|
||
} | ||
|
||
extension SwiftModuleThreeMessage : Proto2Codable { | ||
|
||
public init(from protoReader: Wire.ProtoReader) throws { | ||
var name: Swift.String? = nil | ||
|
||
let token = try protoReader.beginMessage() | ||
while let tag = try protoReader.nextTag(token: token) { | ||
switch tag { | ||
case 1: name = try protoReader.decode(Swift.String.self) | ||
default: try protoReader.readUnknownField(tag: tag) | ||
} | ||
} | ||
self.unknownFields = try protoReader.endMessage(token: token) | ||
|
||
self.name = name | ||
} | ||
|
||
public func encode(to protoWriter: Wire.ProtoWriter) throws { | ||
try protoWriter.encode(tag: 1, value: self.name) | ||
try protoWriter.writeUnknownFields(unknownFields) | ||
} | ||
|
||
} | ||
|
||
#if !WIRE_REMOVE_CODABLE | ||
extension SwiftModuleThreeMessage : Codable { | ||
|
||
public init(from decoder: Swift.Decoder) throws { | ||
let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) | ||
self.name = try container.decodeIfPresent(Swift.String.self, forKey: "name") | ||
} | ||
|
||
public func encode(to encoder: Swift.Encoder) throws { | ||
var container = encoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) | ||
|
||
try container.encodeIfPresent(self.name, forKey: "name") | ||
} | ||
|
||
} | ||
#endif | ||
|
||
/** | ||
* Subtypes within SwiftModuleThreeMessage | ||
*/ | ||
extension SwiftModuleThreeMessage { | ||
|
||
public struct NestedMessage { | ||
|
||
public var map_string_types: [Swift.String : module_one.SwiftModuleOneType] = [:] | ||
public var unknownFields: Foundation.Data = .init() | ||
|
||
public init(configure: (inout Self) -> Swift.Void = { _ in }) { | ||
configure(&self) | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
#if WIRE_INCLUDE_MEMBERWISE_INITIALIZER | ||
extension SwiftModuleThreeMessage.NestedMessage { | ||
|
||
@_disfavoredOverload | ||
@available(*, deprecated) | ||
public init(map_string_types: [Swift.String : module_one.SwiftModuleOneType] = [:]) { | ||
self.map_string_types = map_string_types | ||
} | ||
|
||
} | ||
#endif | ||
|
||
#if !WIRE_REMOVE_EQUATABLE | ||
extension SwiftModuleThreeMessage.NestedMessage : Equatable { | ||
} | ||
#endif | ||
|
||
#if !WIRE_REMOVE_HASHABLE | ||
extension SwiftModuleThreeMessage.NestedMessage : Hashable { | ||
} | ||
#endif | ||
|
||
#if swift(>=5.5) | ||
extension SwiftModuleThreeMessage.NestedMessage : Sendable { | ||
} | ||
#endif | ||
|
||
extension SwiftModuleThreeMessage.NestedMessage : ProtoMessage { | ||
|
||
public static func protoMessageTypeURL() -> Swift.String { | ||
return "type.googleapis.com/squareup.protos.kotlin.swift_modules.SwiftModuleThreeMessage.NestedMessage" | ||
} | ||
|
||
} | ||
|
||
extension SwiftModuleThreeMessage.NestedMessage : Proto2Codable { | ||
|
||
public init(from protoReader: Wire.ProtoReader) throws { | ||
var map_string_types: [Swift.String : module_one.SwiftModuleOneType] = [:] | ||
|
||
let token = try protoReader.beginMessage() | ||
while let tag = try protoReader.nextTag(token: token) { | ||
switch tag { | ||
case 2: try protoReader.decode(into: &map_string_types) | ||
default: try protoReader.readUnknownField(tag: tag) | ||
} | ||
} | ||
self.unknownFields = try protoReader.endMessage(token: token) | ||
|
||
self.map_string_types = map_string_types | ||
} | ||
|
||
public func encode(to protoWriter: Wire.ProtoWriter) throws { | ||
try protoWriter.encode(tag: 2, value: self.map_string_types) | ||
try protoWriter.writeUnknownFields(unknownFields) | ||
} | ||
|
||
} | ||
|
||
#if !WIRE_REMOVE_CODABLE | ||
extension SwiftModuleThreeMessage.NestedMessage : Codable { | ||
|
||
public init(from decoder: Swift.Decoder) throws { | ||
let container = try decoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) | ||
self.map_string_types = try container.decodeProtoMap([Swift.String : module_one.SwiftModuleOneType].self, firstOfKeys: "mapStringTypes", "map_string_types") | ||
} | ||
|
||
public func encode(to encoder: Swift.Encoder) throws { | ||
var container = encoder.container(keyedBy: Wire.StringLiteralCodingKeys.self) | ||
let preferCamelCase = encoder.protoKeyNameEncodingStrategy == .camelCase | ||
let includeDefaults = encoder.protoDefaultValuesEncodingStrategy == .include | ||
|
||
if includeDefaults || !self.map_string_types.isEmpty { | ||
try container.encodeProtoMap(self.map_string_types, forKey: preferCamelCase ? "mapStringTypes" : "map_string_types") | ||
} | ||
} | ||
|
||
} | ||
#endif |
Oops, something went wrong.