@@ -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
@@ -2658,8 +2648,7 @@ namespace {
26582648 // SemaLookup.cpp).
26592649 if (!decl->isBeingDefined () && !decl->isDependentContext () &&
26602650 areRecordFieldsComplete (decl)) {
2661- if (decl->hasInheritedConstructor () &&
2662- Impl.isCxxInteropCompatVersionAtLeast (6 )) {
2651+ if (decl->hasInheritedConstructor ()) {
26632652 for (auto member : decl->decls ()) {
26642653 if (auto usingDecl = dyn_cast<clang::UsingDecl>(member)) {
26652654 for (auto usingShadowDecl : usingDecl->shadows ()) {
@@ -2830,14 +2819,12 @@ namespace {
28302819 void
28312820 addExplicitProtocolConformances (NominalTypeDecl *decl,
28322821 const clang::CXXRecordDecl *clangDecl) {
2833- if (Impl.isCxxInteropCompatVersionAtLeast (6 )) {
2834- // Propagate conforms_to attribute from public base classes.
2835- for (auto base : clangDecl->bases ()) {
2836- if (base.getAccessSpecifier () != clang::AccessSpecifier::AS_public)
2837- continue ;
2838- if (auto *baseClangDecl = base.getType ()->getAsCXXRecordDecl ())
2839- addExplicitProtocolConformances (decl, baseClangDecl);
2840- }
2822+ // Propagate conforms_to attribute from public base classes.
2823+ for (auto base : clangDecl->bases ()) {
2824+ if (base.getAccessSpecifier () != clang::AccessSpecifier::AS_public)
2825+ continue ;
2826+ if (auto *baseClangDecl = base.getType ()->getAsCXXRecordDecl ())
2827+ addExplicitProtocolConformances (decl, baseClangDecl);
28412828 }
28422829
28432830 if (!clangDecl->hasAttrs ())
@@ -3755,39 +3742,34 @@ namespace {
37553742
37563743 if (decl->isVirtual ()) {
37573744 if (auto funcDecl = dyn_cast_or_null<FuncDecl>(method)) {
3758- if (Impl.isCxxInteropCompatVersionAtLeast (6 )) {
3759- if (auto structDecl =
3760- dyn_cast_or_null<StructDecl>(method->getDeclContext ())) {
3761- // If this is a method of a Swift struct, any possible override of
3762- // this method would get sliced away, and an invocation would get
3763- // dispatched statically. This is fine because it matches the C++
3764- // behavior.
3765- if (decl->isPure ()) {
3766- // If this is a pure virtual method, we won't have any
3767- // implementation of it to invoke.
3768- Impl.markUnavailable (
3769- funcDecl, " virtual function is not available in Swift "
3770- " because it is pure" );
3771- }
3772- } else if (auto classDecl = dyn_cast_or_null<ClassDecl>(
3773- funcDecl->getDeclContext ())) {
3774- // This is a foreign reference type. Since `class T` on the Swift
3775- // side is mapped from `T*` on the C++ side, an invocation of a
3776- // virtual method `t->method()` should get dispatched dynamically.
3777- // Create a thunk that will perform dynamic dispatch.
3778- // TODO: we don't have to import the actual `method` in this case,
3779- // we can just synthesize a thunk and import that instead.
3780- auto result = synthesizer.makeVirtualMethod (decl);
3781- if (result) {
3782- return result;
3783- } else {
3784- Impl.markUnavailable (
3785- funcDecl, " virtual function is not available in Swift" );
3786- }
3745+ if (auto structDecl =
3746+ dyn_cast_or_null<StructDecl>(method->getDeclContext ())) {
3747+ // If this is a method of a Swift struct, any possible override of
3748+ // this method would get sliced away, and an invocation would get
3749+ // dispatched statically. This is fine because it matches the C++
3750+ // behavior.
3751+ if (decl->isPure ()) {
3752+ // If this is a pure virtual method, we won't have any
3753+ // implementation of it to invoke.
3754+ Impl.markUnavailable (funcDecl,
3755+ " virtual function is not available in Swift "
3756+ " because it is pure" );
3757+ }
3758+ } else if (auto classDecl = dyn_cast_or_null<ClassDecl>(
3759+ funcDecl->getDeclContext ())) {
3760+ // This is a foreign reference type. Since `class T` on the Swift
3761+ // side is mapped from `T*` on the C++ side, an invocation of a
3762+ // virtual method `t->method()` should get dispatched dynamically.
3763+ // Create a thunk that will perform dynamic dispatch.
3764+ // TODO: we don't have to import the actual `method` in this case,
3765+ // we can just synthesize a thunk and import that instead.
3766+ auto result = synthesizer.makeVirtualMethod (decl);
3767+ if (result) {
3768+ return result;
3769+ } else {
3770+ Impl.markUnavailable (
3771+ funcDecl, " virtual function is not available in Swift" );
37873772 }
3788- } else {
3789- Impl.markUnavailable (
3790- funcDecl, " virtual functions are not yet available in Swift" );
37913773 }
37923774 }
37933775 }
@@ -4045,8 +4027,7 @@ namespace {
40454027 // 1. Types
40464028 // 2. C++ methods from privately inherited base classes
40474029 if (!isa<clang::TypeDecl>(decl->getTargetDecl ()) &&
4048- !(isa<clang::CXXMethodDecl>(decl->getTargetDecl ()) &&
4049- Impl.isCxxInteropCompatVersionAtLeast (6 )))
4030+ !isa<clang::CXXMethodDecl>(decl->getTargetDecl ()))
40504031 return nullptr ;
40514032 // Constructors (e.g. `using BaseClass::BaseClass`) are handled in
40524033 // VisitCXXRecordDecl, since we need them to determine whether a struct
0 commit comments