I just tracked down a very puzzling bug we had that ended up being related to having two similarly named, but distinct methods: pin(productId:) and pin(productId:completion:). The latter has an optional argument with nil default value.
The former is intended to be used only by that subsystem in our app. There's a companion class that calls it, but higher-level code should not. Unfortunately, higher-level code was trying to call the second form, but not passing a completion closure, and the compiler resolved that into a call to the former.
The obvious solution here is for one of them to be public and the other…not public. But afaik, Swift offers no way to do this without either combining all the related classes into one file and using fileprivate, or creating a separate module and using internal.
Thing is, creating a module is a bit heavyweight. In Xcode, I'd have to make a Package or Framework project, and set up some dependencies, and I'm constantly making changes to it, it adds a lot of friction.
I kinda wish Swift had adopted Java's approach of packaging with hierarchical naming. But in that vein, is there any way to designate some files as belonging together without going all the way to a package?
Would it make sense to be able to write module Foo in my Swift source files, and import Foo where I want to use them, without them having to be in a separate physical package?
Also: Shouldn't the compiler have warned me that a call was amiguous?