Skip to content

Commit 8d39e52

Browse files
committed
[SILGen] TypeWrappers: Make sure that default init of $Storage is always emitted
Although it might not be used from user-defined code directly it's still required for injected `self.$_storage = ...` performed by DI.
1 parent 31cf06b commit 8d39e52

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,13 +1430,14 @@ void SILGenModule::emitConstructor(ConstructorDecl *decl) {
14301430
SILDeclRef constant(decl);
14311431
DeclContext *declCtx = decl->getDeclContext();
14321432

1433-
// Make sure that memberwise initializer of $Storage
1434-
// in a type wrapped type is always emitted because
1435-
// it would later be used to initialize $storage property.
1433+
// Make sure that default & memberwise initializers of $Storage
1434+
// in a type wrapped type are always emitted because they would
1435+
// later be used to initialize its `$storage` property.
14361436
if (auto *SD = declCtx->getSelfStructDecl()) {
14371437
auto &ctx = SD->getASTContext();
14381438
if (SD->getName() == ctx.Id_TypeWrapperStorage &&
1439-
decl->isMemberwiseInitializer()) {
1439+
(decl->isMemberwiseInitializer() ||
1440+
decl == SD->getDefaultInitializer())) {
14401441
#ifndef NDEBUG
14411442
auto *wrapped = SD->getDeclContext()->getSelfNominalTypeDecl();
14421443
assert(wrapped->hasTypeWrapper());

0 commit comments

Comments
 (0)