Skip to content

Commit 9cf65af

Browse files
committed
[Serialization] Ensure semantic attributes are serialized
Make sure we serialize `getSemanticAttrs` since for lazy type-checking we may not yet have computed e.g actor isolation. rdar://162100120
1 parent 536518b commit 9cf65af

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
@@ -4180,7 +4180,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
41804180
writeABIOnlyCounterpart(abiRole.getCounterpartUnchecked());
41814181

41824182
// Emit attributes (if any).
4183-
for (auto Attr : D->getAttrs())
4183+
for (auto Attr : D->getSemanticAttrs())
41844184
writeDeclAttribute(D, Attr);
41854185

41864186
if (auto *value = dyn_cast<ValueDecl>(D))
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// REQUIRES: swift_feature_NonisolatedNonsendingByDefault
5+
6+
// Test both with and without '-experimental-lazy-typecheck'
7+
// RUN: %swift-frontend -emit-module %t/Lib.swift -swift-version 6 -experimental-lazy-typecheck -experimental-skip-all-function-bodies -enable-upcoming-feature NonisolatedNonsendingByDefault -module-name Lib -o %t/Modules/Lib.swiftmodule
8+
// RUN: %swift-frontend -emit-sil %t/Test.swift -I %t/Modules -swift-version 6 -enable-upcoming-feature NonisolatedNonsendingByDefault
9+
10+
// RUN: %swift-frontend -emit-module %t/Lib.swift -swift-version 6 -experimental-skip-all-function-bodies -enable-upcoming-feature NonisolatedNonsendingByDefault -module-name Lib -o %t/Modules/Lib.swiftmodule
11+
// RUN: %swift-frontend -emit-sil %t/Test.swift -I %t/Modules -swift-version 6 -enable-upcoming-feature NonisolatedNonsendingByDefault
12+
13+
//--- Lib.swift
14+
15+
public final class IndexStoreDownloadManager2: Sendable {
16+
public func withIndexStore(
17+
body: (String) async throws -> Void
18+
) async throws {
19+
}
20+
}
21+
22+
//--- Test.swift
23+
24+
import Lib
25+
26+
private func `import`(
27+
indexStoreDownloadManager: IndexStoreDownloadManager2,
28+
) async throws {
29+
import2(
30+
indexStoreProvider: { runWithIndexStore in
31+
// Make sure we don't error here since `withIndexStore` is nonisolated(nonsending)
32+
try await indexStoreDownloadManager.withIndexStore(body: runWithIndexStore)
33+
}
34+
)
35+
}
36+
37+
func import2(
38+
indexStoreProvider: (_ runWithIndexStore: (_ indexStore: String) async throws -> Void) async throws -> Void,
39+
) {
40+
}

0 commit comments

Comments
 (0)