mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[interop] adopt a swift-6 interoperability mode for new features in the next release
This commit is contained in:
@@ -2190,8 +2190,7 @@ namespace {
|
||||
Impl.ImportedDecls[{decl->getCanonicalDecl(), getVersion()}] = result;
|
||||
|
||||
if (recordHasMoveOnlySemantics(decl)) {
|
||||
if (Impl.isCxxInteropCompatVersionAtLeast(
|
||||
version::getUpcomingCxxInteropCompatVersion())) {
|
||||
if (Impl.isCxxInteropCompatVersionAtLeast(6)) {
|
||||
if (decl->isInStdNamespace() && decl->getName() == "promise") {
|
||||
// Do not import std::promise.
|
||||
return nullptr;
|
||||
@@ -2658,8 +2657,7 @@ namespace {
|
||||
if (!decl->isBeingDefined() && !decl->isDependentContext() &&
|
||||
areRecordFieldsComplete(decl)) {
|
||||
if (decl->hasInheritedConstructor() &&
|
||||
Impl.isCxxInteropCompatVersionAtLeast(
|
||||
version::getUpcomingCxxInteropCompatVersion())) {
|
||||
Impl.isCxxInteropCompatVersionAtLeast(6)) {
|
||||
for (auto member : decl->decls()) {
|
||||
if (auto usingDecl = dyn_cast<clang::UsingDecl>(member)) {
|
||||
for (auto usingShadowDecl : usingDecl->shadows()) {
|
||||
@@ -2830,8 +2828,7 @@ namespace {
|
||||
void
|
||||
addExplicitProtocolConformances(NominalTypeDecl *decl,
|
||||
const clang::CXXRecordDecl *clangDecl) {
|
||||
if (Impl.isCxxInteropCompatVersionAtLeast(
|
||||
version::getUpcomingCxxInteropCompatVersion())) {
|
||||
if (Impl.isCxxInteropCompatVersionAtLeast(6)) {
|
||||
// Propagate conforms_to attribute from public base classes.
|
||||
for (auto base : clangDecl->bases()) {
|
||||
if (base.getAccessSpecifier() != clang::AccessSpecifier::AS_public)
|
||||
@@ -3755,8 +3752,7 @@ namespace {
|
||||
}
|
||||
|
||||
if (decl->isVirtual() && isa_and_nonnull<ValueDecl>(method)) {
|
||||
if (Impl.isCxxInteropCompatVersionAtLeast(
|
||||
version::getUpcomingCxxInteropCompatVersion())) {
|
||||
if (Impl.isCxxInteropCompatVersionAtLeast(6)) {
|
||||
if (auto dc = method->getDeclContext();
|
||||
!decl->isPure() &&
|
||||
isa_and_nonnull<NominalTypeDecl>(dc->getAsDecl())) {
|
||||
@@ -4044,8 +4040,7 @@ namespace {
|
||||
// 2. C++ methods from privately inherited base classes
|
||||
if (!isa<clang::TypeDecl>(decl->getTargetDecl()) &&
|
||||
!(isa<clang::CXXMethodDecl>(decl->getTargetDecl()) &&
|
||||
Impl.isCxxInteropCompatVersionAtLeast(
|
||||
version::getUpcomingCxxInteropCompatVersion())))
|
||||
Impl.isCxxInteropCompatVersionAtLeast(6)))
|
||||
return nullptr;
|
||||
// Constructors (e.g. `using BaseClass::BaseClass`) are handled in
|
||||
// VisitCXXRecordDecl, since we need them to determine whether a struct
|
||||
|
||||
@@ -2587,8 +2587,7 @@ static ParamDecl *getParameterInfo(ClangImporter::Implementation *impl,
|
||||
// (https://github.com/apple/swift/issues/70124)
|
||||
if (param->hasDefaultArg() && !isInOut &&
|
||||
!isa<clang::CXXConstructorDecl>(param->getDeclContext()) &&
|
||||
impl->isCxxInteropCompatVersionAtLeast(
|
||||
version::getUpcomingCxxInteropCompatVersion()) &&
|
||||
impl->isCxxInteropCompatVersionAtLeast(6) &&
|
||||
impl->isDefaultArgSafeToImport(param)) {
|
||||
SwiftDeclSynthesizer synthesizer(*impl);
|
||||
if (CallExpr *defaultArgExpr = synthesizer.makeDefaultArgument(
|
||||
|
||||
@@ -499,6 +499,8 @@ validateCxxInteropCompatibilityMode(StringRef mode) {
|
||||
if (mode == "upcoming-swift")
|
||||
return {CxxCompatMode::enabled,
|
||||
version::Version({version::getUpcomingCxxInteropCompatVersion()})};
|
||||
if (mode == "swift-6")
|
||||
return {CxxCompatMode::enabled, version::Version({6})};
|
||||
// Swift-5.9 corresponds to the Swift 5 language mode when
|
||||
// Swift 5 is the default language version.
|
||||
if (mode == "swift-5.9")
|
||||
@@ -513,7 +515,8 @@ static void diagnoseCxxInteropCompatMode(Arg *verArg, ArgList &Args,
|
||||
verArg->getAsString(Args), verArg->getValue());
|
||||
|
||||
// Note valid C++ interoperability modes.
|
||||
auto validVers = {llvm::StringRef("off"), llvm::StringRef("default")};
|
||||
auto validVers = {llvm::StringRef("off"), llvm::StringRef("default"),
|
||||
llvm::StringRef("swift-6"), llvm::StringRef("swift-5.9")};
|
||||
auto versStr = "'" + llvm::join(validVers, "', '") + "'";
|
||||
diags.diagnose(SourceLoc(), diag::valid_cxx_interop_modes, versStr);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// RUN: %target-swift-emit-ir -I %S/Inputs -cxx-interoperability-mode=upcoming-swift %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
|
||||
// RUN: %target-swift-emit-ir -I %S/Inputs -cxx-interoperability-mode=swift-6 %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
|
||||
|
||||
import VirtualMethods
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=upcoming-swift
|
||||
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=swift-6
|
||||
|
||||
import VirtualMethods
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift)
|
||||
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O)
|
||||
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6 -O)
|
||||
|
||||
// XFAIL: noncopyable_generics
|
||||
|
||||
|
||||
Reference in New Issue
Block a user