Skip to content

Commit 661da46

Browse files
committed
Enable InferIsolatedConformances and NonisolatedNonsendingByDefault
This allows us to easily get rid of some `@_inheritActorContext`. The others seem to be a little more tricky and I haven’t spent too much time at trying to figure out how to remove the attribute from those.
1 parent cfe3ea9 commit 661da46

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

Package.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ var globalSwiftSettings: [SwiftSetting] {
88
var result: [SwiftSetting] = [
99
.enableUpcomingFeature("InternalImportsByDefault"),
1010
.enableUpcomingFeature("MemberImportVisibility"),
11+
.enableUpcomingFeature("InferIsolatedConformances"),
12+
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
1113
]
1214
if noSwiftPMDependency {
1315
result += [.define("NO_SWIFTPM_DEPENDENCY")]

Sources/SKLogging/LoggingScope.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ package func withLoggingSubsystemAndScope<Result>(
5454
package func withLoggingSubsystemAndScope<Result>(
5555
subsystem: String,
5656
scope: String?,
57-
@_inheritActorContext _ operation: @Sendable () async throws -> Result
57+
@_inheritActorContext _ operation: @Sendable @concurrent () async throws -> Result
5858
) async rethrows -> Result {
5959
return try await LoggingScope.$_subsystem.withValue(subsystem) {
6060
return try await LoggingScope.$_scope.withValue(scope, operation: operation)
@@ -84,7 +84,7 @@ package func withLoggingScope<Result>(
8484
/// - SeeAlso: ``withLoggingScope(_:_:)-6qtga``
8585
package func withLoggingScope<Result>(
8686
_ scope: String,
87-
@_inheritActorContext _ operation: @Sendable () async throws -> Result
87+
@_inheritActorContext _ operation: @Sendable @concurrent () async throws -> Result
8888
) async rethrows -> Result {
8989
return try await LoggingScope.$_scope.withValue(
9090
scope,

Sources/SKLogging/OrLog.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ package func orLog<R>(
4141
package func orLog<R>(
4242
_ prefix: @autoclosure () -> String,
4343
level: LogLevel = .error,
44-
@_inheritActorContext _ block: @Sendable () async throws -> R?
44+
_ block: () async throws -> R?
4545
) async -> R? {
4646
do {
4747
return try await block()

Sources/SKTestSupport/Utils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ package func testScratchDir(testName: String = #function) throws -> URL {
9898
/// The temporary directory will be deleted at the end of `directory` unless the
9999
/// `SOURCEKIT_LSP_KEEP_TEST_SCRATCH_DIR` environment variable is set.
100100
package func withTestScratchDir<T>(
101-
@_inheritActorContext _ body: @Sendable (URL) async throws -> T,
101+
_ body: (URL) async throws -> T,
102102
testName: String = #function
103103
) async throws -> T {
104104
let scratchDirectory = try testScratchDir(testName: testName)

Sources/SwiftExtensions/AsyncUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ package actor RefCountedCancellableTask<Success: Sendable> {
2424
/// Whether the task has been cancelled.
2525
package private(set) var isCancelled: Bool = false
2626

27-
package init(priority: TaskPriority? = nil, operation: @escaping @Sendable () async throws -> Success) {
27+
package init(priority: TaskPriority? = nil, operation: @escaping @Sendable @concurrent () async throws -> Success) {
2828
self.task = Task(priority: priority, operation: operation)
2929
}
3030

Sources/SwiftExtensions/Sequence+AsyncMap.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
extension Sequence {
1414
/// Just like `Sequence.map` but allows an `async` transform function.
1515
package func asyncMap<T>(
16-
@_inheritActorContext _ transform: @Sendable (Element) async throws -> T
16+
_ transform: (Element) async throws -> T
1717
) async rethrows -> [T] {
1818
var result: [T] = []
1919
result.reserveCapacity(self.underestimatedCount)
@@ -27,7 +27,7 @@ extension Sequence {
2727

2828
/// Just like `Sequence.flatMap` but allows an `async` transform function.
2929
package func asyncFlatMap<SegmentOfResult: Sequence>(
30-
@_inheritActorContext _ transform: @Sendable (Element) async throws -> SegmentOfResult
30+
_ transform: (Element) async throws -> SegmentOfResult
3131
) async rethrows -> [SegmentOfResult.Element] {
3232
var result: [SegmentOfResult.Element] = []
3333
result.reserveCapacity(self.underestimatedCount)
@@ -41,7 +41,7 @@ extension Sequence {
4141

4242
/// Just like `Sequence.compactMap` but allows an `async` transform function.
4343
package func asyncCompactMap<T>(
44-
@_inheritActorContext _ transform: @Sendable (Element) async throws -> T?
44+
_ transform: (Element) async throws -> T?
4545
) async rethrows -> [T] {
4646
var result: [T] = []
4747

@@ -56,7 +56,7 @@ extension Sequence {
5656

5757
/// Just like `Sequence.map` but allows an `async` transform function.
5858
package func asyncFilter(
59-
@_inheritActorContext _ predicate: @Sendable (Element) async throws -> Bool
59+
_ predicate: (Element) async throws -> Bool
6060
) async rethrows -> [Element] {
6161
var result: [Element] = []
6262

@@ -70,9 +70,7 @@ extension Sequence {
7070
}
7171

7272
/// Just like `Sequence.first` but allows an `async` predicate function.
73-
package func asyncFirst(
74-
@_inheritActorContext where predicate: @Sendable (Element) async throws -> Bool
75-
) async rethrows -> Element? {
73+
package func asyncFirst(where predicate: (Element) async throws -> Bool) async rethrows -> Element? {
7674
for element in self {
7775
if try await predicate(element) {
7876
return element
@@ -84,7 +82,7 @@ extension Sequence {
8482

8583
/// Just like `Sequence.contains` but allows an `async` predicate function.
8684
package func asyncContains(
87-
@_inheritActorContext where predicate: @Sendable (Element) async throws -> Bool
85+
where predicate: (Element) async throws -> Bool
8886
) async rethrows -> Bool {
8987
return try await asyncFirst(where: predicate) != nil
9088
}

0 commit comments

Comments
 (0)