Skip to content
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

[SR-10849] (fixed in Xcode 11) Type metadata dispatches to wrong init #53239

Closed
swift-ci opened this issue Jun 6, 2019 · 1 comment
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 6, 2019

Previous ID SR-10849
Radar None
Original Reporter benpious (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Xcode 10.2.1, Swift 5 compiler.

Does not reproduce in Xcode 11.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: a927639914e0575f63fb5106e5ea51d3

duplicates:

  • SR-10285 Subclass of a class that conforms to a protocol and extends NSObject is not instantiate correctly

Issue Description:

This is seemingly fixed in Xcode 11, but in case y'all weren't aware of it here's a repro case.

Because I hope that this will be closed as a dupe, I haven't done a lot of work to narrow down the root cause, so the sample project might be a little bloated: the code is spread out into three modules, as it is in our real project.

The TL:DR is that it seems as though if you subclass a type that conforms to `MyProtocol` in your module, then pass your type metadata into a function `create(_ type: MyProtocol.Type) -> MyProtocol`, you'll get instances of your superclass, rather than instances of the type you actually passed in.

@belkadan
Copy link
Contributor

belkadan commented Jun 7, 2019

We do have this one, but it's good to have confirmation that it's fixed. Thank you for taking the time to file it! If we didn't have a test case for it, it would be a great thing to add.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants