After upgrading to Xcode 8 and converting all my code to Swift 3, I have troubles compiling swift resources. It takes a very long time, and my computer gets super laggy and
In my case, I was writing a class that implemented Equatable
and also had generic members. My issue was rooted in comparing the generic members with ==
, when the generic class didn't have a ==
operator implemented.
For example (using Variable
from RxSwift
):
class Foo: Equatable {
var fieldOne: Variable = Variable("fieldOne")
var fieldTwo: Variable = Variable(nil)
public static func ==(lhs: Foo, rhs: Foo) -> Bool {
//should be marked as a compiler error, since Variable doesn't have ==
return lhs.fieldOne == rhs.fieldOne && lhs.fieldTwo == rhs.fieldTwo
}
}
I should have seen a compiler error for this since no definition of ==
exists for Variable
, but the compiler would crash (as well as the static analysis) before being able to show it. I was seeing memory usage of 60GB+ before the crash. Yikes.
It seems swift still has some lingering bugs when it comes to generics.