Skip to content

Commit d9bd92e

Browse files
committed
SILGen: Emit empty type initialization for conditionally-copyable type inits.
Fix the check here to go by `isMoveOnly` on the lowered type rather than `canBeCopyable` on the declaration so that we correctly emit the semantic initialization for types that are `~Copyable` in their most generic form. Fixes rdar://125101955.
1 parent 1166f2e commit d9bd92e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/SILGen/SILGenConstructor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ void SILGenFunction::emitValueConstructor(ConstructorDecl *ctor) {
759759
{selfDecl->getTypeInContext()},
760760
LookUpConformanceInModule(module)),
761761
selfLV.getLValueAddress());
762-
} else if (isa<StructDecl>(nominal) && !nominal->canBeCopyable()
762+
} else if (isa<StructDecl>(nominal)
763+
&& lowering.getLoweredType().isMoveOnly()
763764
&& nominal->getStoredProperties().empty()) {
764765
auto *si = B.createStruct(ctor, lowering.getLoweredType(), {});
765766
B.emitStoreValueOperation(ctor, si, selfLV.getLValueAddress(),
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-swift-frontend -enable-experimental-feature NoncopyableGenerics -emit-sil -verify -primary-file %s
2+
3+
struct G<T: ~Copyable>: ~Copyable { }
4+
5+
extension G: Copyable {}

0 commit comments

Comments
 (0)