Skip to content

Commit

Permalink
Fix use of Swift 6 language mode (#150)
Browse files Browse the repository at this point in the history
* Replace '#if swift(>=6.0)' with '#if compiler(>=6.0)'

* Only deprecate old withSpan functions if compiler >= 6.0

---------

Co-authored-by: Konrad `ktoso` Malawski <[email protected]>
  • Loading branch information
orobio and ktoso authored Oct 9, 2024
1 parent 3ee42aa commit 6483d34
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
12 changes: 9 additions & 3 deletions Sources/Tracing/Tracer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ public func withSpan<T>(
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if swift(>=6.0)
#if compiler(>=6.0)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
public func withSpan<T, Instant: TracerInstant>(
_ operationName: String,
Expand All @@ -349,8 +349,10 @@ public func withSpan<T, Instant: TracerInstant>(
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload
@available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
public func withSpan<T, Instant: TracerInstant>(
_ operationName: String,
Expand Down Expand Up @@ -398,7 +400,7 @@ public func withSpan<T, Instant: TracerInstant>(
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if swift(>=6.0)
#if compiler(>=6.0)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
public func withSpan<T>(
_ operationName: String,
Expand All @@ -424,8 +426,10 @@ public func withSpan<T>(
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload
@available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
public func withSpan<T>(
_ operationName: String,
Expand Down Expand Up @@ -473,7 +477,7 @@ public func withSpan<T>(
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if swift(>=6.0)
#if compiler(>=6.0)
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func withSpan<T>(
_ operationName: String,
Expand All @@ -500,8 +504,10 @@ public func withSpan<T>(
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload
@available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func withSpan<T>(
_ operationName: String,
Expand Down
12 changes: 9 additions & 3 deletions Sources/Tracing/TracerProtocol+Legacy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ extension LegacyTracer {
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if swift(>=6.0)
#if compiler(>=6.0)
public func withAnySpan<T, Instant: TracerInstant>(
_ operationName: String,
at instant: @autoclosure () -> Instant,
Expand Down Expand Up @@ -340,8 +340,10 @@ extension LegacyTracer {
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload
@available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
public func withAnySpan<T, Instant: TracerInstant>(
_ operationName: String,
at instant: @autoclosure () -> Instant,
Expand Down Expand Up @@ -397,7 +399,7 @@ extension LegacyTracer {
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if swift(>=6.0)
#if compiler(>=6.0)
public func withAnySpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -429,8 +431,10 @@ extension LegacyTracer {
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload
@available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
public func withAnySpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -602,7 +606,7 @@ extension Tracer {
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if swift(>=6.0)
#if compiler(>=6.0)
public func withAnySpan<T>(
_ operationName: String,
at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now,
Expand All @@ -628,8 +632,10 @@ extension Tracer {
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload
@available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
public func withAnySpan<T>(
_ operationName: String,
at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now,
Expand Down
8 changes: 6 additions & 2 deletions Sources/Tracing/TracerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ extension Tracer {
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if swift(>=6.0)
#if compiler(>=6.0)
public func withSpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -274,8 +274,10 @@ extension Tracer {
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload
@available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
public func withSpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -329,7 +331,7 @@ extension Tracer {
/// - operation: The operation that this span should be measuring
/// - Returns: the value returned by `operation`
/// - Throws: the error the `operation` has thrown (if any)
#if swift(>=6.0)
#if compiler(>=6.0)
public func withSpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down Expand Up @@ -362,8 +364,10 @@ extension Tracer {
}
#endif

#if compiler(>=6.0)
@_disfavoredOverload
@available(*, deprecated, message: "Prefer #isolation version of this API")
#endif
public func withSpan<T>(
_ operationName: String,
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
Expand Down

0 comments on commit 6483d34

Please sign in to comment.