@@ -750,33 +750,11 @@ extension JSONDecoderImpl {
750
750
}
751
751
752
752
func superDecoder( ) throws -> Decoder {
753
- do {
754
- return try decoderForKey ( _JSONKey. super)
755
- } catch DecodingError . keyNotFound {
756
- var newPath = self . codingPath
757
- newPath. append ( _JSONKey. super)
758
- return JSONDecoderImpl (
759
- userInfo: self . impl. userInfo,
760
- from: . null,
761
- codingPath: newPath,
762
- options: self . impl. options
763
- )
764
- }
753
+ return decoderForKeyNoThrow ( _JSONKey. super)
765
754
}
766
755
767
756
func superDecoder( forKey key: K ) throws -> Decoder {
768
- do {
769
- return try decoderForKey ( key)
770
- } catch DecodingError . keyNotFound {
771
- var newPath = self . codingPath
772
- newPath. append ( key)
773
- return JSONDecoderImpl (
774
- userInfo: self . impl. userInfo,
775
- from: . null,
776
- codingPath: newPath,
777
- options: self . impl. options
778
- )
779
- }
757
+ return decoderForKeyNoThrow ( key)
780
758
}
781
759
782
760
private func decoderForKey< LocalKey: CodingKey > ( _ key: LocalKey ) throws -> JSONDecoderImpl {
@@ -792,6 +770,25 @@ extension JSONDecoderImpl {
792
770
)
793
771
}
794
772
773
+ private func decoderForKeyNoThrow< LocalKey: CodingKey > ( _ key: LocalKey ) -> JSONDecoderImpl {
774
+ let value : JSONValue
775
+ do {
776
+ value = try getValue ( forKey: key)
777
+ } catch {
778
+ // if there no value for this key then return a null value
779
+ value = . null
780
+ }
781
+ var newPath = self . codingPath
782
+ newPath. append ( key)
783
+
784
+ return JSONDecoderImpl (
785
+ userInfo: self . impl. userInfo,
786
+ from: value,
787
+ codingPath: newPath,
788
+ options: self . impl. options
789
+ )
790
+ }
791
+
795
792
@inline ( __always) private func getValue< LocalKey: CodingKey > ( forKey key: LocalKey ) throws -> JSONValue {
796
793
guard let value = dictionary [ key. stringValue] else {
797
794
throw DecodingError . keyNotFound ( key, . init(
0 commit comments