@@ -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
@@ -2666,8 +2656,7 @@ namespace {
2666
2656
// SemaLookup.cpp).
2667
2657
if (!decl->isBeingDefined () && !decl->isDependentContext () &&
2668
2658
areRecordFieldsComplete (decl)) {
2669
- if (decl->hasInheritedConstructor () &&
2670
- Impl.isCxxInteropCompatVersionAtLeast (6 )) {
2659
+ if (decl->hasInheritedConstructor ()) {
2671
2660
for (auto member : decl->decls ()) {
2672
2661
if (auto usingDecl = dyn_cast<clang::UsingDecl>(member)) {
2673
2662
for (auto usingShadowDecl : usingDecl->shadows ()) {
@@ -2838,14 +2827,12 @@ namespace {
2838
2827
void
2839
2828
addExplicitProtocolConformances (NominalTypeDecl *decl,
2840
2829
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);
2849
2836
}
2850
2837
2851
2838
if (!clangDecl->hasAttrs ())
@@ -3763,39 +3750,34 @@ namespace {
3763
3750
3764
3751
if (decl->isVirtual ()) {
3765
3752
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" );
3795
3780
}
3796
- } else {
3797
- Impl.markUnavailable (
3798
- funcDecl, " virtual functions are not yet available in Swift" );
3799
3781
}
3800
3782
}
3801
3783
}
@@ -4053,8 +4035,7 @@ namespace {
4053
4035
// 1. Types
4054
4036
// 2. C++ methods from privately inherited base classes
4055
4037
if (!isa<clang::TypeDecl>(decl->getTargetDecl ()) &&
4056
- !(isa<clang::CXXMethodDecl>(decl->getTargetDecl ()) &&
4057
- Impl.isCxxInteropCompatVersionAtLeast (6 )))
4038
+ !isa<clang::CXXMethodDecl>(decl->getTargetDecl ()))
4058
4039
return nullptr ;
4059
4040
// Constructors (e.g. `using BaseClass::BaseClass`) are handled in
4060
4041
// VisitCXXRecordDecl, since we need them to determine whether a struct
0 commit comments