-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Instantiate C++ class templates from Swift #33284
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
Conversation
This PR depends on #32950. |
@swift-ci please test |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
1 similar comment
@swift-ci please test |
Build failed |
@swift-ci please test |
1 similar comment
@swift-ci please test |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
@swift-ci please test. |
Build failed |
Build failed |
@swift-ci please test. |
Build failed |
Build failed |
@swift-ci please test. |
Build failed |
(Failure on mac came from lldb, not related to this PR) |
@swift-ci please test. |
Build failed |
test/Interop/Cxx/templates/Inputs/class-template-nested-type-for-swift-module.h
Outdated
Show resolved
Hide resolved
test/Interop/Cxx/templates/Inputs/class-template-in-namespace-for-swift-module.h
Outdated
Show resolved
Hide resolved
test/Interop/Cxx/templates/class-template-in-namespace-module-interface.swift
Outdated
Show resolved
Hide resolved
test/Interop/Cxx/templates/class-template-instantiation-existing-specialization.swift
Outdated
Show resolved
Hide resolved
Co-authored-by: Dmitri Gribenko <[email protected]>
…ng-specialization.swift Co-authored-by: Dmitri Gribenko <[email protected]>
@swift-ci please test. |
Build failed |
@swift-ci please test macos platform. |
@swift-ci please test. |
This PR makes it possible to instantiate C++ class templates from Swift. Given a C++ header:
it is now possible to write in Swift:
This is achieved by importing C++ class templates as generic structs, and then when Swift type checker calls
applyGenericArguments
we detect when the generic struct is backed by the C++ class template and call Clang to instantiate the template. In order to make it possible to put class instantiations such asMagicWrapper<MagicNumber>
into Swift signatures, we have created a new field inStructDecl
namedTemplateInstantiationType
where the typechecker stores theBoundGenericType
which we serialize. Deserializer then notices that theBoundGenericType
is actually a C++ class template and performs the instantiation logic.Depends on #33420.
Progress towards https://bugs.swift.org/browse/SR-13261.
Fixes https://bugs.swift.org/browse/SR-13775.