Same issue with this topic: Name disambiguation of computed property/function with same type defined in extensions
MuduleA
extension String {
public func capitalized() -> String {
return "ModuleA"
}
}
ModuleB
extension String {
public func capitalized() -> String {
return "ModuleB"
}
}
ModuleC
import ModuleA
import ModuleB
let capitalized = "hello swift".capitalized()
print(capitalized)
Error: Ambiguous use of 'capitalized'
After reading the blog: Swift Import Declarations - NSHipster, we can import individual declarations, such as:
// ModuleA
func foo() {}
// ModuleC
import func ModuleA.foo
foo()
But swift do not support import extensions like this. So do we need a proposal like this:
// ModuleA
extension String {
public func capitalized() -> String {
return "ModuleA"
}
}
// MuduleC
import extension ModuleA.String.capitalized
or
import String.extension ModuleA.capitalized
or
import extension.String ModuleA.capitalized