Fix crash when accessing the -[MPIdentityApiRequest identity] property from Swift due to incorrect type hinting
We had it hinted as <NSNumber*, NSString*> but then we also stored NSNull objects in some cases. That was fine with Objective-C since it ignores the type hints at runtime, but Swift doesn't and crashes if any NSNull objects are present when accessing the identities property.
Note this doesn't actually change the underlying behavior of this property in any way, it just now is correctly type hinted as <NSNumber*, NSObject*> to include the possibility of NSNull.
Testing Plan
[x] Was this tested locally? If not, explain why.
First reproduced the crash, then confirmed that I can now access the property from Swift without crashing. Also added unit tests to confirm both the core behavior and the Swift interop, explicitly accessing the property from Swift when it contains an NSNull object.
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)
Summary
Fix crash when accessing the
-[MPIdentityApiRequest identity]
property from Swift due to incorrect type hintingWe had it hinted as
<NSNumber*, NSString*>
but then we also storedNSNull
objects in some cases. That was fine with Objective-C since it ignores the type hints at runtime, but Swift doesn't and crashes if any NSNull objects are present when accessing theidentities
property.Note this doesn't actually change the underlying behavior of this property in any way, it just now is correctly type hinted as
<NSNumber*, NSObject*>
to include the possibility ofNSNull
.Testing Plan
First reproduced the crash, then confirmed that I can now access the property from Swift without crashing. Also added unit tests to confirm both the core behavior and the Swift interop, explicitly accessing the property from Swift when it contains an NSNull object.
Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)