@@ -474,6 +474,24 @@ class TestJSONEncoder : XCTestCase {
474
474
XCTFail ( " Caught error during decoding empty super decoder: \( error) " )
475
475
}
476
476
}
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
+ }
477
495
478
496
// MARK: - Test encoding and decoding of built-in Codable types
479
497
func test_codingOfBool( ) {
@@ -1562,6 +1580,7 @@ extension TestJSONEncoder {
1562
1580
( " test_nestedContainerCodingPaths " , test_nestedContainerCodingPaths) ,
1563
1581
( " test_superEncoderCodingPaths " , test_superEncoderCodingPaths) ,
1564
1582
( " test_notFoundSuperDecoder " , test_notFoundSuperDecoder) ,
1583
+ ( " test_childTypeDecoder " , test_childTypeDecoder) ,
1565
1584
( " test_codingOfBool " , test_codingOfBool) ,
1566
1585
( " test_codingOfNil " , test_codingOfNil) ,
1567
1586
( " test_codingOfInt8 " , test_codingOfInt8) ,
0 commit comments