Skip to content

Commit

Permalink
Fixes issue around mutable capture of 'inout' parameter 'buffer' is n…
Browse files Browse the repository at this point in the history
…ot allowed in concurrently-executing code (#1363)
  • Loading branch information
mapierce committed Aug 29, 2024
1 parent f1974a5 commit 4e10fa7
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/jazzy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ concurrency:

jobs:
update_docs:
runs-on: macos-13
runs-on: macos-14
steps:
- name: Set Xcode 15.1.0
run: sudo xcode-select -s /Applications/Xcode_15.1.0.app/Contents/Developer
- name: Set Xcode 15.3.0
run: sudo xcode-select -s /Applications/Xcode_15.3.0.app/Contents/Developer
- name: Print Current Xcode
run: xcode-select -p
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release_macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
build:
needs: [tests]
name: Build Sourcery for macOS
runs-on: macos-13
runs-on: macos-14
steps:
- name: Set Xcode 15.1.0
run: sudo xcode-select -s /Applications/Xcode_15.1.0.app/Contents/Developer
- name: Set Xcode 15.3.0
run: sudo xcode-select -s /Applications/Xcode_15.3.0.app/Contents/Developer
- name: Print Current Xcode
run: xcode-select -p
- uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ concurrency:

jobs:
macos_build:
runs-on: macos-13
runs-on: macos-14
steps:
- name: Set Xcode 15.1.0
run: sudo xcode-select -s /Applications/Xcode_15.1.0.app/Contents/Developer
- name: Set Xcode 15.3.0
run: sudo xcode-select -s /Applications/Xcode_15.3.0.app/Contents/Developer
- name: Print Current Xcode
run: xcode-select -p
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup Swift
uses: YOCKOW/Action-setup-swift@main
with:
swift-version: "5.9.2"
swift-version: "5.10"
- name: Get swift version
run: swift --version
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions SourceryRuntime/Sources/Common/Array+Parallel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public extension Array {
func parallelMap<T>(transform: (Element) -> T) -> [T] {
var result = ContiguousArray<T?>(repeating: nil, count: count)
return result.withUnsafeMutableBufferPointer { buffer in
nonisolated(unsafe) let buffer = buffer
DispatchQueue.concurrentPerform(iterations: buffer.count) { idx in
buffer[idx] = transform(self[idx])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public extension Array {
func parallelMap<T>(transform: (Element) -> T) -> [T] {
var result = ContiguousArray<T?>(repeating: nil, count: count)
return result.withUnsafeMutableBufferPointer { buffer in
nonisolated(unsafe) let buffer = buffer
DispatchQueue.concurrentPerform(iterations: buffer.count) { idx in
buffer[idx] = transform(self[idx])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public extension Array {
func parallelMap<T>(transform: (Element) -> T) -> [T] {
var result = ContiguousArray<T?>(repeating: nil, count: count)
return result.withUnsafeMutableBufferPointer { buffer in
nonisolated(unsafe) let buffer = buffer
DispatchQueue.concurrentPerform(iterations: buffer.count) { idx in
buffer[idx] = transform(self[idx])
}
Expand Down
3 changes: 2 additions & 1 deletion SourceryTests/Generating/SwiftTemplateSpecs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class SwiftTemplateTests: QuickSpec {
}
.to(throwError(closure: { (error) in
let path = Path.cleanTemporaryDir(name: "build").parent() + "/version/Sources/SwiftTemplate/main.swift"
expect("\(error)").to(contain("\(path):11:27: error: missing argument for parameter #1 in call\nsourceryBuffer.append(\"\\( )\");\n ^\n"))
expect("\(error)").to(contain("\(path):11:27: error: missing argument for parameter #1 in call"))
expect("\(error)").to(contain("sourceryBuffer.append(\"\\( )\");"))
}))
}

Expand Down

0 comments on commit 4e10fa7

Please sign in to comment.