Skip to content

Conversation

@glessard
Copy link
Contributor

@glessard glessard commented Oct 5, 2023

Adapt a test from swift-corelibs-foundation, where JSON decoding could produce the wrong dynamic type. Add this test to prevent regressions. Original issue: swiftlang/swift-corelibs-foundation#4806

Addresses rdar://116548255

Adapt a test from swift-corelibs-foundation, where the compiler produced the wrong dynamic type. Test to prevent regressions.
@glessard
Copy link
Contributor Author

glessard commented Oct 5, 2023

@swift-ci please test

@glessard glessard requested a review from iCharlesHu October 5, 2023 23:23
Copy link
Contributor

@kperryua kperryua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this extant test verifies the same behavior. Can you verify?

    func testDecodingConcreteTypeParameter() {
        let encoder = JSONEncoder()
        guard let json = try? encoder.encode(Employee.testValue) else {
            XCTFail("Unable to encode Employee.")
            return
        }

        let decoder = JSONDecoder()
        guard let decoded = try? decoder.decode(Employee.self as Person.Type, from: json) else {
            XCTFail("Failed to decode Employee as Person from JSON.")
            return
        }

        expectEqual(type(of: decoded), Employee.self, "Expected decoded value to be of type Employee; got \(type(of: decoded)) instead.")
    }

@glessard
Copy link
Contributor Author

glessard commented Oct 5, 2023

@glessard glessard closed this Oct 5, 2023
@glessard glessard deleted the jsondecoder-test branch October 9, 2023 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants