Skip to content

Commit 34aaacd

Browse files
authored
Merge pull request #91 from MercuryTechnologies/kb/public-swift
Make swift types public and deprecations prettier
2 parents c672b87 + 1ea4f5b commit 34aaacd

File tree

46 files changed

+132
-151
lines changed
  • .golden
    • swiftAdvancedEnumSpec
    • swiftAdvancedEnumWithRawValueSpec
    • swiftAdvancedNewtypeSpec
    • swiftAdvancedNewtypeWithEnumFieldSpec
    • swiftAdvancedRecordSpec
    • swiftBasicDocSpec
    • swiftBasicEnumSpec
    • swiftBasicEnumWithRawValueSpec
    • swiftBasicNewtypeJoinOptionalsSpec
    • swiftBasicNewtypeSpec
    • swiftBasicNewtypeWithConcreteFieldSpec
    • swiftBasicNewtypeWithEitherFieldSpec
    • swiftBasicRecordSpec
    • swiftDataSingleNullarySpec
    • swiftDataSingleNullaryWithTypeVariableSpec
    • swiftDeprecatedFieldSpec
    • swiftEnumSumOfProductDocSpec
    • swiftEnumSumOfProductSpec
    • swiftEnumSumOfProductWithNameCollisionSpec
    • swiftEnumSumOfProductWithTaggedFlatObjectStyleSpec
    • swiftEnumSumOfProductWithTaggedObjectStyleSpec
    • swiftEnumValueClassDocSpec
    • swiftEnumValueClassSpec
    • swiftGenericAliasSpec
    • swiftGenericNewtypeSpec
    • swiftGenericStructSpec
    • swiftMultipleTypeVariableSpec
    • swiftRecord0DuplicateRecordFieldSpec
    • swiftRecord0SumOfProductDocSpec
    • swiftRecord0SumOfProductWithTaggedFlatObjectStyleSpec
    • swiftRecord0SumOfProductWithTaggedObjectStyleSpec
    • swiftRecord1DuplicateRecordFieldSpec
    • swiftRecord1SumOfProductDocSpec
    • swiftRecord1SumOfProductWithTaggedFlatObjectStyleSpec
    • swiftRecord1SumOfProductWithTaggedObjectStyleSpec
    • swiftStrictEnumsSpec-EnumA
    • swiftStrictEnumsSpec-EnumB
    • swiftStrictFieldsCheck-RecordA
    • swiftStrictFieldsCheck-RecordB
    • swiftSumOfProductWithTypeParameterSpec
    • swiftTypeVariableSpec
  • nix
  • src/Moat/Pretty

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+132
-151
lines changed

.golden/swiftAdvancedEnumSpec/golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum Enum: CaseIterable, Hashable, Codable {
1+
public enum Enum: CaseIterable, Hashable, Codable {
22
case a
33
case b
44
case c
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum Enum: String, CaseIterable, Hashable, Codable {
1+
public enum Enum: String, CaseIterable, Hashable, Codable {
22
case a
33
case b
44
}
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Newtype: CaseIterable, Hashable, Codable {
2-
typealias NewtypeTag = Tagged<Newtype, String>
3-
let value: NewtypeTag
1+
public struct Newtype: CaseIterable, Hashable, Codable {
2+
public typealias NewtypeTag = Tagged<Newtype, String>
3+
public let value: NewtypeTag
44
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
struct Newtype {
2-
var newtypeField: Enum
1+
public struct Newtype {
2+
public var newtypeField: Enum
33
}
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Data: CaseIterable, Hashable, Codable {
2-
var field0: Int
3-
var field1: Int?
1+
public struct Data: CaseIterable, Hashable, Codable {
2+
public var field0: Int
3+
public var field1: Int?
44
}

.golden/swiftBasicDocSpec/golden

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
/// guard n != 0, n != 1 else { return n }
2828
/// return fibonacci(n - 1) + fibonacci(n - 2)
2929
/// }
30-
struct Data {
30+
public struct Data {
3131
/// First field, it's an Int
32-
var first: Int
32+
public var first: Int
3333
/// Second field, it's maybe an Int
34-
var second: Int?
34+
public var second: Int?
3535
}

.golden/swiftBasicEnumSpec/golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum Enum {
1+
public enum Enum {
22
case a
33
case b
44
case c
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum Enum {
1+
public enum Enum {
22
case a
33
case b
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Newtype {
2-
typealias NewtypeTag = Tagged<Newtype, Int?>
3-
let value: NewtypeTag?
1+
public struct Newtype {
2+
public typealias NewtypeTag = Tagged<Newtype, Int?>
3+
public let value: NewtypeTag?
44
}

.golden/swiftBasicNewtypeSpec/golden

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Newtype {
2-
typealias NewtypeTag = Tagged<Newtype, String>
3-
let value: NewtypeTag
1+
public struct Newtype {
2+
public typealias NewtypeTag = Tagged<Newtype, String>
3+
public let value: NewtypeTag
44
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
struct Newtype {
2-
var newtypeField: String
1+
public struct Newtype {
2+
public var newtypeField: String
33
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
struct Newtype {
2-
var newtypeField: Result<Int, String>
1+
public struct Newtype {
2+
public var newtypeField: Result<Int, String>
33
}

.golden/swiftBasicRecordSpec/golden

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Data {
2-
var field0: Int
3-
var field1: Int?
1+
public struct Data {
2+
public var field0: Int
3+
public var field1: Int?
44
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
struct Data: Hashable, Codable {}
1+
public struct Data: Hashable, Codable {}
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
struct Data<A: Hashable & Codable>: Hashable, Codable {}
1+
public struct Data<A: Hashable & Codable>: Hashable, Codable {}
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
struct Data {
2-
var field0: Int
3-
// Deprecated since build 500
4-
// var field1: Int?
1+
public struct Data {
2+
public var field0: Int
3+
// Deprecated since build 500
4+
// public var field1: Int?
55
}

.golden/swiftEnumSumOfProductDocSpec/golden

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/// Top-level documentation describing ``Enum``.
2-
enum Enum: CaseIterable, Hashable, Codable {
2+
public enum Enum: CaseIterable, Hashable, Codable {
33
/// A constructor.
44
case dataCons0(Record0)
55
/// Another constructor.
66
case dataCons1(Record1)
77

8-
enum CodingKeys: String, CodingKey {
8+
public enum CodingKeys: String, CodingKey {
99
case tag
1010
case contents
1111
}
1212

13-
init(from decoder: any Decoder) throws {
13+
public init(from decoder: any Decoder) throws {
1414
let container = try decoder.container(keyedBy: CodingKeys.self)
1515
let discriminator = try container.decode(String.self, forKey: .tag)
1616
switch discriminator {
@@ -26,7 +26,7 @@ enum Enum: CaseIterable, Hashable, Codable {
2626
}
2727
}
2828

29-
func encode(to encoder: any Encoder) throws {
29+
public func encode(to encoder: any Encoder) throws {
3030
var container = encoder.container(keyedBy: CodingKeys.self)
3131
switch (self) {
3232
case let .dataCons0(contents):

.golden/swiftEnumSumOfProductSpec/golden

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
enum Enum: Hashable, Codable {
1+
public enum Enum: Hashable, Codable {
22
case dataCons0(_ enumField0: Int, _ enumField1: Int)
33
case dataCons1(_ enumField2: String, _ enumField3: String)
44

5-
enum CodingKeys: String, CodingKey {
5+
public enum CodingKeys: String, CodingKey {
66
case tag
77
case enumField0
88
case enumField1
99
case enumField2
1010
case enumField3
1111
}
1212

13-
init(from decoder: any Decoder) throws {
13+
public init(from decoder: any Decoder) throws {
1414
let container = try decoder.container(keyedBy: CodingKeys.self)
1515
let discriminator = try container.decode(String.self, forKey: .tag)
1616
switch discriminator {
@@ -32,7 +32,7 @@ enum Enum: Hashable, Codable {
3232
}
3333
}
3434

35-
func encode(to encoder: any Encoder) throws {
35+
public func encode(to encoder: any Encoder) throws {
3636
var container = encoder.container(keyedBy: CodingKeys.self)
3737
switch (self) {
3838
case let .dataCons0:

.golden/swiftEnumSumOfProductWithNameCollisionSpec/golden

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
enum Enum: Codable {
1+
public enum Enum: Codable {
22
case record0(Record0)
33
case record1(Record1)
44
case record2
55

6-
enum CodingKeys: String, CodingKey {
6+
public enum CodingKeys: String, CodingKey {
77
case tag
88
case contents
99
}
1010

11-
init(from decoder: any Decoder) throws {
11+
public init(from decoder: any Decoder) throws {
1212
let container = try decoder.container(keyedBy: CodingKeys.self)
1313
let discriminator = try container.decode(String.self, forKey: .tag)
1414
switch discriminator {
@@ -26,7 +26,7 @@ enum Enum: Codable {
2626
}
2727
}
2828

29-
func encode(to encoder: any Encoder) throws {
29+
public func encode(to encoder: any Encoder) throws {
3030
var container = encoder.container(keyedBy: CodingKeys.self)
3131
switch (self) {
3232
case let .record0(contents):

.golden/swiftEnumSumOfProductWithTaggedFlatObjectStyleSpec/golden

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
enum Enum: Codable {
1+
public enum Enum: Codable {
22
case dataCons0(Record0)
33
case dataCons1(Record1)
44
case dataCons2
55
case _unknown
66

7-
enum CodingKeys: String, CodingKey {
7+
public enum CodingKeys: String, CodingKey {
88
case tag
99
}
1010

11-
init(from decoder: any Decoder) throws {
11+
public init(from decoder: any Decoder) throws {
1212
let container = try decoder.container(keyedBy: CodingKeys.self)
1313
let discriminator = try container.decode(String.self, forKey: .tag)
1414
switch discriminator {
@@ -23,7 +23,7 @@ enum Enum: Codable {
2323
}
2424
}
2525

26-
func encode(to encoder: any Encoder) throws {
26+
public func encode(to encoder: any Encoder) throws {
2727
var container = encoder.container(keyedBy: CodingKeys.self)
2828
switch (self) {
2929
case let .dataCons0(value):

.golden/swiftEnumSumOfProductWithTaggedObjectStyleSpec/golden

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
enum Enum: Codable {
1+
public enum Enum: Codable {
22
case dataCons0(Record0)
33
case dataCons1(Record1)
44
case dataCons2
55

6-
enum CodingKeys: String, CodingKey {
6+
public enum CodingKeys: String, CodingKey {
77
case tag
88
case contents
99
}
1010

11-
init(from decoder: any Decoder) throws {
11+
public init(from decoder: any Decoder) throws {
1212
let container = try decoder.container(keyedBy: CodingKeys.self)
1313
let discriminator = try container.decode(String.self, forKey: .tag)
1414
switch discriminator {
@@ -26,7 +26,7 @@ enum Enum: Codable {
2626
}
2727
}
2828

29-
func encode(to encoder: any Encoder) throws {
29+
public func encode(to encoder: any Encoder) throws {
3030
var container = encoder.container(keyedBy: CodingKeys.self)
3131
switch (self) {
3232
case let .dataCons0(contents):

.golden/swiftEnumValueClassDocSpec/golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// Top-level enum documentation.
2-
enum EnumAsValueClass: CaseIterable, Hashable, Codable {
2+
public enum EnumAsValueClass: CaseIterable, Hashable, Codable {
33
/// ``First``
44
case first
55
/// ``Second``

.golden/swiftEnumValueClassSpec/golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum EnumAsValueClass: CaseIterable, Hashable, Codable {
1+
public enum EnumAsValueClass: CaseIterable, Hashable, Codable {
22
case first
33
case second
44
case third

.golden/swiftGenericAliasSpec/golden

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
typealias TreeResponse = Tree
1+
public typealias TreeResponse = Tree
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct LTree<A: Hashable & Codable>: Hashable, Codable {
2-
typealias LTreeTag = Tagged<LTree, [A]>
3-
let value: LTreeTag
1+
public struct LTree<A: Hashable & Codable>: Hashable, Codable {
2+
public typealias LTreeTag = Tagged<LTree, [A]>
3+
public let value: LTreeTag
44
}

.golden/swiftGenericStructSpec/golden

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Tree<A: Hashable & Codable>: Hashable, Codable {
2-
var rootLabel: A
3-
var subForest: [Tree<A>]
1+
public struct Tree<A: Hashable & Codable>: Hashable, Codable {
2+
public var rootLabel: A
3+
public var subForest: [Tree<A>]
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Data<A: Hashable & Codable, B: Hashable & Codable>: CaseIterable, Hashable, Codable {
2-
var field0: A
3-
var field1: B
1+
public struct Data<A: Hashable & Codable, B: Hashable & Codable>: CaseIterable, Hashable, Codable {
2+
public var field0: A
3+
public var field1: B
44
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// Record 0 with duplicate fields
2-
struct Data0 {
3-
var field0: Int
2+
public struct Data0 {
3+
public var field0: Int
44
/// not a duplicate
5-
var field1: Int?
5+
public var field1: Int?
66
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Documentation for ``Record0``.
2-
struct Record0: CaseIterable, Hashable, Codable {
2+
public struct Record0: CaseIterable, Hashable, Codable {
33
/// The zeroth field of record 0
4-
var record0Field0: Int
4+
public var record0Field0: Int
55
/// The first field of record 0
6-
var record0Field1: Int
6+
public var record0Field1: Int
77
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Record0: Codable {
2-
var record0Field0: Int
3-
var record0Field1: Int
1+
public struct Record0: Codable {
2+
public var record0Field0: Int
3+
public var record0Field1: Int
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Record0: Codable {
2-
var record0Field0: Int
3-
var record0Field1: Int
1+
public struct Record0: Codable {
2+
public var record0Field0: Int
3+
public var record0Field1: Int
44
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// Record 1 with duplicate fields
2-
struct Data1 {
3-
var field0: String
2+
public struct Data1 {
3+
public var field0: String
44
/// not a duplicate
5-
var field2: String?
5+
public var field2: String?
66
}
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// Documentation for ``Record1``.
2-
struct Record1: CaseIterable, Hashable, Codable {
2+
public struct Record1: CaseIterable, Hashable, Codable {
33
/// The zeroth field of record 1
4-
var record1Field0: Int
4+
public var record1Field0: Int
55
/// The first field of record 1
6-
var record1Field1: Int
6+
public var record1Field1: Int
77
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Record1: Codable {
2-
var record1Field0: Int
3-
var record1Field1: Int
1+
public struct Record1: Codable {
2+
public var record1Field0: Int
3+
public var record1Field1: Int
44
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct Record1: Codable {
2-
var record1Field0: Int
3-
var record1Field1: Int
1+
public struct Record1: Codable {
2+
public var record1Field0: Int
3+
public var record1Field1: Int
44
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
enum EnumA {
1+
public enum EnumA {
22
case enumFirst
33
}

0 commit comments

Comments
 (0)