diff --git a/include/swift/Basic/Features.def b/include/swift/Basic/Features.def index b78a22b08f696..3797a9a40462d 100644 --- a/include/swift/Basic/Features.def +++ b/include/swift/Basic/Features.def @@ -498,10 +498,6 @@ EXPERIMENTAL_FEATURE(AssumeResilientCxxTypes, true) /// Import inherited non-public members when importing C++ classes. EXPERIMENTAL_FEATURE(ImportNonPublicCxxMembers, true) -/// Suppress the synthesis of static factory methods for C++ foreign reference -/// types and importing them as Swift initializers. -EXPERIMENTAL_FEATURE(SuppressCXXForeignReferenceTypeInitializers, true) - /// Emit a warning when a C++ API returns a SWIFT_SHARED_REFERENCE type /// without being explicitly annotated with either SWIFT_RETURNS_RETAINED /// or SWIFT_RETURNS_UNRETAINED. diff --git a/lib/AST/FeatureSet.cpp b/lib/AST/FeatureSet.cpp index 125eabcc6cbf4..590a15eabfddd 100644 --- a/lib/AST/FeatureSet.cpp +++ b/lib/AST/FeatureSet.cpp @@ -332,7 +332,6 @@ UNINTERESTING_FEATURE(LibraryEvolution) UNINTERESTING_FEATURE(SafeInteropWrappers) UNINTERESTING_FEATURE(AssumeResilientCxxTypes) UNINTERESTING_FEATURE(ImportNonPublicCxxMembers) -UNINTERESTING_FEATURE(SuppressCXXForeignReferenceTypeInitializers) UNINTERESTING_FEATURE(WarnUnannotatedReturnOfCxxFrt) UNINTERESTING_FEATURE(CoroutineAccessorsUnwindOnCallerError) UNINTERESTING_FEATURE(AllowRuntimeSymbolDeclarations) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 57fb5dc786a39..f099468d6d8f2 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -2597,34 +2597,30 @@ namespace { result->addMember(ctor); } } else { - if (!Impl.SwiftContext.LangOpts.hasFeature( - Feature::SuppressCXXForeignReferenceTypeInitializers)) { - assert( - isa(result) && - "Expected result to be a ClassDecl as it cannot be a StructDecl"); - // When we add full support for C foreign reference types then we - // should synthesize static factories for them as well - if (auto *cxxRecordDecl = dyn_cast(decl)) { - bool hasUserProvidedStaticFactory = llvm::any_of( - cxxRecordDecl->methods(), - [](const clang::CXXMethodDecl *method) { - return method->isStatic() && - llvm::any_of( - method->specific_attrs(), - [](const auto *attr) { - return attr->getName().starts_with("init("); - }); - }); - if (!hasUserProvidedStaticFactory) { - auto generatedCxxMethodDecls = - synthesizer.synthesizeStaticFactoryForCXXForeignRef( - cxxRecordDecl); - for (auto *methodDecl : generatedCxxMethodDecls) { - if (Decl *importedInitDecl = - Impl.SwiftContext.getClangModuleLoader() - ->importDeclDirectly(methodDecl)) - result->addMember(importedInitDecl); - } + assert( + isa(result) && + "Expected result to be a ClassDecl as it cannot be a StructDecl"); + // When we add full support for C foreign reference types then we + // should synthesize static factories for them as well + if (auto *cxxRecordDecl = dyn_cast(decl)) { + bool hasUserProvidedStaticFactory = llvm::any_of( + cxxRecordDecl->methods(), [](const clang::CXXMethodDecl *method) { + return method->isStatic() && + llvm::any_of( + method->specific_attrs(), + [](const auto *attr) { + return attr->getName().starts_with("init("); + }); + }); + if (!hasUserProvidedStaticFactory) { + auto generatedCxxMethodDecls = + synthesizer.synthesizeStaticFactoryForCXXForeignRef( + cxxRecordDecl); + for (auto *methodDecl : generatedCxxMethodDecls) { + if (Decl *importedInitDecl = + Impl.SwiftContext.getClangModuleLoader() + ->importDeclDirectly(methodDecl)) + result->addMember(importedInitDecl); } } }