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] Finalize Swift 5.9 rules that determine when inherited members that shadow other members can be introduced to the Swift type that represents the C++ structure or class #66323

Closed
Tracked by #65808
hyp opened this issue Jun 4, 2023 · 0 comments · Fixed by #67178
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ c++ to swift Feature → c++ interop: c++ to swift compiler The Swift compiler itself swift 5.9

Comments

@hyp
Copy link
Contributor

hyp commented Jun 4, 2023

The exact rules that determine when members from inherited base types are introduced to Swift’s representation of the C++ type are not yet finalized in Swift 5.9. This issue tracks their finalization.

The current rules need to be updated to handle shadowing better. For example, given the following C++ code:

class Plant {
public:
  void water(float amount) { moisture += amount; }
private:
  float moisture = 0.0;
};

class Fern: public Plant {
public:
  void trim();
  void water(float amount);
};

A user in Swift won't be unable to call the water method on a Fern object, as Swift will think it's an ambiguous call.

@hyp hyp added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ triage needed This issue needs more specific labels swift 5.9 labels Jun 4, 2023
@hyp hyp self-assigned this Jun 4, 2023
hyp added a commit to hyp/swift that referenced this issue Jul 7, 2023
…ties with a derived class member of the same name

Fixes swiftlang#66323
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself c++ to swift Feature → c++ interop: c++ to swift and removed triage needed This issue needs more specific labels labels Jul 10, 2023
hyp added a commit to hyp/swift that referenced this issue Jul 11, 2023
…ties with a derived class member of the same name

Fixes swiftlang#66323

(cherry picked from commit 11d7d58)
hyp added a commit to hyp/swift that referenced this issue Jul 12, 2023
…ties with a derived class member of the same name

Fixes swiftlang#66323
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ c++ to swift Feature → c++ interop: c++ to swift compiler The Swift compiler itself swift 5.9
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants