Skip to content

Fix a couple build warnings #2202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions Sources/CompletionScoring/Utilities/SwiftExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Sources/SKLogging/LoggingScope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Contributor

@bnbarham bnbarham Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only available in 6.2. I added a:

+#if compiler(<6.2)
+package typealias SendableMetatype = Any
+#endif

in AsyncUtils.swift in mine.

/// 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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftExtensions/AsyncUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down