Skip to content

Commit 9703319

Browse files
committed
CxxInterop: remove checks for NoncopyableGenerics
It will always evaluate to true now; it's not experimental. This change effectively reverts the following: - 6140ba1 - 78eee32 (cherry picked from commit b04be89)
1 parent 2995ee5 commit 9703319

File tree

6 files changed

+3
-51
lines changed

6 files changed

+3
-51
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5763,20 +5763,6 @@ cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext) {
57635763
}
57645764

57655765
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-
57805766
auto rawMemory = allocateMemoryForDecl<VarDecl>(var->getASTContext(),
57815767
sizeof(VarDecl), false);
57825768
auto out =

lib/ClangImporter/ImportType.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -509,26 +509,6 @@ 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-
532512
PointerTypeKind pointerKind;
533513
if (quals.hasConst()) {
534514
pointerKind = PTK_UnsafePointer;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics)
2-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics -O -Xfrontend -sil-verify-none)
1+
// 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 -O -Xfrontend -sil-verify-none)
33
//
44
// REQUIRES: executable_test
55
// REQUIRES: GH_ISSUE_70246
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
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
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-NCG
62

73
// CHECK-NCG: func getNonCopyablePtr() -> UnsafeMutablePointer<NonCopyable>
84
// CHECK-NCG: func getNonCopyableDerivedPtr() -> UnsafeMutablePointer<NonCopyableDerived>

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
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)
32
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-5.9 -O)
43
// 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)
64

75
// REQUIRES: executable_test
86

@@ -29,12 +27,10 @@ MoveOnlyCxxValueType.test("Test derived move only type member access") {
2927
var k = c.method(-3)
3028
expectEqual(k, -6)
3129
expectEqual(c.method(1), 2)
32-
#if HAS_NONCOPYABLE_GENERICS
3330
k = c.x
3431
expectEqual(k, 2)
3532
c.x = 11
3633
expectEqual(c.x, 11)
37-
#endif
3834
k = c.mutMethod(-13)
3935
expectEqual(k, -13)
4036
}
@@ -60,7 +56,6 @@ MoveOnlyCxxValueType.test("Test move only field access in holder") {
6056
expectEqual(c.x.x, 5)
6157
}
6258

63-
#if HAS_NONCOPYABLE_GENERICS
6459
MoveOnlyCxxValueType.test("Test move only field access in derived holder") {
6560
var c = NonCopyableHolderDerivedDerived(-11)
6661
var k = borrowNC(c.x)
@@ -74,6 +69,5 @@ MoveOnlyCxxValueType.test("Test move only field access in derived holder") {
7469
c.x.mutMethod(5)
7570
expectEqual(c.x.x, 5)
7671
}
77-
#endif
7872

7973
runAllTests()

test/Interop/Cxx/operators/move-only/move-only-synthesized-properties.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-5.9)
22
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6)
33
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift)
4-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
54
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-5.9 -O)
65
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=swift-6 -O)
76
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O)
8-
// RUN: %target-run-simple-swift(-I %S/Inputs/ -cxx-interoperability-mode=upcoming-swift -O -enable-experimental-feature NoncopyableGenerics -D HAS_NONCOPYABLE_GENERICS)
97
//
108
// REQUIRES: executable_test
119

@@ -92,7 +90,6 @@ MoveOnlyCxxOperators.test("testNonCopyableHolderValueMutDeref pointee value") {
9290
expectEqual(k.x, k2.x)
9391
}
9492

95-
#if HAS_NONCOPYABLE_GENERICS
9693
MoveOnlyCxxOperators.test("NonCopyableHolderConstDerefDerivedDerived pointee borrow") {
9794
let holder = NonCopyableHolderConstDerefDerivedDerived(11)
9895
var k = borrowNC(holder.pointee)
@@ -160,6 +157,5 @@ MoveOnlyCxxOperators.test("testNonCopyableHolderValueMutDerefDerivedDerived poin
160157
var k2 = holder.pointee
161158
expectEqual(k.x, k2.x)
162159
}
163-
#endif
164160

165161
runAllTests()

0 commit comments

Comments
 (0)