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-2289] Dynamic casts of CoreFoundation types don't work #44896

Closed
gribozavr opened this issue Aug 5, 2016 · 4 comments
Closed

[SR-2289] Dynamic casts of CoreFoundation types don't work #44896

gribozavr opened this issue Aug 5, 2016 · 4 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself runtime The Swift Runtime

Comments

@gribozavr
Copy link
Contributor

Previous ID SR-2289
Radar rdar://problem/27116100
Original Reporter @gribozavr
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Runtime
Assignee @tbkka
Priority Medium

md5: 540dd3cbf15c2fc1a75d48b4738ea25f

Issue Description:

See disabled test cases in {test/1_stdlib//Casts.swift}. Dynamic casts from CoreFoundation types to protocol existentials (for protocols that they implement) don't work.

@belkadan
Copy link
Contributor

belkadan commented Aug 5, 2016

@tbkka
Copy link
Contributor

tbkka commented Jan 15, 2020

The test cases in question attempt to:

  • Extend a CF class with a protocol conformance

  • Create an CF object

  • Cast it to the protocol in question

This turns out to be a somewhat ambiguous thing to try to do: When dealing with references to class objects, the runtime caster will normalize the object types. For most CF objects, this results in the caster working with the corresponding Objective-C type instead of the CF type. One possible solution would be for the runtime dynamic cast code to try both the provided (CF) type and the normalized (Obj-C) type in such cases.

@tbkka
Copy link
Contributor

tbkka commented Aug 27, 2020

#33561 should fix this for the non-optimized case (where the cast is being handled by the runtime). There may still be issues with optimized casts, though.

@tbkka
Copy link
Contributor

tbkka commented Jan 5, 2021

I believe the PR mentioned above has resolved this. Please let me know if you see any further problems in this area.

@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 itself runtime The Swift Runtime
Projects
None yet
Development

No branches or pull requests

3 participants