Is `unowned(unsafe) T` -> `weak T?` a breaking change?

Swift aims to avoid breaking changes as good as possible yet it seems that some are okay or even wanted. I recently spotted this change in Apple's CoreBluetooth APIs.

+ weak var peripheral: CBPeripheral? { get }
- unowned(unsafe) var peripheral: CBPeripheral { get }

I'm personally not relying on this property directly, so I'm not directly affected by this change. However it feels like a very dangerous breaking change as the type signature moved from being non-optional to an optional, which definitely will break clients code, because T is a theoretical sub-type of T?, not the other way around.

I'm asking here, because I'm not sure if this should be urgently reported to Apple or not. :thinking:

More interestingly, is this a Swift bug where some automatic conversion from Objc code got messed up, or some manually created issue inside the origin APIs?

Edit: This issue seems to repeat itself in other places as well: [1] [2]

1 Like

Swift aims to avoid breaking changes, but that doesn't mean Apple's framework overlays do as well. I believe there have been other small changes in the overlays over the years since Swift declared source stability.

Feel free to report to Apple, they may reply whether it's intentional or not.