Skip to content

[cxx-interop] Test static factory backed initializers with value types #79909

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 1 commit into from
Mar 11, 2025

Conversation

Xazax-hun
Copy link
Contributor

We can use swift_name to import a static factory function as a Swift initializer. This was tested with foreign reference types but not with value types. This PR adds a test case for the latter.

rdar://117531428

@Xazax-hun Xazax-hun added the c++ interop Feature: Interoperability with C++ label Mar 11, 2025
Copy link
Contributor

@j-hui j-hui left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for noticing this!

@Xazax-hun Xazax-hun enabled auto-merge March 11, 2025 15:13
Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

The test case looks good! Should we move it out of the foreign-reference test directory?

@Xazax-hun
Copy link
Contributor Author

Should we move it out of the foreign-reference test directory?

Hmm, maybe? I did not find a good place for this. Interop\Cxx\class is already pretty crowded. Maybe Interop\Cxx\ergonomics?

@egorzhdan
Copy link
Contributor

I think Interop/Cxx/class would be the best place for this, since that's where we test all kinds of constructors, e.g. copy constructors.

@Xazax-hun Xazax-hun disabled auto-merge March 11, 2025 16:16
@Xazax-hun Xazax-hun force-pushed the gaborh/ctor-value-type branch from a66680a to 88925b3 Compare March 11, 2025 17:35
@Xazax-hun
Copy link
Contributor Author

I think Interop/Cxx/class would be the best place for this

Done.

We can use swift_name to import a static factory function as a Swift
initializer. This was tested with foreign reference types but not with
value types. This PR adds a test case for the latter.

rdar://117531428
@Xazax-hun Xazax-hun force-pushed the gaborh/ctor-value-type branch from 88925b3 to 14d92ff Compare March 11, 2025 17:37
@Xazax-hun
Copy link
Contributor Author

@swift-ci please smoke test

@Xazax-hun Xazax-hun enabled auto-merge March 11, 2025 21:31
@Xazax-hun Xazax-hun merged commit 2386508 into main Mar 11, 2025
3 checks passed
@Xazax-hun Xazax-hun deleted the gaborh/ctor-value-type branch March 11, 2025 23:12
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.

3 participants