Skip to content

[cxx-interop] Implicitly import Cxx module #60603

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 2 commits into from
Oct 20, 2022
Merged

Conversation

egorzhdan
Copy link
Contributor

This lifts the requirement for the user to explicitly add import Cxx in Swift code that relies on protocols from the Cxx module, such as CxxSequence.

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

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 8e96abd to 2b4a7ff Compare August 18, 2022 16:07
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@stevapple
Copy link
Contributor

Should we rename it to _Cxx to align with other implicitly imported "standard" libraries?

@egorzhdan
Copy link
Contributor Author

@stevapple underscored names are generally used for something the developer wouldn't need to reference directly from Swift code. This module could be referenced directly, for example, if someone needs to provide a utility extension to one of the protocols from Cxx module:

// Util.swift
import Cxx

extension CxxSequence where RawIterator: ... {
  func doSomething() { ... }
}

Note that we don't always implicitly import Cxx, we only do that for C++ modules that are being imported into Swift, so without import Cxx the above snippet wouldn't compile.

@stevapple
Copy link
Contributor

Ah, makes sense👌

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 75858ca to 6e61fc3 Compare August 24, 2022 18:32
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan requested a review from zoecarver August 24, 2022 18:33
@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 6e61fc3 to 9e84c84 Compare August 25, 2022 12:23
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 9e84c84 to 106b7b9 Compare August 25, 2022 13:57
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 106b7b9 to 5322433 Compare August 25, 2022 16:18
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@zoecarver zoecarver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing all these tests!

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 5322433 to 4f5552b Compare August 31, 2022 13:07
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

1 similar comment
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 4f5552b to 4562328 Compare October 17, 2022 13:05
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 4562328 to ca38af8 Compare October 17, 2022 16:01
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@ktoso
Copy link
Contributor

ktoso commented Oct 18, 2022

Hooray, makes a lot of sense +1

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from ca38af8 to 1918d1d Compare October 18, 2022 11:08
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from 1918d1d to d0d3c03 Compare October 19, 2022 10:03
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from d0d3c03 to cc0a8b1 Compare October 19, 2022 13:03
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

This lifts the requirement for the user to explicitly add `import Cxx` in Swift code that relies on protocols from the `Cxx` module, such as `CxxSequence`.
`Swift` is the name of the Swift standard library module. Creating another module with this name breaks assumptions in the compiler and caused these two tests to fail.
@egorzhdan egorzhdan force-pushed the egorzhdan/implicit-cxx branch from cc0a8b1 to 5a3bb14 Compare October 19, 2022 14:01
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test macOS

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.

4 participants