Skip to content

Commit 56a91e9

Browse files
authored
Merge pull request #2202 from ahoppen/fix-build-warnings
Fix a couple build warnings
2 parents aef6510 + 0b3db5e commit 56a91e9

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

Sources/CompletionScoring/Utilities/SwiftExtensions.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ extension RandomAccessCollection {
232232
return body(scratchArea)
233233
}
234234

235-
package func concurrentCompactMap<T>(_ f: @Sendable (Element) -> T?) -> [T] where Self: Sendable {
235+
package func concurrentCompactMap<T>(_ f: @Sendable (Element) -> T?) -> [T] where Self: Sendable, Index: Sendable {
236236
return withMapScratchArea { (results: UnsafeMutablePointer<T?>) -> [T] in
237237
// `nonisolated(unsafe)` is fine because we write to different offsets within the buffer on every concurrent
238238
// iteration.
@@ -245,7 +245,7 @@ extension RandomAccessCollection {
245245
}
246246
}
247247

248-
package func concurrentMap<T>(_ f: @Sendable (Element) -> T) -> [T] where Self: Sendable {
248+
package func concurrentMap<T>(_ f: @Sendable (Element) -> T) -> [T] where Self: Sendable, Index: Sendable {
249249
return withMapScratchArea { (results: UnsafeMutablePointer<T>) -> [T] in
250250
// `nonisolated(unsafe)` is fine because we write to different offsets within the buffer on every concurrent
251251
// iteration.
@@ -289,8 +289,13 @@ protocol ContiguousZeroBasedIndexedCollection: Collection where Index == Int {
289289
var indices: Range<Int> { get }
290290
}
291291

292+
#if compiler(<6.2)
293+
/// Provide a compatibility layer for `SendableMetatype` if it doesn't exist in the compiler
294+
typealias SendableMetatype = Any
295+
#endif
296+
292297
extension ContiguousZeroBasedIndexedCollection {
293-
func slicedConcurrentForEachSliceRange(body: @Sendable (Range<Index>) -> Void) {
298+
func slicedConcurrentForEachSliceRange(body: @Sendable (Range<Index>) -> Void) where Self: SendableMetatype {
294299
// We want to use `DispatchQueue.concurrentPerform`, but we want to be called only a few times. So that we
295300
// can amortize per-callback work. We also want to oversubscribe so that we can efficiently use
296301
// heterogeneous CPUs. If we had 4 efficiency cores, and 4 performance cores, and we dispatched 8 work items

Sources/SKLogging/LoggingScope.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ package final class LoggingScope {
4343
package func withLoggingSubsystemAndScope<Result>(
4444
subsystem: String,
4545
scope: String?,
46-
@_inheritActorContext _ operation: @Sendable () throws -> Result
46+
_ operation: @Sendable () throws -> Result
4747
) rethrows -> Result {
4848
return try LoggingScope.$_subsystem.withValue(subsystem) {
4949
return try LoggingScope.$_scope.withValue(scope, operation: operation)

Sources/SourceKitLSP/Swift/CodeActions/SyntaxCodeActionProvider.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ import SKLogging
1515
import SwiftRefactor
1616
import SwiftSyntax
1717

18+
#if compiler(<6.2)
19+
/// Provide a compatibility layer for `SendableMetatype` if it doesn't exist in the compiler
20+
typealias SendableMetatype = Any
21+
#endif
22+
1823
/// Describes types that provide one or more code actions based on purely
1924
/// syntactic information.
20-
protocol SyntaxCodeActionProvider {
25+
protocol SyntaxCodeActionProvider: SendableMetatype {
2126
/// Produce code actions within the given scope. Each code action
2227
/// corresponds to one syntactic transformation that can be performed, such
2328
/// as adding or removing separators from an integer literal.

Sources/SwiftExtensions/AsyncUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ package func withCancellableCheckedThrowingContinuation<Handle: Sendable, Result
132132
)
133133
}
134134

135-
extension Collection where Element: Sendable {
135+
extension Collection where Self: Sendable, Element: Sendable {
136136
/// Transforms all elements in the collection concurrently and returns the transformed collection.
137137
package func concurrentMap<TransformedElement: Sendable>(
138138
maxConcurrentTasks: Int = ProcessInfo.processInfo.processorCount,

Tests/BuildServerIntegrationTests/SwiftPMBuildServerTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ struct SwiftPMBuildServerTests {
770770
// We opened the project from a symlink. The realpath isn't part of the project and we should thus not receive
771771
// build settings for it.
772772
#expect(
773-
try await #require(
773+
try #require(
774774
await buildServerManager.buildSettingsInferredFromMainFile(
775775
for: DocumentURI(aswiftReal),
776776
language: .swift,

0 commit comments

Comments
 (0)