Skip to content

Commit f5128d5

Browse files
authored
Merge pull request #72464 from jckarter/init-conditionally-copyable-empty-type
SILGen: Emit empty type initialization for conditionally-copyable type inits.
2 parents 83b2593 + d9bd92e commit f5128d5

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
@@ -754,7 +754,8 @@ void SILGenFunction::emitValueConstructor(ConstructorDecl *ctor) {
754754
{selfDecl->getTypeInContext()},
755755
LookUpConformanceInModule(module)),
756756
selfLV.getLValueAddress());
757-
} else if (isa<StructDecl>(nominal) && !nominal->canBeCopyable()
757+
} else if (isa<StructDecl>(nominal)
758+
&& lowering.getLoweredType().isMoveOnly()
758759
&& nominal->getStoredProperties().empty()) {
759760
auto *si = B.createStruct(ctor, lowering.getLoweredType(), {});
760761
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)