Skip to content

[cxx-interop] Fix a rare compilation error in reverse interop header#80598

Merged
Xazax-hun merged 1 commit into
mainfrom
gaborh/nested-foreign-type-metadata
Apr 7, 2025
Merged

[cxx-interop] Fix a rare compilation error in reverse interop header#80598
Xazax-hun merged 1 commit into
mainfrom
gaborh/nested-foreign-type-metadata

Conversation

@Xazax-hun

Copy link
Copy Markdown
Contributor

To trigger this error one needs to import a nested type from C++, use it in a generic context in Swift, and export it back to C++. We were inconsisent in what namespace did we declare the functions to get the type metadata for types. It was in the swift namespace for foreign types and in the module namespace for Swift types. This PR standardizes on how the metadata function is declared and called to fix the issue.

Fixes #80538.

rdar://148597079

Comment thread lib/ClangImporter/ClangImporter.cpp Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor: redundant llvm::

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this UN: supposed to be RUN:?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Whoops, this is a line I wanted to remove. Thanks for catching this!

To trigger this error one needs to import a nested type from C++, use it
in a generic context in Swift, and export it back to C++. We were
inconsisent in what namespace did we declare the functions to get the
type metadata for types. It was in the swift namespace for foreign types
and in the module namespace for Swift types. This PR standardizes on how
the metadata function is declared and called to fix the issue.

Fixes #80538.

rdar://148597079
@Xazax-hun
Xazax-hun force-pushed the gaborh/nested-foreign-type-metadata branch from 36aaa67 to b3b2031 Compare April 7, 2025 16:50
@Xazax-hun

Copy link
Copy Markdown
Contributor Author

@swift-ci please smoke test

@Xazax-hun
Xazax-hun enabled auto-merge April 7, 2025 18:00
@Xazax-hun
Xazax-hun merged commit fe98abb into main Apr 7, 2025
@Xazax-hun
Xazax-hun deleted the gaborh/nested-foreign-type-metadata branch April 7, 2025 23:02
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.

[cxx-interop] Reference to type metadata pointer for imported c++ class can be improperly referenced in C++ import header

3 participants