Conflict between Swift.Error and RealmSwift.Error
I got bunch of this error message while converting my project to Swift 3.
"'Error' is ambiguous for type lookup in this context"
I should change all "Error" to "Swift.Error" in my code.
This is really pain in the ass....
Same issue
Swift's namespacing requires that conflicting declarations be disambiguated using their fully qualified name (e.g. Swift.Error/RealmSwift.Error). We discussed renaming Error in #4086 but ultimately decided against it.
It's impossible for us to avoid conflicts in all configurations, but this is how Swift's namespacing was designed. If you'd like Swift's behavior to change, please file a ticket at https://bugs.swift.org.
Sad to hear that.
I had to edit hundreds of Error to Swift.Error in my project.
There are many blocks using Error as parameter in iOS and macOS APIs.
I thought that Realm is made for easy use.. but this is not easy.
Now I have to modify every time Error appears on autocompleted functions and block parameters.
If someone add a Realm to the project already exists, they may get bunch of error messages and don't know what should do. It's hard to think that there will be another 'Error' and should convert 'Error' to 'Swift.Error' in iOS/macOS APIs.
This is why most of 3rd party libraries use prefix for their naming.
This is very disappointing. Realm should add prefix to avoid that.
If it's not resolved in future, I may switch to other databases.
Is the intended functionality for people that install this version to have to prepend Swift. to every instance of Error they use in their codebase unless they are realm errors? This is incredibly inconvenient and will make the upgrade to swift3 very painful.
We're going to move Error into an extension on Realm for Swift 3 in a few days. This will be a source breaking change.
Most helpful comment
Sad to hear that.
I had to edit hundreds of Error to Swift.Error in my project.
There are many blocks using Error as parameter in iOS and macOS APIs.
I thought that Realm is made for easy use.. but this is not easy.
Now I have to modify every time Error appears on autocompleted functions and block parameters.
If someone add a Realm to the project already exists, they may get bunch of error messages and don't know what should do. It's hard to think that there will be another 'Error' and should convert 'Error' to 'Swift.Error' in iOS/macOS APIs.
This is why most of 3rd party libraries use prefix for their naming.