Skip to content

Commit 6483d34

Browse files
orobioktoso
andauthored
Fix use of Swift 6 language mode (#150)
* 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]>
1 parent 3ee42aa commit 6483d34

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

Sources/Tracing/Tracer.swift

+9-3
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public func withSpan<T>(
322322
/// - operation: The operation that this span should be measuring
323323
/// - Returns: the value returned by `operation`
324324
/// - Throws: the error the `operation` has thrown (if any)
325-
#if swift(>=6.0)
325+
#if compiler(>=6.0)
326326
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
327327
public func withSpan<T, Instant: TracerInstant>(
328328
_ operationName: String,
@@ -349,8 +349,10 @@ public func withSpan<T, Instant: TracerInstant>(
349349
}
350350
#endif
351351

352+
#if compiler(>=6.0)
352353
@_disfavoredOverload
353354
@available(*, deprecated, message: "Prefer #isolation version of this API")
355+
#endif
354356
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
355357
public func withSpan<T, Instant: TracerInstant>(
356358
_ operationName: String,
@@ -398,7 +400,7 @@ public func withSpan<T, Instant: TracerInstant>(
398400
/// - operation: The operation that this span should be measuring
399401
/// - Returns: the value returned by `operation`
400402
/// - Throws: the error the `operation` has thrown (if any)
401-
#if swift(>=6.0)
403+
#if compiler(>=6.0)
402404
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
403405
public func withSpan<T>(
404406
_ operationName: String,
@@ -424,8 +426,10 @@ public func withSpan<T>(
424426
}
425427
#endif
426428

429+
#if compiler(>=6.0)
427430
@_disfavoredOverload
428431
@available(*, deprecated, message: "Prefer #isolation version of this API")
432+
#endif
429433
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) // for TaskLocal ServiceContext
430434
public func withSpan<T>(
431435
_ operationName: String,
@@ -473,7 +477,7 @@ public func withSpan<T>(
473477
/// - operation: The operation that this span should be measuring
474478
/// - Returns: the value returned by `operation`
475479
/// - Throws: the error the `operation` has thrown (if any)
476-
#if swift(>=6.0)
480+
#if compiler(>=6.0)
477481
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
478482
public func withSpan<T>(
479483
_ operationName: String,
@@ -500,8 +504,10 @@ public func withSpan<T>(
500504
}
501505
#endif
502506

507+
#if compiler(>=6.0)
503508
@_disfavoredOverload
504509
@available(*, deprecated, message: "Prefer #isolation version of this API")
510+
#endif
505511
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
506512
public func withSpan<T>(
507513
_ operationName: String,

Sources/Tracing/TracerProtocol+Legacy.swift

+9-3
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ extension LegacyTracer {
307307
/// - operation: The operation that this span should be measuring
308308
/// - Returns: the value returned by `operation`
309309
/// - Throws: the error the `operation` has thrown (if any)
310-
#if swift(>=6.0)
310+
#if compiler(>=6.0)
311311
public func withAnySpan<T, Instant: TracerInstant>(
312312
_ operationName: String,
313313
at instant: @autoclosure () -> Instant,
@@ -340,8 +340,10 @@ extension LegacyTracer {
340340
}
341341
#endif
342342

343+
#if compiler(>=6.0)
343344
@_disfavoredOverload
344345
@available(*, deprecated, message: "Prefer #isolation version of this API")
346+
#endif
345347
public func withAnySpan<T, Instant: TracerInstant>(
346348
_ operationName: String,
347349
at instant: @autoclosure () -> Instant,
@@ -397,7 +399,7 @@ extension LegacyTracer {
397399
/// - operation: The operation that this span should be measuring
398400
/// - Returns: the value returned by `operation`
399401
/// - Throws: the error the `operation` has thrown (if any)
400-
#if swift(>=6.0)
402+
#if compiler(>=6.0)
401403
public func withAnySpan<T>(
402404
_ operationName: String,
403405
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
@@ -429,8 +431,10 @@ extension LegacyTracer {
429431
}
430432
#endif
431433

434+
#if compiler(>=6.0)
432435
@_disfavoredOverload
433436
@available(*, deprecated, message: "Prefer #isolation version of this API")
437+
#endif
434438
public func withAnySpan<T>(
435439
_ operationName: String,
436440
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
@@ -602,7 +606,7 @@ extension Tracer {
602606
/// - operation: The operation that this span should be measuring
603607
/// - Returns: the value returned by `operation`
604608
/// - Throws: the error the `operation` has thrown (if any)
605-
#if swift(>=6.0)
609+
#if compiler(>=6.0)
606610
public func withAnySpan<T>(
607611
_ operationName: String,
608612
at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now,
@@ -628,8 +632,10 @@ extension Tracer {
628632
}
629633
#endif
630634

635+
#if compiler(>=6.0)
631636
@_disfavoredOverload
632637
@available(*, deprecated, message: "Prefer #isolation version of this API")
638+
#endif
633639
public func withAnySpan<T>(
634640
_ operationName: String,
635641
at instant: @autoclosure () -> some TracerInstant = DefaultTracerClock.now,

Sources/Tracing/TracerProtocol.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ extension Tracer {
242242
/// - operation: The operation that this span should be measuring
243243
/// - Returns: the value returned by `operation`
244244
/// - Throws: the error the `operation` has thrown (if any)
245-
#if swift(>=6.0)
245+
#if compiler(>=6.0)
246246
public func withSpan<T>(
247247
_ operationName: String,
248248
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
@@ -274,8 +274,10 @@ extension Tracer {
274274
}
275275
#endif
276276

277+
#if compiler(>=6.0)
277278
@_disfavoredOverload
278279
@available(*, deprecated, message: "Prefer #isolation version of this API")
280+
#endif
279281
public func withSpan<T>(
280282
_ operationName: String,
281283
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
@@ -329,7 +331,7 @@ extension Tracer {
329331
/// - operation: The operation that this span should be measuring
330332
/// - Returns: the value returned by `operation`
331333
/// - Throws: the error the `operation` has thrown (if any)
332-
#if swift(>=6.0)
334+
#if compiler(>=6.0)
333335
public func withSpan<T>(
334336
_ operationName: String,
335337
context: @autoclosure () -> ServiceContext = .current ?? .topLevel,
@@ -362,8 +364,10 @@ extension Tracer {
362364
}
363365
#endif
364366

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

0 commit comments

Comments
 (0)