Skip to content

JSONDecoder parse type differently on Linux #4806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ypli-chn opened this issue Aug 3, 2023 · 1 comment
Closed

JSONDecoder parse type differently on Linux #4806

ypli-chn opened this issue Aug 3, 2023 · 1 comment

Comments

@ypli-chn
Copy link
Contributor

ypli-chn commented Aug 3, 2023

Example Code

import Foundation

class Base: Codable { }
class Child: Base { }

func dynamicType() -> Base.Type {
    return Child.self
}

let data = "{}".data(using: .utf8)!

let classType = dynamicType()
let instance = try JSONDecoder().decode(classType, from: data)
print("type: \(instance) => \(type(of: instance))")

on macOS:

type: JSONDecoderExample.Child => Child

on Linux:

type: JSONDecoderExample.Base => Base
@glessard
Copy link
Contributor

glessard commented Oct 5, 2023

Fixed in #4807

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

No branches or pull requests

2 participants