@@ -119,6 +119,7 @@ extension Backtrace: Codable {
119
119
// MARK: - Backtraces for thrown errors
120
120
121
121
extension Backtrace {
122
+ #if !hasFeature(Embedded)
122
123
// MARK: - Error cache keys
123
124
124
125
/// A type used as a cache key that uniquely identifies error existential
@@ -321,6 +322,7 @@ extension Backtrace {
321
322
}
322
323
forward ( errorType)
323
324
}
325
+ #endif
324
326
325
327
/// Whether or not Foundation provides a function that triggers the capture of
326
328
/// backtaces when instances of `NSError` or `CFError` are created.
@@ -336,7 +338,7 @@ extension Backtrace {
336
338
/// - Note: The underlying Foundation function is called (if present) the
337
339
/// first time the value of this property is read.
338
340
static let isFoundationCaptureEnabled = {
339
- #if _runtime(_ObjC) && !SWT_NO_DYNAMIC_LINKING
341
+ #if !hasFeature(Embedded) && _runtime(_ObjC) && !SWT_NO_DYNAMIC_LINKING
340
342
if Environment . flag ( named: " SWT_FOUNDATION_ERROR_BACKTRACING_ENABLED " ) == true {
341
343
let _CFErrorSetCallStackCaptureEnabled = symbol ( named: " _CFErrorSetCallStackCaptureEnabled " ) . map {
342
344
castCFunction ( at: $0, to: ( @convention( c) ( DarwinBoolean) - > DarwinBoolean) . self)
@@ -348,6 +350,7 @@ extension Backtrace {
348
350
return false
349
351
} ( )
350
352
353
+ #if !hasFeature(Embedded)
351
354
/// The implementation of ``Backtrace/startCachingForThrownErrors()``, run
352
355
/// only once.
353
356
///
@@ -373,6 +376,7 @@ extension Backtrace {
373
376
}
374
377
}
375
378
} ( )
379
+ #endif
376
380
377
381
/// Configure the Swift runtime to allow capturing backtraces when errors are
378
382
/// thrown.
@@ -381,17 +385,21 @@ extension Backtrace {
381
385
/// developer-supplied code to ensure that thrown errors' backtraces are
382
386
/// always captured.
383
387
static func startCachingForThrownErrors( ) {
388
+ #if !hasFeature(Embedded)
384
389
__SWIFT_TESTING_IS_CAPTURING_A_BACKTRACE_FOR_A_THROWN_ERROR__
390
+ #endif
385
391
}
386
392
387
393
/// Flush stale entries from the error-mapping cache.
388
394
///
389
395
/// Call this function periodically to ensure that errors do not continue to
390
396
/// take up space in the cache after they have been deinitialized.
391
397
static func flushThrownErrorCache( ) {
398
+ #if !hasFeature(Embedded)
392
399
_errorMappingCache. withLock { cache in
393
400
cache = cache. filter { $0. value. errorObject != nil }
394
401
}
402
+ #endif
395
403
}
396
404
397
405
/// Initialize an instance of this type with the previously-cached backtrace
@@ -411,6 +419,7 @@ extension Backtrace {
411
419
/// initializer cannot be made an instance method or property of `Error`
412
420
/// because doing so will cause Swift-native errors to be unboxed into
413
421
/// existential containers with different addresses.
422
+ #if !hasFeature(Embedded)
414
423
@inline ( never)
415
424
init ? ( forFirstThrowOf error: any Error , checkFoundation: Bool = true ) {
416
425
if checkFoundation && Self . isFoundationCaptureEnabled,
@@ -430,4 +439,9 @@ extension Backtrace {
430
439
return nil
431
440
}
432
441
}
442
+ #else
443
+ init ? ( forFirstThrowOf error: some Error , checkFoundation: Bool = true ) {
444
+ return nil
445
+ }
446
+ #endif
433
447
}
0 commit comments