Skip to content

Instantly share code, notes, and snippets.

@hiroshi-maybe
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save hiroshi-maybe/d90dfe63f6ca046dae73 to your computer and use it in GitHub Desktop.

Select an option

Save hiroshi-maybe/d90dfe63f6ca046dae73 to your computer and use it in GitHub Desktop.
Infinite recursive call in Swift 2.0
protocol Eq {
typealias A = Self
func equalsTo(a: A) -> Bool
func notEqualsTo(a: A) -> Bool
}
extension Eq {
func equalsTo(a: A) -> Bool { return !self.notEqualsTo(a) }
func notEqualsTo(a: A) -> Bool { return self.equalsTo(a) }
}
extension Int : Eq {
func equalsTo(a: Int) -> Bool { return self == a }
}
let x = 1
// infinite recursive call happens and crashes on Xcode Version 7.0 beta 4 (7A165t)
print("x \(x.notEqualsTo(1))")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment