-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Description
swift/bridging
header defines a SWIFT_CONFORMS_TO_PROTOCOL
macro, which expands to __attribute__((swift_attr("conforms_to:MyModule.MyProtocol")))
.
This attribute lets the Swift compiler know that the annotated C++ class should be automatically marked as conforming to a Swift protocol with the given name.
Currently the Swift compiler only respects one SWIFT_CONFORMS_TO_PROTOCOL
attribute on a single C++ class at a time. This is a limitation, we should support multiple SWIFT_CONFORMS_TO_PROTOCOL
attributes on a single class.
Reproduction
Expected behavior
If two or more SWIFT_CONFORMS_TO_PROTOCOL
attributes are provided, Swift should conform the C++ type to all of the listed Swift protocols.
Environment
Recent Swift compiler from main
Additional information
This is the part of ClangImporter that handles explicit conformances:
swift/lib/ClangImporter/ImportDecl.cpp
Lines 2840 to 2842 in 375363a
void | |
addExplicitProtocolConformances(NominalTypeDecl *decl, | |
const clang::CXXRecordDecl *clangDecl) { |
This method would likely need to change as part of the resolution of this issue.