From bd4809593b9178be57490f53c39735655b436a52 Mon Sep 17 00:00:00 2001 From: Nate Chandler Date: Mon, 8 Apr 2024 17:15:13 -0700 Subject: [PATCH] [BitwiseCopyable] Don't infer for noncopyable. This bailout was accidentally removed in https://github.com/apple/swift/pull/72856 when removing a duplicative diagnostic. rdar://126135770 --- lib/Sema/TypeCheckBitwise.cpp | 6 ++++++ test/ModuleInterface/bitwise_copyable.swift | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/ModuleInterface/bitwise_copyable.swift diff --git a/lib/Sema/TypeCheckBitwise.cpp b/lib/Sema/TypeCheckBitwise.cpp index 50a788665e023..1f074b001a1ce 100644 --- a/lib/Sema/TypeCheckBitwise.cpp +++ b/lib/Sema/TypeCheckBitwise.cpp @@ -229,6 +229,12 @@ void BitwiseCopyableStorageVisitor::emitNonconformingMemberTypeDiagnostic( static bool checkBitwiseCopyableInstanceStorage(NominalTypeDecl *nominal, DeclContext *dc, BitwiseCopyableCheck check) { + if (dc->mapTypeIntoContext(nominal->getDeclaredInterfaceType()) + ->isNoncopyable()) { + // Already separately diagnosed when explicit. + return true; + } + assert(dc->getParentModule()->getASTContext().getProtocol( KnownProtocolKind::BitwiseCopyable)); diff --git a/test/ModuleInterface/bitwise_copyable.swift b/test/ModuleInterface/bitwise_copyable.swift new file mode 100644 index 0000000000000..b597643def109 --- /dev/null +++ b/test/ModuleInterface/bitwise_copyable.swift @@ -0,0 +1,11 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name Test -enable-experimental-feature BitwiseCopyable +// RUN: %FileCheck %s < %t.swiftinterface +// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name Test + + +@frozen +@_moveOnly +public struct S_Implicit_Noncopyable {} + +// CHECK-NOT: extension Test.S_Implicit_Noncopyable : Swift._BitwiseCopyable {}