Skip to content

ObjCPromise initializer fails for arrays in Swift 6.4 #245

Description

@thorfroelich

The following initializer fails its precondition under Swift 6.4 when T is an array:

public init<T>(_ objCPromise: ObjCPromise<T>) {
  guard let objCPromise = objCPromise as? ObjCPromise<AnyObject> 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 ArrayAnyObject 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions