Skip to content

Commit 78ffc87

Browse files
committed
[move-only] Make sure we can properly deserialize deinits from structs/enums.
We previously had a cast<ClassDecl> here. I changed it to NominalTypeDecl and added tests for this. rdar://102173184
1 parent 4fcc60e commit 78ffc87

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

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: 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)