Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redundant conformance constraint warning in Swift 4

Tags:

swift

swift4

I just migrated a Swift 3.1 project from Xcode 8.3.3 to Swift 4 / Xcode 9 GM. I managed to resolve most compiler warnings, but this one sticks and I cannot find any info related to this. The code compiled without warning in Xcode 8.3.3. I am using snippets to illustrate the issue.

The warning exact warning is

FirebaseArrayDelegate.swift:22:26: 
    Redundant conformance constraint 'T': 'FirebaseModel'

and relates to the declaration of func initialized (third line).

public protocol FirebaseArrayDelegate: class {

    func update(with block: (()->Void)?)
    func initialized<T : FirebaseModel>(array: FirebaseArray<T>)
    func added<T : FirebaseModel>(child: T, at index: Int)
    func changed<T : FirebaseModel>(child: T, at index: Int)
    func removed<T : FirebaseModel>(child: T, at index: Int)
    func moved<T : FirebaseModel>(child: T, from oldIndex: Int, to newIndex: Int)
    func changedSortOrder()
    func cancelled(with error: Error)

}

FirebaseModel is defined as

public protocol FirebaseModel: AnyObject, Equatable {

    init?(snapshot: DataSnapshot)
    var key: String { get }
    var ref: DatabaseReference { get }

}

and FirebaseArray as

open class FirebaseArray<T : FirebaseModel>: NSObject, Collection

Any idea what could cause this warning or might this be a bug in Xcode 9 GM? Thanks!

like image 211
Georg Avatar asked Sep 14 '17 15:09

Georg


1 Answers

This is a bug in Swift, hopefully it will be addressed soon.

See: https://bugs.swift.org/browse/SR-6265

like image 174
Dermot Avatar answered Nov 14 '22 02:11

Dermot