Fix a couple build warnings

This commit is contained in:
Alex Hoppen
2025-07-14 11:09:31 +02:00
parent 10411dd127
commit 0b3db5e49b
5 changed files with 17 additions and 7 deletions

View File

@@ -232,7 +232,7 @@ extension RandomAccessCollection {
return body(scratchArea)
}
package func concurrentCompactMap<T>(_ f: @Sendable (Element) -> T?) -> [T] where Self: Sendable {
package func concurrentCompactMap<T>(_ f: @Sendable (Element) -> T?) -> [T] where Self: Sendable, Index: Sendable {
return withMapScratchArea { (results: UnsafeMutablePointer<T?>) -> [T] in
// `nonisolated(unsafe)` is fine because we write to different offsets within the buffer on every concurrent
// iteration.
@@ -245,7 +245,7 @@ extension RandomAccessCollection {
}
}
package func concurrentMap<T>(_ f: @Sendable (Element) -> T) -> [T] where Self: Sendable {
package func concurrentMap<T>(_ f: @Sendable (Element) -> T) -> [T] where Self: Sendable, Index: Sendable {
return withMapScratchArea { (results: UnsafeMutablePointer<T>) -> [T] in
// `nonisolated(unsafe)` is fine because we write to different offsets within the buffer on every concurrent
// iteration.
@@ -289,8 +289,13 @@ protocol ContiguousZeroBasedIndexedCollection: Collection where Index == Int {
var indices: Range<Int> { get }
}
#if compiler(<6.2)
/// Provide a compatibility layer for `SendableMetatype` if it doesn't exist in the compiler
typealias SendableMetatype = Any
#endif
extension ContiguousZeroBasedIndexedCollection {
func slicedConcurrentForEachSliceRange(body: @Sendable (Range<Index>) -> Void) {
func slicedConcurrentForEachSliceRange(body: @Sendable (Range<Index>) -> Void) where Self: SendableMetatype {
// We want to use `DispatchQueue.concurrentPerform`, but we want to be called only a few times. So that we
// can amortize per-callback work. We also want to oversubscribe so that we can efficiently use
// heterogeneous CPUs. If we had 4 efficiency cores, and 4 performance cores, and we dispatched 8 work items

View File

@@ -43,7 +43,7 @@ package final class LoggingScope {
package func withLoggingSubsystemAndScope<Result>(
subsystem: String,
scope: String?,
@_inheritActorContext _ operation: @Sendable () throws -> Result
_ operation: @Sendable () throws -> Result
) rethrows -> Result {
return try LoggingScope.$_subsystem.withValue(subsystem) {
return try LoggingScope.$_scope.withValue(scope, operation: operation)

View File

@@ -15,9 +15,14 @@ import SKLogging
import SwiftRefactor
import SwiftSyntax
#if compiler(<6.2)
/// Provide a compatibility layer for `SendableMetatype` if it doesn't exist in the compiler
typealias SendableMetatype = Any
#endif
/// Describes types that provide one or more code actions based on purely
/// syntactic information.
protocol SyntaxCodeActionProvider {
protocol SyntaxCodeActionProvider: SendableMetatype {
/// Produce code actions within the given scope. Each code action
/// corresponds to one syntactic transformation that can be performed, such
/// as adding or removing separators from an integer literal.

View File

@@ -132,7 +132,7 @@ package func withCancellableCheckedThrowingContinuation<Handle: Sendable, Result
)
}
extension Collection where Element: Sendable {
extension Collection where Self: Sendable, Element: Sendable {
/// Transforms all elements in the collection concurrently and returns the transformed collection.
package func concurrentMap<TransformedElement: Sendable>(
maxConcurrentTasks: Int = ProcessInfo.processInfo.processorCount,

View File

@@ -770,7 +770,7 @@ struct SwiftPMBuildServerTests {
// We opened the project from a symlink. The realpath isn't part of the project and we should thus not receive
// build settings for it.
#expect(
try await #require(
try #require(
await buildServerManager.buildSettingsInferredFromMainFile(
for: DocumentURI(aswiftReal),
language: .swift,