Skip to content

Commit 1084d89

Browse files
authored
Merge pull request #62021 from gottesmm/pr-88e3b82d31a08823ec6704d7d190b78b233ac27e
[move-only] Two more small fixes
2 parents cd47e7f + 78ffc87 commit 1084d89

File tree

6 files changed

+51
-4
lines changed

6 files changed

+51
-4
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,

lib/Serialization/Deserialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4491,7 +4491,7 @@ class DeclDeserializer {
44914491

44924492
dtor->setGenericSignature(MF.getGenericSignature(genericSigID));
44934493

4494-
dtor->setAccess(std::max(cast<ClassDecl>(DC)->getFormalAccess(),
4494+
dtor->setAccess(std::max(cast<NominalTypeDecl>(DC)->getFormalAccess(),
44954495
AccessLevel::Internal));
44964496

44974497
if (isImplicit)
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+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
@_moveOnly
3+
public struct MoveOnlyStruct {
4+
private let desc: Int
5+
6+
public init(desc: Int) {
7+
self.desc = desc
8+
}
9+
10+
deinit { }
11+
}
12+
13+
@_moveOnly
14+
public enum MoveOnlyEnum {
15+
case lhs(Int)
16+
case rhs(Int)
17+
18+
deinit { }
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -enable-experimental-move-only -g -emit-module -module-name OtherModule %S/Inputs/moveonly_deinit.swift -emit-module-path %t/OtherModule.swiftmodule
3+
// RUN: %target-swift-frontend -enable-experimental-move-only -g -I %t %s -emit-silgen
4+
5+
// Make sure we can deserialize deinits of both enums and structs.
6+
7+
import OtherModule
8+
9+
let s = MoveOnlyStruct(desc: 5)
10+
let e = MoveOnlyEnum.lhs(5)

0 commit comments

Comments
 (0)