From b44167b245ee45bb2e3f4fedeed98bd23b9b0611 Mon Sep 17 00:00:00 2001 From: vijaysharm Date: Wed, 13 Nov 2024 11:03:13 -0500 Subject: [PATCH] Allow for subtypes to be sendable --- CodeGen/Sources/LucidCodeGen/Meta/MetaSubtype.swift | 1 + CodeGen/Sources/LucidCodeGenCore/Codable.swift | 2 ++ CodeGen/Sources/LucidCodeGenCore/Descriptions.swift | 2 ++ 3 files changed, 5 insertions(+) diff --git a/CodeGen/Sources/LucidCodeGen/Meta/MetaSubtype.swift b/CodeGen/Sources/LucidCodeGen/Meta/MetaSubtype.swift index a7be3a24..2d0a476f 100644 --- a/CodeGen/Sources/LucidCodeGen/Meta/MetaSubtype.swift +++ b/CodeGen/Sources/LucidCodeGen/Meta/MetaSubtype.swift @@ -50,6 +50,7 @@ struct MetaSubtype { let type = Type(identifier: subtype.typeID()) .with(accessLevel: .public) .adding(inheritedType: .codable) + .adding(inheritedType: subtype.sendable ? .sendable : nil) .adding(inheritedType: .hashable) switch subtype.items { diff --git a/CodeGen/Sources/LucidCodeGenCore/Codable.swift b/CodeGen/Sources/LucidCodeGenCore/Codable.swift index 26c0e11b..edd82af9 100644 --- a/CodeGen/Sources/LucidCodeGenCore/Codable.swift +++ b/CodeGen/Sources/LucidCodeGenCore/Codable.swift @@ -757,6 +757,7 @@ extension Subtype: Codable { case objc case objcNoneCase case platforms + case sendable } public init(from decoder: Decoder) throws { @@ -765,6 +766,7 @@ extension Subtype: Codable { name = try container.decode(String.self, forKey: .name) manualImplementations = Set(try container.decodeIfPresent([`Protocol`].self, forKey: .manualImplementations) ?? []) platforms = try container.decodeIfPresent(Set.self, forKey: .platforms) ?? DescriptionDefaults.platforms + sendable = try container.decodeIfPresent(Bool.self, forKey: .sendable) ?? DescriptionDefaults.sendable if let usedCases = try container.decodeIfPresent([String].self, forKey: .cases) { let unusedCases = try container.decodeIfPresent([String].self, forKey: .unusedCases) ?? [] diff --git a/CodeGen/Sources/LucidCodeGenCore/Descriptions.swift b/CodeGen/Sources/LucidCodeGenCore/Descriptions.swift index 5bf44379..654336bd 100644 --- a/CodeGen/Sources/LucidCodeGenCore/Descriptions.swift +++ b/CodeGen/Sources/LucidCodeGenCore/Descriptions.swift @@ -645,6 +645,8 @@ public struct Subtype: Equatable { public let objc: Bool public let platforms: Set + + public let sendable: Bool } // MARK: - Conversions