Skip to content

[cxx-interop] Add ability to specify protocol conformance on C++ side. #62330

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 3 commits into from
Dec 14, 2022

Conversation

zoecarver
Copy link
Contributor

No description provided.

@zoecarver zoecarver added the c++ interop Feature: Interoperability with C++ label Dec 1, 2022
@zoecarver
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

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

Really awesome, thank you @zoecarver :)

@hyp
Copy link
Contributor

hyp commented Dec 1, 2022

We should error out if the protocol lookup fails to catch typos .

@hyp
Copy link
Contributor

hyp commented Dec 1, 2022

we should also error out on ambiguous lookups, no?

@zoecarver
Copy link
Contributor Author

@swift-ci please test

protocols.insert(proto);
}
auto addSynthesized = [&](ProtocolDecl *proto) {
llvm::dbgs() << "S\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug output, pls rm -rf.

@zoecarver
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@zoecarver
Copy link
Contributor Author

@swift-ci please test

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.

This is a great improvement but I'm a bit worried that importing a C++ module can now trigger loading of an unrelated Swift module, which might run into cyclic dependencies.

Could you please add a test that has something like this:

  1. a C++ module A that contains a decl with conforms_to:X attr
  2. a Swift module B that imports A
  3. a Swift module C that imports B and contains protocol X

@zoecarver
Copy link
Contributor Author

@swift-ci please test

@zoecarver
Copy link
Contributor Author

zoecarver commented Dec 6, 2022

This is a great improvement but I'm a bit worried that importing a C++ module can now trigger loading of an unrelated Swift module, which might run into cyclic dependencies.

Could you please add a test that has something like this:

  1. a C++ module A that contains a decl with conforms_to:X attr
  2. a Swift module B that imports A
  3. a Swift module C that imports B and contains protocol X

Yeah this is a good point. Regardless, it is not ideal that we have to load all the modules and potentially have ambiguities. What if we just required people to specify the module in the attribute string?

@ktoso
Copy link
Contributor

ktoso commented Dec 7, 2022

What if we just required people to specify the module in the attribute string?

I'd be more than happy with that; requiring to be precise here sounds good tbh.

@zoecarver zoecarver merged commit 9850906 into swiftlang:main Dec 14, 2022
@zoecarver
Copy link
Contributor Author

I will address the review comments post-commit. I think we should require the user to specify both the module and the protocol.

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.

4 participants