-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[cxx-interop] Import using decls that expose methods from private base classes #69623
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
@swift-ci please smoke test |
c875b03
to
1e6954b
Compare
@swift-ci please smoke test |
@swift-ci please test |
@swift-ci please test source compatibility |
1e6954b
to
e583acf
Compare
@swift-ci please smoke test |
e583acf
to
63d4947
Compare
is this source breaking by any chance? |
63d4947
to
35325af
Compare
@swift-ci please smoke test |
Yes, it is, I should probably guard this by version, thanks! |
9ba60f3
to
ae8cf95
Compare
@swift-ci please smoke test |
ae8cf95
to
0d35e5b
Compare
@swift-ci please smoke test |
lib/ClangImporter/ImportDecl.cpp
Outdated
@@ -2697,6 +2697,30 @@ namespace { | |||
// SemaLookup.cpp). | |||
if (!decl->isBeingDefined() && !decl->isDependentContext() && | |||
areRecordFieldsComplete(decl)) { | |||
if (decl->hasInheritedConstructor() && | |||
Impl.isCxxInteropCompatVersionAtLeast(5, 11)) { |
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.
You should use isCxxInteropCompatVersionAtLeast(version::getUpcomingCxxInteropCompatVersion())
here instead. that will convert to a concrete one once we know the next version :)
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!
lib/ClangImporter/ImportDecl.cpp
Outdated
// 2. C++ methods from privately inherited base classes | ||
if (!isa<clang::TypeDecl>(decl->getTargetDecl()) && | ||
!(isa<clang::CXXMethodDecl>(decl->getTargetDecl()) && | ||
Impl.isCxxInteropCompatVersionAtLeast(5, 11))) |
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.
ditto here.
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.
Looks good with requested changes.
0d35e5b
to
b0fc16e
Compare
@swift-ci please smoke test |
b0fc16e
to
71aa696
Compare
@swift-ci please smoke test |
71aa696
to
25d9200
Compare
@swift-ci please smoke test |
…e classes If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`. MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized. rdar://114282353 / resolves #68068
25d9200
to
efc008a
Compare
@swift-ci please smoke test |
…e classes If a C++ type `Derived` inherits from `Base` privately, the public methods from `Base` should not be callable on an instance of `Derived`. However, C++ supports exposing such methods via a using declaration: `using MyPrivateBase::myPublicMethod;`. MSVC started using this feature for `std::optional` which means Swift doesn't correctly import `var pointee: Pointee` for instantiations of `std::optional` on Windows. This prevents the automatic conformance to `CxxOptional` from being synthesized. rdar://114282353 / resolves swiftlang#68068 Cherrypick commit efc008a Cherrypick PR swiftlang#69623
If a C++ type
Derived
inherits fromBase
privately, the public methods fromBase
should not be callable on an instance ofDerived
. However, C++ supports exposing such methods via a using declaration:using MyPrivateBase::myPublicMethod;
.MSVC started using this feature for
std::optional
which means Swift doesn't correctly importvar pointee: Pointee
for instantiations ofstd::optional
on Windows. This prevents the automatic conformance toCxxOptional
from being synthesized.rdar://114282353 / resolves #68068