Skip to content

Commit caeef6b

Browse files
authored
Generate concurrency-safe code in test bundle (#1274)
With the new concurrency features in Swift 6, there are also a set of checks that ensure that the code is safe to run concurrently. Public static mutable variables are considered unsafe unless they are specifically of a type that conforms to `Sendable`. This patch changes the test bundle generation to use `let` instead of `var` in the case of `public static` properties.
1 parent 1a01b54 commit caeef6b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bin/make-test-bundle/Sources/make-test-bundle/Node/PropertyNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class PropertyNode: TypeMemberNode {
5353
if isDynamic {
5454
result += "\(levelString) \(kindString) var \(name.lowercased()): \(propertyType) { return \(propertyType)(\(propertyValue)) }\n"
5555
} else {
56-
result += "\(levelString) \(kindString) var \(name.lowercased()): \(propertyType) = \(propertyValue)\n"
56+
result += "\(levelString) \(kindString) \(kind == .static ? "let" : "var") \(name.lowercased()): \(propertyType) = \(propertyValue)\n"
5757
}
5858

5959
if kind == .interface {

0 commit comments

Comments
 (0)