Skip to content

Commit efd440c

Browse files
committed
[Serialization] InitAccessors: Use correct code for @storageRestrictions serialization
1 parent aad2b6e commit efd440c

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2957,7 +2957,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
29572957
}
29582958

29592959
case DAK_StorageRestrictions: {
2960-
auto abbrCode = S.DeclTypeAbbrCodes[AccessesDeclAttrLayout::Code];
2960+
auto abbrCode = S.DeclTypeAbbrCodes[StorageRestrictionsDeclAttrLayout::Code];
29612961
auto attr = cast<StorageRestrictionsAttr>(DA);
29622962

29632963
SmallVector<IdentifierID, 4> properties;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t/src)
3+
// RUN: %empty-directory(%t/sdk)
4+
// RUN: split-file %s %t/src
5+
6+
// REQUIRES: asserts
7+
8+
// RUN: %target-swift-frontend -emit-module %t/src/PublicModule.swift \
9+
// RUN: -module-name PublicModule -swift-version 5 \
10+
// RUN: -emit-module-path %t/sdk/PublicModule.swiftmodule \
11+
// RUN: -enable-experimental-feature InitAccessors
12+
13+
// RUN: %target-swift-frontend -typecheck %t/src/Client.swift \
14+
// RUN: -enable-experimental-feature InitAccessors \
15+
// RUN: -module-name Client -I %t/sdk
16+
17+
//--- PublicModule.swift
18+
public struct Test<T> {
19+
private var _x: T
20+
21+
public var x: T {
22+
@storageRestrictions(initializes: _x)
23+
init {
24+
_x = newValue
25+
}
26+
27+
get { _x }
28+
set { _x = newValue }
29+
}
30+
31+
public init(data: T) {
32+
self.x = data
33+
}
34+
}
35+
36+
//--- Client.swift
37+
import PublicModule
38+
39+
let test = Test<[Int]>(data: [1, 2, 3])
40+
_ = test.x

0 commit comments

Comments
 (0)