-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Import non-public inherited members #79348
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
Conversation
This patch is follow-up work from swiftlang#78942 and concurrent with swiftlang#79093. It imports non-public members, which were previously not being imported. Once swiftlang#79093 (SWIFT_PRIVATE_FILEID) is merged in, these inherited members will be available within certain Swift extensions.
@swift-ci Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any tests where a field with the same name appears in multiple bases? We can disambiguate accessing those in C++ by using qualified lookup but it is not possible in Swift where in case of struct
s we put everything in the same type. So I think we might want to skip fields (and methods?) that can cause ambiguities.
(This is different from the case where the members in the derived class shadows the members in the base.)
Ambiguous lookups need follow-up work. Last time I tried it out, it gave me a very unhelpful error message, because the way the diagnostics are implemented don't seem to consider that kind of ambiguity. That said, I still think we should import those ambiguous members, because it lets us report the same error from Swift as in C++ (even if that isn't quite implemented right now). This is the same reason why I am importing inaccessible private base members; without doing so, we get "missing field" errors that don't actually point to the underlying problem. To work around an ambiguous member lookup, users can add a shim method in C++ where they perform the fully qualified lookup there. |
I will add a test case that has ambiguous members and make sure it does not affect unambiguous member lookup. |
@Xazax-hun I added a test case that checks ambiguous lookups, and it misbehaves somewhat (specifically, lookups that should be ambiguous do not seem to be). There is also a pretty big discrepancy in how To avoid blowing up the size of this PR, I would like to revisit this issue in follow-up work. rdar://144843878 |
@swift-ci Please test |
@swift-ci Please test |
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@swift-ci Please test |
@swift-ci please test |
@swift-ci please smoke test windows platform |
@swift-ci please test |
@swift-ci Please test |
This patch is follow-up work from #78942 and concurrent with #79093.
It imports non-public members, which were previously not being imported.
The access level of each inherited base member is computed according to
the inheritance rules in C++, and accounts for public/protected/private
inheritance. Base members that are inaccessible from the derived class
(either because they are private, or due to nested private inheritance)
are also imported into Swift but marked as unavailable, to ensure that
(1) trying to access these members produces a reasonable error message
rather than claiming that the inaccessible member doesn't exist, and
(2) ambiguous member lookups aren't erroneously disambiguated by virtue
of one being public and the other private.
Once #79093 (
SWIFT_PRIVATE_FILEID
) is merged in, these inherited memberswill be available within Swift extensions that have been blessed by the
SWIFT_PRIVATE_FILEID
annotation.rdar://137764620