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-13864] Conformance availability vs dynamic casts #56262

Open
slavapestov opened this issue Nov 16, 2020 · 3 comments
Open

[SR-13864] Conformance availability vs dynamic casts #56262

slavapestov opened this issue Nov 16, 2020 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@slavapestov
Copy link
Member

Previous ID SR-13864
Radar rdar://problem/71461973
Original Reporter @slavapestov
Type Bug
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee @slavapestov
Priority Medium

md5: 13f414e9d05d4909524ed22bf5e9f240

Issue Description:

There are two holes with conformance availability checking as it interacts with dynamic casts:

  • We should ensure that an unconditionally unavailable conformance is never discovered by a dynamic `as?` cast

  • We should ensure that a conditionally unavailable conformance is never discovered by a dynamic `as?` cast, even if the witness table symbol exists on the deployment target.

There might be some places we need to check in the SIL optimizer as well.

@slavapestov
Copy link
Member Author

@swift-ci create

@lorentey
Copy link
Member

> We should ensure that a conditionally unavailable conformance is never discovered by a dynamic `as?` cast, even if the witness table symbol exists on the deployment target.

I think dynamic casts ought to succeed if the conformance is available at runtime. The alternative seems far less desirable – by forcing dynamic casts to fail, we would cripple these additions with a second-rate status.

Code that does dynamic casting already needs to prepare for failure, much like the else branch of an `if #available` check.

@lorentey
Copy link
Member

Hm, that is probably overly optimistic. I think we'd only want dynamic casts to consider these conformances if the running code was compiled with an stdlib module that included them – but I think we'd definitely want them in that case. (These new conformances may cause regressions in existing binaries, I guess esp. for any code that included its own conformance for these.)

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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.
Projects
None yet
Development

No branches or pull requests

2 participants