I found what might be an issue with the logic of function overloaded when using the some
keyword. Given the example code below, I don't think it's possible to call the second makeExample
declaration, yet the code compiles fine.
struct Example: Identifiable { let id: Int }
// 1
func makeExample() -> Example {
Example(id: 0)
}
// 2
func makeExample() -> some Identifiable {
Example(id: 0)
}
func test() {
let example: Example = makeExample() // always calls 1
let example = makeExample() // ambiguous error
}
Doesn't seem to be a big deal, but maybe the compiler should throw an error in the case where you overshadow a function returning an opaque type by overloading it with a concrete type?