Swift should allow multiple SWIFT_CONFORMS_TO_PROTOCOL
attributes on a C++ class
#75831
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
c++ interop
Feature: Interoperability with C++
compiler
The Swift compiler itself
good first issue
Good for newcomers
Description
swift/bridging
header defines aSWIFT_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 multipleSWIFT_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
This method would likely need to change as part of the resolution of this issue.
The text was updated successfully, but these errors were encountered: