@@ -2192,22 +2192,12 @@ namespace {
21922192 Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}] = result;
21932193
21942194 if (recordHasMoveOnlySemantics (decl)) {
2195- if (Impl.isCxxInteropCompatVersionAtLeast (6 )) {
2196- if (decl->isInStdNamespace () && decl->getName () == " promise" ) {
2197- // Do not import std::promise.
2198- return nullptr ;
2199- }
2200- result->getAttrs ().add (new (Impl.SwiftContext )
2201- MoveOnlyAttr (/* Implicit=*/ true ));
2202- } else {
2203- Impl.addImportDiagnostic (
2204- decl,
2205- Diagnostic (
2206- diag::move_only_requires_move_only,
2207- Impl.SwiftContext .AllocateCopy (decl->getNameAsString ())),
2208- decl->getLocation ());
2195+ if (decl->isInStdNamespace () && decl->getName () == " promise" ) {
2196+ // Do not import std::promise.
22092197 return nullptr ;
22102198 }
2199+ result->getAttrs ().add (new (Impl.SwiftContext )
2200+ MoveOnlyAttr (/* Implicit=*/ true ));
22112201 }
22122202
22132203 // FIXME: Figure out what to do with superclasses in C++. One possible
@@ -2666,8 +2656,7 @@ namespace {
26662656 // SemaLookup.cpp).
26672657 if (!decl->isBeingDefined () && !decl->isDependentContext () &&
26682658 areRecordFieldsComplete (decl)) {
2669- if (decl->hasInheritedConstructor () &&
2670- Impl.isCxxInteropCompatVersionAtLeast (6 )) {
2659+ if (decl->hasInheritedConstructor ()) {
26712660 for (auto member : decl->decls ()) {
26722661 if (auto usingDecl = dyn_cast<clang::UsingDecl>(member)) {
26732662 for (auto usingShadowDecl : usingDecl->shadows ()) {
@@ -2838,14 +2827,12 @@ namespace {
28382827 void
28392828 addExplicitProtocolConformances (NominalTypeDecl *decl,
28402829 const clang::CXXRecordDecl *clangDecl) {
2841- if (Impl.isCxxInteropCompatVersionAtLeast (6 )) {
2842- // Propagate conforms_to attribute from public base classes.
2843- for (auto base : clangDecl->bases ()) {
2844- if (base.getAccessSpecifier () != clang::AccessSpecifier::AS_public)
2845- continue ;
2846- if (auto *baseClangDecl = base.getType ()->getAsCXXRecordDecl ())
2847- addExplicitProtocolConformances (decl, baseClangDecl);
2848- }
2830+ // Propagate conforms_to attribute from public base classes.
2831+ for (auto base : clangDecl->bases ()) {
2832+ if (base.getAccessSpecifier () != clang::AccessSpecifier::AS_public)
2833+ continue ;
2834+ if (auto *baseClangDecl = base.getType ()->getAsCXXRecordDecl ())
2835+ addExplicitProtocolConformances (decl, baseClangDecl);
28492836 }
28502837
28512838 if (!clangDecl->hasAttrs ())
@@ -3763,39 +3750,34 @@ namespace {
37633750
37643751 if (decl->isVirtual ()) {
37653752 if (auto funcDecl = dyn_cast_or_null<FuncDecl>(method)) {
3766- if (Impl.isCxxInteropCompatVersionAtLeast (6 )) {
3767- if (auto structDecl =
3768- dyn_cast_or_null<StructDecl>(method->getDeclContext ())) {
3769- // If this is a method of a Swift struct, any possible override of
3770- // this method would get sliced away, and an invocation would get
3771- // dispatched statically. This is fine because it matches the C++
3772- // behavior.
3773- if (decl->isPure ()) {
3774- // If this is a pure virtual method, we won't have any
3775- // implementation of it to invoke.
3776- Impl.markUnavailable (
3777- funcDecl, " virtual function is not available in Swift "
3778- " because it is pure" );
3779- }
3780- } else if (auto classDecl = dyn_cast_or_null<ClassDecl>(
3781- funcDecl->getDeclContext ())) {
3782- // This is a foreign reference type. Since `class T` on the Swift
3783- // side is mapped from `T*` on the C++ side, an invocation of a
3784- // virtual method `t->method()` should get dispatched dynamically.
3785- // Create a thunk that will perform dynamic dispatch.
3786- // TODO: we don't have to import the actual `method` in this case,
3787- // we can just synthesize a thunk and import that instead.
3788- auto result = synthesizer.makeVirtualMethod (decl);
3789- if (result) {
3790- return result;
3791- } else {
3792- Impl.markUnavailable (
3793- funcDecl, " virtual function is not available in Swift" );
3794- }
3753+ if (auto structDecl =
3754+ dyn_cast_or_null<StructDecl>(method->getDeclContext ())) {
3755+ // If this is a method of a Swift struct, any possible override of
3756+ // this method would get sliced away, and an invocation would get
3757+ // dispatched statically. This is fine because it matches the C++
3758+ // behavior.
3759+ if (decl->isPure ()) {
3760+ // If this is a pure virtual method, we won't have any
3761+ // implementation of it to invoke.
3762+ Impl.markUnavailable (funcDecl,
3763+ " virtual function is not available in Swift "
3764+ " because it is pure" );
3765+ }
3766+ } else if (auto classDecl = dyn_cast_or_null<ClassDecl>(
3767+ funcDecl->getDeclContext ())) {
3768+ // This is a foreign reference type. Since `class T` on the Swift
3769+ // side is mapped from `T*` on the C++ side, an invocation of a
3770+ // virtual method `t->method()` should get dispatched dynamically.
3771+ // Create a thunk that will perform dynamic dispatch.
3772+ // TODO: we don't have to import the actual `method` in this case,
3773+ // we can just synthesize a thunk and import that instead.
3774+ auto result = synthesizer.makeVirtualMethod (decl);
3775+ if (result) {
3776+ return result;
3777+ } else {
3778+ Impl.markUnavailable (
3779+ funcDecl, " virtual function is not available in Swift" );
37953780 }
3796- } else {
3797- Impl.markUnavailable (
3798- funcDecl, " virtual functions are not yet available in Swift" );
37993781 }
38003782 }
38013783 }
@@ -4053,8 +4035,7 @@ namespace {
40534035 // 1. Types
40544036 // 2. C++ methods from privately inherited base classes
40554037 if (!isa<clang::TypeDecl>(decl->getTargetDecl ()) &&
4056- !(isa<clang::CXXMethodDecl>(decl->getTargetDecl ()) &&
4057- Impl.isCxxInteropCompatVersionAtLeast (6 )))
4038+ !isa<clang::CXXMethodDecl>(decl->getTargetDecl ()))
40584039 return nullptr ;
40594040 // Constructors (e.g. `using BaseClass::BaseClass`) are handled in
40604041 // VisitCXXRecordDecl, since we need them to determine whether a struct
0 commit comments