@@ -2192,22 +2192,12 @@ namespace {
2192
2192
Impl.ImportedDecls [{decl->getCanonicalDecl (), getVersion ()}] = result;
2193
2193
2194
2194
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.
2209
2197
return nullptr ;
2210
2198
}
2199
+ result->getAttrs ().add (new (Impl.SwiftContext )
2200
+ MoveOnlyAttr (/* Implicit=*/ true ));
2211
2201
}
2212
2202
2213
2203
// FIXME: Figure out what to do with superclasses in C++. One possible
@@ -2658,8 +2648,7 @@ namespace {
2658
2648
// SemaLookup.cpp).
2659
2649
if (!decl->isBeingDefined () && !decl->isDependentContext () &&
2660
2650
areRecordFieldsComplete (decl)) {
2661
- if (decl->hasInheritedConstructor () &&
2662
- Impl.isCxxInteropCompatVersionAtLeast (6 )) {
2651
+ if (decl->hasInheritedConstructor ()) {
2663
2652
for (auto member : decl->decls ()) {
2664
2653
if (auto usingDecl = dyn_cast<clang::UsingDecl>(member)) {
2665
2654
for (auto usingShadowDecl : usingDecl->shadows ()) {
@@ -2830,14 +2819,12 @@ namespace {
2830
2819
void
2831
2820
addExplicitProtocolConformances (NominalTypeDecl *decl,
2832
2821
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);
2841
2828
}
2842
2829
2843
2830
if (!clangDecl->hasAttrs ())
@@ -3755,39 +3742,34 @@ namespace {
3755
3742
3756
3743
if (decl->isVirtual ()) {
3757
3744
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" );
3787
3772
}
3788
- } else {
3789
- Impl.markUnavailable (
3790
- funcDecl, " virtual functions are not yet available in Swift" );
3791
3773
}
3792
3774
}
3793
3775
}
@@ -4045,8 +4027,7 @@ namespace {
4045
4027
// 1. Types
4046
4028
// 2. C++ methods from privately inherited base classes
4047
4029
if (!isa<clang::TypeDecl>(decl->getTargetDecl ()) &&
4048
- !(isa<clang::CXXMethodDecl>(decl->getTargetDecl ()) &&
4049
- Impl.isCxxInteropCompatVersionAtLeast (6 )))
4030
+ !isa<clang::CXXMethodDecl>(decl->getTargetDecl ()))
4050
4031
return nullptr ;
4051
4032
// Constructors (e.g. `using BaseClass::BaseClass`) are handled in
4052
4033
// VisitCXXRecordDecl, since we need them to determine whether a struct
0 commit comments