Skip to content

Commit 5bf9280

Browse files
committed
fix: adds missing nonisolated key in generated files
1 parent d3ac85c commit 5bf9280

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

Sources/ThemeKitGenerator/ShapeStyleExtensionGenerator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ nonisolated public struct ShapeStyleExtensionGenerator: Sendable {
1313
import SwiftUI
1414
import ThemeKit
1515
16-
extension ShapeStyle where Self == ThemeShapeStyle<\(category.styleType)> {
16+
nonisolated extension ShapeStyle where Self == ThemeShapeStyle<\(category.styleType)> {
1717
\(staticProperties)
1818
}
1919
@@ -26,7 +26,7 @@ nonisolated public struct ShapeStyleExtensionGenerator: Sendable {
2626

2727
content += """
2828
29-
extension ShapeStyle {
29+
nonisolated extension ShapeStyle {
3030
\(instanceProperties)
3131
}
3232

Tests/ThemeKitGeneratorTests/ThemeFileGeneratorTests.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,25 @@ struct ThemeFileGeneratorTests {
152152
#expect(gradientsExt.content.contains("ThemeShapeStyle<Gradient>"))
153153
}
154154

155+
@Test func shapeStyleExtension_usesNonisolated() throws {
156+
let files = try ThemeFileGenerator().generate(fromJSON: fullJSON).files
157+
158+
let colorsExt = try #require(files.first { $0.name == "ShapeStyle+ThemeColors.swift" })
159+
#expect(colorsExt.content.contains("nonisolated extension ShapeStyle"))
160+
161+
let gradientsExt = try #require(files.first { $0.name == "ShapeStyle+ThemeGradients.swift" })
162+
#expect(gradientsExt.content.contains("nonisolated extension ShapeStyle"))
163+
}
164+
165+
@Test func shadowShapeStyleExtension_bothBlocksUseNonisolated() throws {
166+
let files = try ThemeFileGenerator().generate(fromJSON: shadowsOnlyJSON).files
167+
let shadowExt = try #require(files.first { $0.name == "ShapeStyle+ThemeShadows.swift" })
168+
169+
// Both the constrained static extension and unconstrained instance extension must be nonisolated
170+
let matches = shadowExt.content.components(separatedBy: "nonisolated extension ShapeStyle")
171+
#expect(matches.count == 3, "Expected two 'nonisolated extension ShapeStyle' occurrences (splits into 3 parts)")
172+
}
173+
155174
@Test func copyWith_themeUsesOptionalParams() throws {
156175
let files = try ThemeFileGenerator().generate(fromJSON: fullJSON).files
157176
let copyWith = try #require(files.first { $0.name == "Theme+CopyWith.swift" })

0 commit comments

Comments
 (0)