`ObjCPromise` initializer fails for arrays in Swift 6.4
- Dominant language
- Objective-C
- Stars
- 3.8k
- Forks
- 316
- PR merge metrics
- No merged PRs in 30d
Description
The following initializer fails its precondition under Swift 6.4 when `T` is an array:
```
public init(_ objCPromise: ObjCPromise) {
guard let objCPromise = objCPromise as? ObjCPromise else {
preconditionFailure("Cannot cast \(T.self) to \(AnyObject.self)")
}
self.objCPromise = objCPromise
}
```
The function to get an `ObjCPromise` from a `Promise` (relying on the same `Array` → `AnyObject` cast) does too.
Replacing the current cast with an `unsafeBitCast` seems to fix the issue in both cases, but I haven't yet tested it thoroughly enough to be certain.
Contributor guide
Research direction
Start by locating the ObjCPromise initializer shown in the report and the function that converts a Promise to an ObjCPromise. Reproduce both failures with an array type under Swift 6.4, then verify that the completed change no longer triggers the precondition in either path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- objective-c, swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100