Skip to content

[cxx-interop] Correctly check iterator conformances #61540

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

Merged
merged 1 commit into from
Oct 14, 2022

Conversation

egorzhdan
Copy link
Contributor

To determine whether to conform a C++ type to CxxSequence protocol automatically, ClangImporter checks if the corresponding iterator type conforms to UnsafeCxxInputIterator.

This logic had false-positives, e.g. Optional<OpaquePointer> was treated as if it conforms to UnsafeCxxInputIterator while it actually doesn't. This happened because lookupConformance returned a conformance with a conditional requirement (Wrapped : UnsafeCxxInputIterator) that is not satisfied for OpaquePointer.

rdar://100265664

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Oct 11, 2022
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan requested review from hyp and zoecarver October 11, 2022 11:24
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test Linux

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

2 similar comments
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-iterator-opaque-ptr branch from 3366b47 to b8fd75d Compare October 13, 2022 11:57
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

To determine whether to conform a C++ type to `CxxSequence` protocol automatically, ClangImporter checks if the corresponding iterator type conforms to `UnsafeCxxInputIterator`.

This logic had false-positives, e.g. `Optional<OpaquePointer>` was treated as if it conforms to `UnsafeCxxInputIterator` while it actually doesn't. This happened because `lookupConformance` returned a conformance with a conditional requirement (`Wrapped : UnsafeCxxInputIterator`) that is not satisfied for `OpaquePointer`.

rdar://100265664
@egorzhdan egorzhdan force-pushed the egorzhdan/cxx-iterator-opaque-ptr branch from b8fd75d to c53b814 Compare October 13, 2022 17:14
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test Windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant