Skip to content

[cxx-interop] Do not add base class members that cause lookup ambigui… #67178

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
Jul 10, 2023

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Jul 7, 2023

…ties with a derived class member of the same name

Fixes #66323

…ties with a derived class member of the same name

Fixes swiftlang#66323
@hyp hyp added the c++ interop Feature: Interoperability with C++ label Jul 7, 2023
@hyp hyp requested review from zoecarver and egorzhdan as code owners July 7, 2023 17:39
@hyp
Copy link
Contributor Author

hyp commented Jul 7, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Jul 7, 2023

@swift-ci please test source compatibility

@hyp
Copy link
Contributor Author

hyp commented Jul 8, 2023

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Jul 9, 2023

@swift-ci please test macOS platform

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.

Would we still be able to import void foo in this scenario?

// C++
struct A {};
struct B : A {
  void foo(int x);
};
// Swift
extension A {
  func foo(s: String) {}
}

@hyp
Copy link
Contributor Author

hyp commented Jul 10, 2023

Would we still be able to import void foo in this scenario?

// C++
struct A {};
struct B : A {
  void foo(int x);
};
// Swift
extension A {
 func foo(s: String) {}
}

Good question, I will check.

@hyp
Copy link
Contributor Author

hyp commented Jul 10, 2023

Would we still be able to import void foo in this scenario?

// C++
struct A {};
struct B : A {
  void foo(int x);
};
// Swift
extension A {
 func foo(s: String) {}
}

Good question, I will check.

Yes, this appears to work. The reason is that methods in Swift extensions on base classes can't be duplicated over as we're only considering original C++ methods for duplication. And of course the inheritance hierarchy is not present in Swift, so B.foo where foo is foo(s: String) wouldn't have worked anyway.

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
2 participants