Add workaround for Optional JSONEncoding errors #1317
Merged
+61
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is basically a band-aid on #1305 and similar bugs, which could occur when using a custom JSON scalar and trying to persist it to the cache. If the type of the typealiased JSON was
[String: Any?]
, which is expected, theas JSONEncodable
would fail to recognize several types that have that conformance in an extension, and those types need to be unwrapped manually.This is a band-aid rather than a permanent fix because once I can get the Swift codegen stuff going again, I'm going to rip all this
JSONEncodable
stuff out in favor of aCodable
solution (you can see a preview of the more flexible part of this in the JSON type I'm using in the Codegen lib).But that's gonna be a hot minute, so band-aid it is!