Skip to content
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

[cxx-interop] Support using Swift Extensions from C++ #75295

Open
mrousavy opened this issue Jul 17, 2024 · 0 comments
Open

[cxx-interop] Support using Swift Extensions from C++ #75295

mrousavy opened this issue Jul 17, 2024 · 0 comments
Labels
c++ interop Feature: Interoperability with C++ feature A feature request or implementation swift to c++ Feature → c++ interop: swift to c++

Comments

@mrousavy
Copy link

Motivation

I am building Swift classes that are exposed to C++.

Many of those Swift classes have functions that can throw errors, and since error throwing is not yet supported in C++ <> Swift interop (see #75290), I need to use some workaround.

I have this Swift class:

public class MySwiftClass {
  func doSomething() throws -> Int {
    throw SomeError.failure
  }
}

Now since I cannot call doSomething() from C++ (because it throws), I wanted to create an extension to wrap it in a Result:

public extension MySwiftClass {
  func doSomethingResult() -> Result<Int, SomeError>
}

..but unfortunately doSomethingResult() is also not available in C++, because it is an extension.

Proposed solution

It would be great if the generated C++ binding class would also pull in any extensions declared in Swift.

Alternatives considered

No response

Additional information

No response

@mrousavy mrousavy added feature A feature request or implementation triage needed This issue needs more specific labels labels Jul 17, 2024
@mrousavy mrousavy changed the title C++ Interop: Support using Swift Extensions from C++ [cxx-interop] Support using Swift Extensions from C++ Jul 18, 2024
@hborla hborla added c++ interop Feature: Interoperability with C++ swift to c++ Feature → c++ interop: swift to c++ and removed triage needed This issue needs more specific labels labels Jul 26, 2024
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++ feature A feature request or implementation swift to c++ Feature → c++ interop: swift to c++
Projects
None yet
Development

No branches or pull requests

2 participants