File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
stdlib/public/SDK/Foundation Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -815,7 +815,14 @@ internal class _NSSwiftData : NSData {
815815 }
816816
817817 override var bytes : UnsafeRawPointer {
818- return _backing. bytes!
818+ // NSData's byte pointer methods are not annotated for nullability correctly
819+ // (but assume non-null by the wrapping macro guards). This placeholder value
820+ // is to work-around this bug. Any indirection to the underlying bytes of a NSData
821+ // with a length of zero would have been a programmer error anyhow so the actual
822+ // return value here is not needed to be an allocated value. This is specifically
823+ // needed to live like this to be source compatible with Swift3. Beyond that point
824+ // this API may be subject to correction.
825+ return _backing. bytes ?? UnsafeRawPointer ( bitPattern: 0xBAD0 ) !
819826 }
820827
821828 override func copy( with zone: NSZone ? = nil ) -> Any {
You can’t perform that action at this time.
0 commit comments