Skip to content

Commit 92d014c

Browse files
authored
Merge pull request #41349 from DougGregor/nonsendable-serialization-fix
2 parents 63161e6 + 3933c6d commit 92d014c

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

lib/Serialization/ModuleFormat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5656
/// describe what change you made. The content of this comment isn't important;
5757
/// it just ensures a conflict if two people change the module format.
5858
/// Don't worry about adhering to the 80-column limit for this line.
59-
const uint16_t SWIFTMODULE_VERSION_MINOR = 667; // @_backDeploy
59+
const uint16_t SWIFTMODULE_VERSION_MINOR = 668; // @_nonSendable fix
6060

6161
/// A standard hash seed used for all string hashes in a serialized module.
6262
///
@@ -1923,7 +1923,7 @@ namespace decls_block {
19231923

19241924
using NonSendableDeclAttrLayout = BCRecordLayout<
19251925
NonSendable_DECL_ATTR,
1926-
BCFixed<1> // assumed flag
1926+
BCFixed<1> // non-sendable kind
19271927
>;
19281928

19291929
using OptimizeDeclAttrLayout = BCRecordLayout<

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2504,7 +2504,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
25042504
auto *theAttr = cast<NonSendableAttr>(DA);
25052505
auto abbrCode = S.DeclTypeAbbrCodes[NonSendableDeclAttrLayout::Code];
25062506
NonSendableDeclAttrLayout::emitRecord(S.Out, S.ScratchRecord, abbrCode,
2507-
(unsigned)theAttr->getKind());
2507+
(unsigned)theAttr->Specificity);
25082508
return;
25092509
}
25102510

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@_nonSendable
2+
public struct A { }
3+
4+
@_nonSendable(_assumed)
5+
public struct B { }

test/Serialization/nonsendable.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -module-name def_nonsendable -o %t %S/Inputs/def_nonsendable.swift
3+
// RUN: llvm-bcanalyzer %t/def_nonsendable.swiftmodule | %FileCheck %s
4+
// RUN: %target-swift-frontend -typecheck -I %t %s -o /dev/null
5+
// RUN: %target-swift-frontend -emit-sil -I %t %s -o /dev/null
6+
7+
// RUN: %target-swift-ide-test(mock-sdk: %clang-importer-sdk) -print-module -module-to-print=def_nonsendable -I %t -source-filename=%s | %FileCheck -check-prefix=CHECK-PRINT %s
8+
9+
// CHECK-NOT: UnknownCode
10+
11+
// CHECK-PRINT-DAG: @_nonSendable struct A
12+
// CHECK-PRINT-DAG: @_nonSendable(_assumed) struct B
13+
14+
import def_nonsendable
15+
16+
func test(a: A, b: B) { }

0 commit comments

Comments
 (0)