Skip to content

Commit 02210e0

Browse files
committed
Fixed _SwiftNSCharacterSet._cfObject
1 parent 6bde2d4 commit 02210e0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Foundation/CharacterSet.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ internal final class _SwiftNSCharacterSet : NSCharacterSet, _SwiftNativeFoundati
9494
override func isSuperset(of other: CharacterSet) -> Bool {
9595
return _mapUnmanaged { $0.isSuperset(of: other) }
9696
}
97+
98+
override var _cfObject: CFType {
99+
// We cannot inherit super's unsafeBitCast(self, to: CFType.self) here, because layout of _SwiftNSCharacterSet
100+
// is not compatible with CFCharacterSet. We need to bitcast the underlying NSCharacterSet instead.
101+
return _mapUnmanaged { unsafeBitCast($0, to: CFType.self) }
102+
}
97103
}
98104

99105
/**
@@ -486,10 +492,7 @@ extension CharacterSet : _ObjectTypeBridgeable {
486492

487493
@_semantics("convertToObjectiveC")
488494
public func _bridgeToObjectiveC() -> NSCharacterSet {
489-
switch _wrapped.__wrapped {
490-
case .Mutable(let wrapped): return wrapped.takeUnretainedValue()
491-
case .Immutable(let wrapped): return wrapped.takeUnretainedValue()
492-
}
495+
return _wrapped
493496
}
494497

495498
public static func _forceBridgeFromObjectiveC(_ input: NSCharacterSet, result: inout CharacterSet?) {

0 commit comments

Comments
 (0)