From b20f92b1bdf9ff6aa6add21fdb56ed8b00bf2afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Pacheco=20Neves?= Date: Thu, 10 Oct 2019 14:53:59 +0100 Subject: [PATCH] Fix compiler failure in Xcode 11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some unknown reason (at least to me) the `subscript(position:)` extension on `MutableCollection` where `Index == Int` was causing the swift compiler to crash with a weird `DESERIALIZATION FAILURE` error, as mentioned on #15. Updating the `subscript` to use `C.Index` instead of `Int` appears to make the compiler happy and successfully compile the project. My suspicion is that it somehow enables it to disambiguate between the multiple `subscript` implementations, but it's pure speculation 🔮. On our tests this seems to have fixed the issue, and since it's an equivalent definition of the subscript (even though more "precise" from a generic POV), it should cause no side effects. Fixes #15. 🎉 --- Sources/NonEmpty/NonEmpty+MutableCollection.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/NonEmpty/NonEmpty+MutableCollection.swift b/Sources/NonEmpty/NonEmpty+MutableCollection.swift index 93dd3e8..3b3771b 100644 --- a/Sources/NonEmpty/NonEmpty+MutableCollection.swift +++ b/Sources/NonEmpty/NonEmpty+MutableCollection.swift @@ -28,7 +28,7 @@ extension NonEmpty: MutableCollection where C: MutableCollection { } extension NonEmpty where C: MutableCollection, C.Index == Int { - public subscript(position: Int) -> Element { + public subscript(position: C.Index) -> Element { get { return self[position == 0 ? .head : .tail(self.tail.startIndex + position - 1)] }