Skip to content

Commit a843d69

Browse files
authored
Merge pull request #73223 from apple/egorzhdan/6.0-cxx-interop-compat-mode
🍒[cxx-interop] Pull changes from `swift-6` compat mode into `swift-5.9`
2 parents 327fa92 + e0aac58 commit a843d69

31 files changed

+127
-81
lines changed

include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,6 @@ ERROR(conforms_to_ambiguous,none,
247247
ERROR(conforms_to_not_protocol,none,
248248
"%0 %1 referenced in protocol conformance '%2' is not a protocol", (DescriptiveDeclKind, ValueDecl *, StringRef))
249249

250-
ERROR(move_only_requires_move_only,none,
251-
"use of noncopyable C++ type '%0' requires -enable-experimental-move-only",
252-
(StringRef))
253-
254250
ERROR(failed_base_method_call_synthesis,none,
255251
"failed to synthesize call to the base method %0 of type %0",
256252
(ValueDecl *, ValueDecl *))

lib/ClangImporter/ClangImporter.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5709,6 +5709,8 @@ DeclAttributes cloneImportedAttributes(ValueDecl *decl, ASTContext &context) {
57095709

57105710
static ValueDecl *
57115711
cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext) {
5712+
ASTContext &context = decl->getASTContext();
5713+
57125714
if (auto fn = dyn_cast<FuncDecl>(decl)) {
57135715
// TODO: function templates are specialized during type checking so to
57145716
// support these we need to tell Swift to type check the synthesized bodies.
@@ -5726,7 +5728,6 @@ cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext) {
57265728
return nullptr;
57275729
}
57285730

5729-
ASTContext &context = decl->getASTContext();
57305731
auto out = FuncDecl::createImplicit(
57315732
context, fn->getStaticSpelling(), fn->getName(),
57325733
fn->getNameLoc(), fn->hasAsync(), fn->hasThrows(),
@@ -5762,6 +5763,20 @@ cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext) {
57625763
}
57635764

57645765
if (auto var = dyn_cast<VarDecl>(decl)) {
5766+
auto oldContext = var->getDeclContext();
5767+
auto oldTypeDecl = oldContext->getSelfNominalTypeDecl();
5768+
// If the base type is non-copyable, and non-copyable generics are disabled,
5769+
// we cannot synthesize the accessor, because its implementation would use
5770+
// `UnsafePointer<BaseTy>`.
5771+
// We cannot use `ty->isNoncopyable()` here because that would create a
5772+
// cyclic dependency between ModuleQualifiedLookupRequest and
5773+
// LookupConformanceInModuleRequest, so we check for the presence of
5774+
// move-only attribute that is implicitly added to non-copyable C++ types by
5775+
// ClangImporter.
5776+
if (oldTypeDecl->getAttrs().hasAttribute<MoveOnlyAttr>() &&
5777+
!context.LangOpts.hasFeature(Feature::NoncopyableGenerics))
5778+
return nullptr;
5779+
57655780
auto rawMemory = allocateMemoryForDecl<VarDecl>(var->getASTContext(),
57665781
sizeof(VarDecl), false);
57675782
auto out =

lib/ClangImporter/ImportDecl.cpp

Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -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

lib/ClangImporter/ImportType.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,26 @@ namespace {
509509
return importFunctionPointerLikeType(*type, pointeeType);
510510
}
511511

512+
// If non-copyable generics are disabled, we cannot specify
513+
// UnsafePointer<T> with a non-copyable type T.
514+
// We cannot use `ty->isNoncopyable()` here because that would create a
515+
// cyclic dependency between ModuleQualifiedLookupRequest and
516+
// LookupConformanceInModuleRequest, so we check for the presence of
517+
// move-only attribute that is implicitly added to non-copyable C++ types
518+
// by ClangImporter.
519+
if (pointeeType && pointeeType->getAnyNominal() &&
520+
pointeeType->getAnyNominal()
521+
->getAttrs()
522+
.hasAttribute<MoveOnlyAttr>() &&
523+
!Impl.SwiftContext.LangOpts.hasFeature(
524+
Feature::NoncopyableGenerics)) {
525+
auto opaquePointerDecl = Impl.SwiftContext.getOpaquePointerDecl();
526+
if (!opaquePointerDecl)
527+
return Type();
528+
return {opaquePointerDecl->getDeclaredInterfaceType(),
529+
ImportHint::OtherPointer};
530+
}
531+
512532
PointerTypeKind pointerKind;
513533
if (quals.hasConst()) {
514534
pointerKind = PTK_UnsafePointer;
@@ -2603,7 +2623,6 @@ static ParamDecl *getParameterInfo(ClangImporter::Implementation *impl,
26032623
// (https://github.com/apple/swift/issues/70124)
26042624
if (param->hasDefaultArg() && !isInOut &&
26052625
!isa<clang::CXXConstructorDecl>(param->getDeclContext()) &&
2606-
impl->isCxxInteropCompatVersionAtLeast(6) &&
26072626
impl->isDefaultArgSafeToImport(param)) {
26082627
SwiftDeclSynthesizer synthesizer(*impl);
26092628
if (CallExpr *defaultArgExpr = synthesizer.makeDefaultArgument(

test/Interop/Cxx/class/conforms-to.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
// RUN: %target-swift-frontend %S/Inputs/conforms-to-imported.swift -module-name ImportedModule -emit-module -emit-module-path %t/ImportedModule.swiftmodule
33

44
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %t -I %S/Inputs -module-name SwiftTest -enable-experimental-cxx-interop
5-
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %t -I %S/Inputs -module-name SwiftTest -cxx-interoperability-mode=swift-6 -D UPCOMING_SWIFT
6-
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %t -I %S/Inputs -module-name SwiftTest -cxx-interoperability-mode=upcoming-swift -D UPCOMING_SWIFT
5+
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %t -I %S/Inputs -module-name SwiftTest -cxx-interoperability-mode=swift-5.9
6+
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %t -I %S/Inputs -module-name SwiftTest -cxx-interoperability-mode=swift-6
7+
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %t -I %S/Inputs -module-name SwiftTest -cxx-interoperability-mode=upcoming-swift
78

89
import ConformsTo
910
import ImportedModule
@@ -23,11 +24,9 @@ func callee(_ _: Testable) {
2324
func caller(_ x: HasTest) {
2425
callee(x)
2526
}
26-
#if UPCOMING_SWIFT
2727
func caller(_ x: DerivedFromHasTest) { callee(x) }
2828
func caller(_ x: DerivedFromDerivedFromHasTest) { callee(x) }
2929
func caller(_ x: DerivedFromDerivedFromHasTestWithDuplicateArg) { callee(x) }
30-
#endif
3130

3231
func callee(_ _: Playable) {
3332

@@ -36,7 +35,6 @@ func callee(_ _: Playable) {
3635
func caller(_ x: Playable) {
3736
callee(x)
3837
}
39-
#if UPCOMING_SWIFT
4038
func caller(_ x: DerivedFromHasPlay) { callee(x) }
4139
func caller(_ x: DerivedFromDerivedFromHasPlay) { callee(x) }
4240

@@ -48,15 +46,12 @@ func caller(_ x: DerivedFromHasTestAndPlay) {
4846
callee(x as Testable)
4947
callee(x as Playable)
5048
}
51-
#endif
5249

5350
func callee(_ _: ProtocolFromImportedModule) {
5451
}
5552

5653
func caller(_ x: HasImportedConf) {
5754
callee(x)
5855
}
59-
#if UPCOMING_SWIFT
6056
func caller(_ x: DerivedFromHasImportedConf) { callee(x) }
6157
func caller(_ x: DerivedFromDerivedFromHasImportedConf) { callee(x) }
62-
#endif

test/Interop/Cxx/class/inheritance/using-base-members-typechecker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=swift-5.9
12
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=swift-6
23
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=upcoming-swift
34

test/Interop/Cxx/class/inheritance/using-base-members.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -cxx-interoperability-mode=swift-5.9)
12
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -cxx-interoperability-mode=swift-6)
23
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -cxx-interoperability-mode=upcoming-swift)
34
//

test/Interop/Cxx/class/inheritance/virtual-methods-irgen.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-swift-emit-ir -I %S/Inputs -cxx-interoperability-mode=upcoming-swift %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
2+
// RUN: %target-swift-emit-ir -I %S/Inputs -cxx-interoperability-mode=swift-5.9 %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
23
// RUN: %target-swift-emit-ir -I %S/Inputs -cxx-interoperability-mode=swift-6 %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
34

45
import VirtualMethods

test/Interop/Cxx/class/inheritance/virtual-methods-module-interface.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// RUN: %target-swift-ide-test -print-module -cxx-interoperability-mode=swift-5.9 -print-implicit-attrs -module-to-print=VirtualMethods -I %S/Inputs -source-filename=x | %FileCheck %s
12
// RUN: %target-swift-ide-test -print-module -cxx-interoperability-mode=swift-6 -print-implicit-attrs -module-to-print=VirtualMethods -I %S/Inputs -source-filename=x | %FileCheck %s
23
// RUN: %target-swift-ide-test -print-module -cxx-interoperability-mode=upcoming-swift -print-implicit-attrs -module-to-print=VirtualMethods -I %S/Inputs -source-filename=x | %FileCheck %s
34

test/Interop/Cxx/class/inheritance/virtual-methods-typechecker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=upcoming-swift
2+
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=swift-5.9
23
// RUN: %target-typecheck-verify-swift -verify-ignore-unknown -I %S/Inputs -cxx-interoperability-mode=swift-6
34

45
import VirtualMethods

test/Interop/Cxx/class/inheritance/virtual-methods.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=swift-5.9)
12
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=swift-6)
23
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift)
34

test/Interop/Cxx/class/move-only/Inputs/move-only-cxx-value-type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@ struct NonCopyableHolderDerivedDerived: NonCopyableHolderDerived {
5353
}
5454
};
5555

56+
inline NonCopyable *getNonCopyablePtr() { return nullptr; }
57+
inline NonCopyableDerived *getNonCopyableDerivedPtr() { return nullptr; }
58+
5659
#endif // TEST_INTEROP_CXX_CLASS_MOVE_ONLY_VT_H

test/Interop/Cxx/class/move-only/inherited-field-access-irgen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-emit-irgen -I %S/Inputs -cxx-interoperability-mode=swift-6 %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
2-
// RUN: %target-swift-emit-irgen -I %S/Inputs -cxx-interoperability-mode=upcoming-swift %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
1+
// RUN: %target-swift-emit-irgen -I %S/Inputs -cxx-interoperability-mode=swift-6 -enable-experimental-feature NoncopyableGenerics %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
2+
// RUN: %target-swift-emit-irgen -I %S/Inputs -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics %s -validate-tbd-against-ir=none -Xcc -fignore-exceptions | %FileCheck %s
33

44
import MoveOnlyCxxValueType
55

test/Interop/Cxx/class/move-only/inherited-field-access-silgen.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-emit-sil -I %S/Inputs -cxx-interoperability-mode=swift-6 %s -validate-tbd-against-ir=none | %FileCheck %s
2-
// RUN: %target-swift-emit-sil -I %S/Inputs -cxx-interoperability-mode=upcoming-swift %s -validate-tbd-against-ir=none | %FileCheck %s
1+
// RUN: %target-swift-emit-sil -I %S/Inputs -cxx-interoperability-mode=swift-6 -enable-experimental-feature NoncopyableGenerics %s -validate-tbd-against-ir=none | %FileCheck %s
2+
// RUN: %target-swift-emit-sil -I %S/Inputs -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics %s -validate-tbd-against-ir=none | %FileCheck %s
33

44
import MoveOnlyCxxValueType
55

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-swift-ide-test -print-module -module-to-print=MoveOnlyCxxValueType -I %S/Inputs -cxx-interoperability-mode=upcoming-swift -source-filename=x | %FileCheck %s --check-prefix=CHECK-NO-NCG
2+
// RUN: %target-swift-ide-test -print-module -module-to-print=MoveOnlyCxxValueType -I %S/Inputs -cxx-interoperability-mode=upcoming-swift -source-filename=x -enable-experimental-feature NoncopyableGenerics | %FileCheck %s --check-prefix=CHECK-NCG
3+
4+
// CHECK-NO-NCG: func getNonCopyablePtr() -> OpaquePointer
5+
// CHECK-NO-NCG: func getNonCopyableDerivedPtr() -> OpaquePointer
6+
7+
// CHECK-NCG: func getNonCopyablePtr() -> UnsafeMutablePointer<NonCopyable>
8+
// CHECK-NCG: func getNonCopyableDerivedPtr() -> UnsafeMutablePointer<NonCopyableDerived>

test/Interop/Cxx/class/move-only/move-only-cxx-value-type.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift)
2+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
3+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-5.9 -O)
24
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6 -O)
5+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6 -O -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
36

4-
//
57
// REQUIRES: executable_test
68

79
import MoveOnlyCxxValueType
@@ -27,10 +29,12 @@ MoveOnlyCxxValueType.test("Test derived move only type member access") {
2729
var k = c.method(-3)
2830
expectEqual(k, -6)
2931
expectEqual(c.method(1), 2)
32+
#if HAS_NONCOPYABLE_GENERICS
3033
k = c.x
3134
expectEqual(k, 2)
3235
c.x = 11
3336
expectEqual(c.x, 11)
37+
#endif
3438
k = c.mutMethod(-13)
3539
expectEqual(k, -13)
3640
}
@@ -56,6 +60,7 @@ MoveOnlyCxxValueType.test("Test move only field access in holder") {
5660
expectEqual(c.x.x, 5)
5761
}
5862

63+
#if HAS_NONCOPYABLE_GENERICS
5964
MoveOnlyCxxValueType.test("Test move only field access in derived holder") {
6065
var c = NonCopyableHolderDerivedDerived(-11)
6166
var k = borrowNC(c.x)
@@ -69,5 +74,6 @@ MoveOnlyCxxValueType.test("Test move only field access in derived holder") {
6974
c.x.mutMethod(5)
7075
expectEqual(c.x.x, 5)
7176
}
77+
#endif
7278

7379
runAllTests()

test/Interop/Cxx/class/protocol-conformance-typechecker.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Tests that a C++ class can conform to a Swift protocol.
22

33
// RUN: %target-typecheck-verify-swift -I %S/Inputs -enable-experimental-cxx-interop
4+
// RUN: %target-typecheck-verify-swift -I %S/Inputs -D VIRTUAL_METHODS -cxx-interoperability-mode=swift-5.9
45
// RUN: %target-typecheck-verify-swift -I %S/Inputs -D VIRTUAL_METHODS -cxx-interoperability-mode=swift-6
56
// RUN: %target-typecheck-verify-swift -I %S/Inputs -D VIRTUAL_METHODS -cxx-interoperability-mode=upcoming-swift
67

0 commit comments

Comments
 (0)