SwifterSwift: Getting `ambiguous use of 'makeIterator()'` error when building package with Xcode 14

Describe the bug The package will fail to build and install when used inside a project being compiled on Xcode 14 beta, with an ambiguous use of 'makeIterator()' error.

To Reproduce

  1. Add SwifterSwift as a package inside an iOS project.
  2. Open project in Xcode 14 beta.
  3. Attempt to build app.

Expected behavior The SwifterSwift package will not fail to build when using Xcode 14 beta.

Additional context

Here’s a screenshot of the error: Screen Shot 2022-08-31 at 10 07 12 AM

I’m about to open a PR which addresses this issue!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 4
  • Comments: 17 (13 by maintainers)

Most upvoted comments

Workaround changes landed! Was actually an interesting compiler bug finding Thank you @ianclawson @theedov

This is the reduced reproducer:

struct S: Sequence {
  private var _storage: [UInt8] = []
  func makeIterator() -> Array<UInt8>.Iterator {
    _storage.makeIterator()
  }
  
  typealias Element = UInt8
  class Iterator: IteratorProtocol {
    func next() -> UInt8? { 0 }
    typealias Element = UInt8
  }

  func makeIterator() -> Iterator {
    Iterator()
  }
}
extension S {
  func f() {
    for elt in self { //  error: ambiguous use of 'makeIterator()'
      print(elt)
    }
  }
}

I’ve already reported the bug on https://github.com/apple/swift/issues/