Skip to content

Commit 642a8f9

Browse files
committed
[embedded] #ifdef the Dictionary.init(uniqueKeysWithValues:) changes only to Embedded Swift
1 parent c99e9e4 commit 642a8f9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

stdlib/public/core/Dictionary.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,13 +486,20 @@ public struct Dictionary<Key: Hashable, Value> {
486486
// error instead of calling fatalError() directly because we want the
487487
// message to include the duplicate key, and the closure only has access to
488488
// the conflicting values.
489+
#if !$Embedded
490+
try! native.merge(
491+
keysAndValues,
492+
isUnique: true,
493+
uniquingKeysWith: { _, _ in throw _MergeError.keyCollision })
494+
#else
489495
native.merge(
490496
keysAndValues,
491497
isUnique: true,
492498
uniquingKeysWith: { _, _ throws(_MergeError) in
493499
throw _MergeError.keyCollision
494500
}
495501
)
502+
#endif
496503
self.init(_native: native)
497504
}
498505

stdlib/public/core/NativeDictionary.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ extension _NativeDictionary { // High-level operations
791791
}
792792
}
793793

794+
#if $Embedded
794795
@inlinable
795796
internal mutating func merge<S: Sequence>(
796797
_ keysAndValues: __owned S,
@@ -817,6 +818,7 @@ extension _NativeDictionary { // High-level operations
817818
}
818819
}
819820
}
821+
#endif
820822

821823
@inlinable
822824
@inline(__always)

0 commit comments

Comments
 (0)