Skip to content

Commit

Permalink
Fix compiler failure in Xcode 11
Browse files Browse the repository at this point in the history
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. 馃帀
  • Loading branch information
p4checo committed Oct 10, 2019
1 parent 51391d6 commit b20f92b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/NonEmpty/NonEmpty+MutableCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
}
Expand Down

0 comments on commit b20f92b

Please sign in to comment.