Skip to content

Commit 4fcc60e

Browse files
committed
[move-only] When emitting a module, do not emit the body of the deinit of a move only type.
rdar://102173152
1 parent 6df38a6 commit 4fcc60e

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,12 @@ void SILGenModule::emitMoveOnlyDestructor(NominalTypeDecl *cd,
15901590

15911591
emitAbstractFuncDecl(dd);
15921592

1593-
// Emit the deallocating destructor.
1594-
SILDeclRef deallocator(dd, SILDeclRef::Kind::Deallocator);
1595-
emitFunctionDefinition(deallocator, getFunction(deallocator, ForDefinition));
1593+
// Emit the deallocating destructor if we have a body.
1594+
if (dd->hasBody()) {
1595+
SILDeclRef deallocator(dd, SILDeclRef::Kind::Deallocator);
1596+
emitFunctionDefinition(deallocator,
1597+
getFunction(deallocator, ForDefinition));
1598+
}
15961599
}
15971600

15981601
void SILGenModule::emitDefaultArgGenerator(SILDeclRef constant,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-module -g -enable-experimental-move-only -experimental-skip-non-inlinable-function-bodies-without-types %s
2+
3+
// Just make sure we don't crash.
4+
5+
@_moveOnly
6+
public struct S {
7+
private let desc: Int
8+
9+
internal init(desc: Int) {
10+
self.desc = desc
11+
}
12+
13+
deinit {
14+
}
15+
}

0 commit comments

Comments
 (0)