@@ -750,33 +750,11 @@ extension JSONDecoderImpl {
750750 }
751751
752752 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)
765754 }
766755
767756 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)
780758 }
781759
782760 private func decoderForKey< LocalKey: CodingKey > ( _ key: LocalKey ) throws -> JSONDecoderImpl {
@@ -792,6 +770,25 @@ extension JSONDecoderImpl {
792770 )
793771 }
794772
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+
795792 @inline ( __always) private func getValue< LocalKey: CodingKey > ( forKey key: LocalKey ) throws -> JSONValue {
796793 guard let value = dictionary [ key. stringValue] else {
797794 throw DecodingError . keyNotFound ( key, . init(
0 commit comments