Skip to content

Commit 1b914a7

Browse files
committed
Fix a memory leak in BackgroundIndexingTests.testPrepareTargetAfterEditToDependency
The closure that handled the `DiagnosticsRefreshRequest` was retaining `project`, which constituted a retain cycle.
1 parent a29f1ac commit 1b914a7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Tests/SourceKitLSPTests/BackgroundIndexingTests.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -604,13 +604,14 @@ final class BackgroundIndexingTests: XCTestCase {
604604
)
605605

606606
let receivedEmptyDiagnostics = self.expectation(description: "Received diagnostic refresh request")
607+
receivedEmptyDiagnostics.assertForOverFulfill = false
607608
project.testClient.handleMultipleRequests { (_: CreateWorkDoneProgressRequest) in
608609
return VoidResponse()
609610
}
610611

611-
project.testClient.handleMultipleRequests { (_: DiagnosticsRefreshRequest) in
612-
Task {
613-
let updatedDiagnostics = try await project.testClient.send(
612+
project.testClient.handleMultipleRequests { [weak project] (_: DiagnosticsRefreshRequest) in
613+
Task { [weak project] in
614+
let updatedDiagnostics = try await project?.testClient.send(
614615
DocumentDiagnosticsRequest(textDocument: TextDocumentIdentifier(uri))
615616
)
616617
guard case .full(let updatedDiagnostics) = updatedDiagnostics else {

0 commit comments

Comments
 (0)