Skip to content

Commit

Permalink
Require NSCopying when calling shallowCopy
Browse files Browse the repository at this point in the history
  • Loading branch information
max-signal authored Jan 10, 2025
1 parent 8459b86 commit 59a3e19
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions SignalServiceKit/Storage/Database/DeepCopy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class DeepCopies {
}

// "Cannot explicitly specialize a generic function."
fileprivate static func shallowCopy<T: NSObject>(_ objectToCopy: T) throws -> T {
fileprivate static func shallowCopy<T: NSObject & NSCopying>(_ objectToCopy: T) throws -> T {
guard let newCopy = objectToCopy.copy() as? T else {
throw OWSAssertionError("Could not copy: \(type(of: objectToCopy))")
}
Expand Down Expand Up @@ -213,26 +213,6 @@ extension StickerPackItem: DeepCopyable {

// MARK: -

@objc
extension Contact: DeepCopyable {
public func deepCopy() throws -> AnyObject {
// This class can use shallow copies.
return try DeepCopies.shallowCopy(self)
}
}

// MARK: -

@objc
extension Aes256Key: DeepCopyable {
public func deepCopy() throws -> AnyObject {
// This class can use shallow copies.
return try DeepCopies.shallowCopy(self)
}
}

// MARK: -

@objc
extension TSGroupModel: DeepCopyable {
public func deepCopy() throws -> AnyObject {
Expand Down Expand Up @@ -313,16 +293,6 @@ extension MobileCoinPayment: DeepCopyable {

// MARK: -

@objc
extension OWSUserProfileBadgeInfo: DeepCopyable {
public func deepCopy() throws -> AnyObject {
// This class can use shallow copies.
return try DeepCopies.shallowCopy(self)
}
}

// MARK: -

@objc
extension TSInfoMessage.LegacyPersistableGroupUpdateItemsWrapper: DeepCopyable {
public func deepCopy() throws -> AnyObject {
Expand Down

0 comments on commit 59a3e19

Please sign in to comment.