@@ -725,8 +725,7 @@ public func swift_unboxFromSwiftValueWithType<T>(
725
725
// Internal stdlib SPI
726
726
@_silgen_name ( " swift_swiftValueConformsTo " )
727
727
public func _swiftValueConformsTo< T> ( _ type: T . Type ) -> Bool {
728
- _assertSwiftValueFlavorIsConsistent ( )
729
- if let foundationType = _typeByName ( " Foundation._SwiftValue " ) {
728
+ if let foundationType = _foundationSwiftValueType {
730
729
return foundationType is T . Type
731
730
} else {
732
731
return _SwiftValue. self is T . Type
@@ -750,38 +749,11 @@ extension Optional: _Unwrappable {
750
749
}
751
750
}
752
751
753
- // This is a best-effort tripmine for detecting the situation
754
- // (which should never happen) of Swift._SwiftValue and
755
- // Foundation._SwiftValue/Foundation.NSNull being used
756
- // in the same process.
757
-
758
- @usableFromInline
759
- internal enum _SwiftValueFlavor : Equatable {
760
- case stdlib
761
- case foundation
762
- }
763
-
764
- @usableFromInline
765
- func _currentSwiftValueFlavor( ) -> _SwiftValueFlavor {
766
- if _typeByName ( " Foundation._SwiftValue " ) as? _NSSwiftValue . Type != nil {
767
- return . foundation
768
- } else {
769
- return . stdlib
770
- }
771
- }
772
-
773
- @usableFromInline
774
- internal var _selectedSwiftValueFlavor : _SwiftValueFlavor = _currentSwiftValueFlavor ( )
775
-
776
- @usableFromInline
777
- internal func _assertSwiftValueFlavorIsConsistent( ) {
778
- assert ( _selectedSwiftValueFlavor == _currentSwiftValueFlavor ( ) )
779
- }
752
+ private let _foundationSwiftValueType = _typeByName ( " Foundation._SwiftValue " ) as? _NSSwiftValue . Type
780
753
781
754
@usableFromInline
782
755
internal var _nullPlaceholder : AnyObject {
783
- _assertSwiftValueFlavorIsConsistent ( )
784
- if let foundationType = _typeByName ( " Foundation._SwiftValue " ) as? _NSSwiftValue . Type {
756
+ if let foundationType = _foundationSwiftValueType {
785
757
return foundationType. null
786
758
} else {
787
759
return _SwiftValue. null
@@ -790,8 +762,7 @@ internal var _nullPlaceholder: AnyObject {
790
762
791
763
@usableFromInline
792
764
func _makeSwiftValue( _ value: Any ) -> AnyObject {
793
- _assertSwiftValueFlavorIsConsistent ( )
794
- if let foundationType = _typeByName ( " Foundation._SwiftValue " ) as? _NSSwiftValue . Type {
765
+ if let foundationType = _foundationSwiftValueType {
795
766
return foundationType. init ( value)
796
767
} else {
797
768
return _SwiftValue ( value)
0 commit comments