Skip to content

[cxx-interop] Test symbolic interface generation for new features #73248

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
Apr 26, 2024

Conversation

egorzhdan
Copy link
Contributor

This adds a test that ensures that a symbolic interface for a C++ module will include these features:

  • move-only types
  • virtual methods

Default arguments are already tested.

rdar://125816549

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Apr 25, 2024
@egorzhdan egorzhdan requested review from zoecarver and hyp as code owners April 25, 2024 13:55
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

This adds a test that ensures that a symbolic interface for a C++ module will include these features:
* move-only types
* virtual methods

Default arguments are already tested.

rdar://125816549
@egorzhdan egorzhdan force-pushed the egorzhdan/test-symbolic-new-features branch from 593a048 to 442f9c1 Compare April 25, 2024 15:33
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan requested a review from ravikandhadai April 25, 2024 18:14

struct NonCopyable {
NonCopyable(const NonCopyable& other) = delete;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test with a private copy constructor? they should be imported as non-copyable right?

Copy link
Contributor

Choose a reason for hiding this comment

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

And also a test with a non-default and explicitly defaulted move constructors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have a test for these kinds of C++ types, type-classification-module-interface.swift. Right now we don't import structs with private copy constructors, but you're right, we should be importing them as non-copyable in Swift. I'll put up a separate patch for that.

// CHECK: class MyImmortal {
// CHECK-NEXT: func foo()
// CHECK-NEXT: }
// CHECK-NEXT: struct NonCopyable {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this need a conformance to ~Copyable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

swift-ide-test -print-module doesn't explicitly print this conformance in the module interface

// CHECK-NEXT: }
// CHECK-NEXT: struct NonCopyable {
// CHECK-NEXT: @available(*, deprecated, message:
// CHECK-NEXT: init()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering why an availability printed for init() here but not for other methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the deprecation annotation that we add to the synthesized zero-initializers, when the C++ struct doesn't have a default constructor

@egorzhdan egorzhdan merged commit f3224ca into main Apr 26, 2024
@egorzhdan egorzhdan deleted the egorzhdan/test-symbolic-new-features branch April 26, 2024 11:58
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.

2 participants