@@ -474,6 +474,24 @@ class TestJSONEncoder : XCTestCase {
474474 XCTFail ( " Caught error during decoding empty super decoder: \( error) " )
475475 }
476476 }
477+
478+ func test_childTypeDecoder( ) {
479+ class BaseTestType : Decodable { }
480+ class ChildTestType : BaseTestType { }
481+
482+ func dynamicTestType( ) -> BaseTestType . Type {
483+ return ChildTestType . self
484+ }
485+
486+ let decoder = JSONDecoder ( )
487+ do {
488+ let testType = dynamicTestType ( )
489+ let instance = try decoder. decode ( testType, from: Data ( #"{}"# . utf8) )
490+ XCTAssertTrue ( instance is ChildTestType )
491+ } catch {
492+ XCTFail ( " Caught error during decoding empty super decoder: \( error) " )
493+ }
494+ }
477495
478496 // MARK: - Test encoding and decoding of built-in Codable types
479497 func test_codingOfBool( ) {
@@ -1562,6 +1580,7 @@ extension TestJSONEncoder {
15621580 ( " test_nestedContainerCodingPaths " , test_nestedContainerCodingPaths) ,
15631581 ( " test_superEncoderCodingPaths " , test_superEncoderCodingPaths) ,
15641582 ( " test_notFoundSuperDecoder " , test_notFoundSuperDecoder) ,
1583+ ( " test_childTypeDecoder " , test_childTypeDecoder) ,
15651584 ( " test_codingOfBool " , test_codingOfBool) ,
15661585 ( " test_codingOfNil " , test_codingOfNil) ,
15671586 ( " test_codingOfInt8 " , test_codingOfInt8) ,
0 commit comments