From f0231e287ffb6b1bed7ef37a6f1fdafa37028e6e Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Tue, 2 Jun 2026 11:06:52 -0700 Subject: [PATCH 1/2] Workspace: explicit weak captures in semanticIndexManager callbacks Inner closures captured `sourceKitLSPServer` implicitly. The outer `Task` already captures it weakly, making it a `var` in scope; inner @Sendable closures that capture this `var` implicitly trigger the `SendableClosureCaptures` diagnostic on compiler configurations without `ImmutableWeakCaptures`. Add explicit `[weak sourceKitLSPServer]` to each inner closure so the capture binds cleanly to a fresh weak local. --- Sources/SourceKitLSP/Workspace.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/SourceKitLSP/Workspace.swift b/Sources/SourceKitLSP/Workspace.swift index 97698e44..171b511d 100644 --- a/Sources/SourceKitLSP/Workspace.swift +++ b/Sources/SourceKitLSP/Workspace.swift @@ -262,13 +262,13 @@ package final class Workspace: Sendable, BuildServerManagerDelegate { hooks: hooks.indexHooks, indexTaskScheduler: indexTaskScheduler, preparationBatchingStrategy: options.preparationBatchingStrategy, - logMessageToIndexLog: { + logMessageToIndexLog: { [weak sourceKitLSPServer] in sourceKitLSPServer?.logMessageToIndexLog(message: $0, type: $1, structure: $2) }, - indexTasksWereScheduled: { + indexTasksWereScheduled: { [weak sourceKitLSPServer] in sourceKitLSPServer?.indexProgressManager.indexTasksWereScheduled(count: $0) }, - indexProgressStatusDidChange: { + indexProgressStatusDidChange: { [weak sourceKitLSPServer] in sourceKitLSPServer?.indexProgressManager.indexProgressStatusDidChange() } ) @@ -399,7 +399,7 @@ package final class Workspace: Sendable, BuildServerManagerDelegate { [weak sourceKitLSPServer] (initializationData, mainFilesChangedCallback) -> (any MainFilesProvider)? in await createIndex( initializationData: initializationData, - indexChangedCallback: { + indexChangedCallback: { [weak sourceKitLSPServer] in // Notify that main files may have changed. await mainFilesChangedCallback() From 1b7f310e92155e0a376701f356fba6504225800a Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Tue, 2 Jun 2026 11:08:51 -0700 Subject: [PATCH 2/2] UncheckedIndex: mark IndexStoreDB? init param as sending ThreadSafeBox.init takes `consuming sending Value`, so its argument must be region-isolated. Without `sending` on this init's parameter, callers in some build configurations couldn't satisfy the sending requirement and triggered SendingRisksDataRace. --- Sources/SemanticIndex/CheckedIndex.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SemanticIndex/CheckedIndex.swift b/Sources/SemanticIndex/CheckedIndex.swift index d223d515..ca8069bd 100644 --- a/Sources/SemanticIndex/CheckedIndex.swift +++ b/Sources/SemanticIndex/CheckedIndex.swift @@ -344,7 +344,7 @@ package final actor UncheckedIndex: Sendable { /// The set of unit output paths that are currently registered in the underlying `IndexStoreDB`. private var unitOutputPaths: Set = [] - package init?(_ index: IndexStoreDB?, usesExplicitOutputPaths: Bool) { + package init?(_ index: sending IndexStoreDB?, usesExplicitOutputPaths: Bool) { guard let index else { return nil }