New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expected type Date for key... #101
Comments
@pepasflo Is it because your signature is a bit off? Try |
@bwhiteley That was precisely it! For those following along at home, this causes an exception: extension Date : ValueType {
public static func value(_ object: Any) throws -> Date { while this works correctly: extension Date : ValueType {
public static func value(from object: Any) throws -> Date { (the only difference being It is a shame I can't lean on the compiler to spot this difference. It turns out you can make any sort of typo in the function name, or even omit it entirely, and Xcode will compile it without complaining that extension Date : ValueType {} Why is it that I can get away with declaring an empty protocol conformance? Is this because one of the other generic implementations of |
(marking closed) |
@pepasflo It is because I've been bit by this a sort of thing few times. It can happen with ObjC protocols that have optional methods, or Swift protocols that have default implementations in a protocol extension. If you have a typo in your func name, it's not conforming to the protocol like you expect but the compiler offers no help. I've wished Swift had a Since your first message I've been reading swift-evolution discussions about such a thing. It appears there are edge cases that complicate adding such a feature. |
Thanks so much for taking to time to explain this! |
Sometimes I get into a situation where Date parsing doesn't seem to work.
This:
Throws this:
I can work around this by transforming to a string first, then to Date:
My Date support looks like so:
The text was updated successfully, but these errors were encountered: