Skip to content

Commit e61f8f1

Browse files
authored
Merge pull request #39841 from DougGregor/isolated-params-serialization-5.5
Properly serialize 'isolated' bit on function parameter declarations.
2 parents dd3f702 + 4de006c commit e61f8f1

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3080,12 +3080,14 @@ class DeclDeserializer {
30803080
bool isIUO;
30813081
bool isVariadic;
30823082
bool isAutoClosure;
3083+
bool isIsolated;
30833084
uint8_t rawDefaultArg;
30843085

30853086
decls_block::ParamLayout::readRecord(scratch, argNameID, paramNameID,
30863087
contextID, rawSpecifier,
30873088
interfaceTypeID, isIUO, isVariadic,
3088-
isAutoClosure, rawDefaultArg);
3089+
isAutoClosure, isIsolated,
3090+
rawDefaultArg);
30893091

30903092
auto argName = MF.getIdentifier(argNameID);
30913093
auto paramName = MF.getIdentifier(paramNameID);
@@ -3119,6 +3121,7 @@ class DeclDeserializer {
31193121
param->setImplicitlyUnwrappedOptional(isIUO);
31203122
param->setVariadic(isVariadic);
31213123
param->setAutoClosure(isAutoClosure);
3124+
param->setIsolated(isIsolated);
31223125

31233126
// Decode the default argument kind.
31243127
// FIXME: Default argument expression, if available.

lib/Serialization/ModuleFormat.h

Lines changed: 2 additions & 1 deletion
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 = 621; // builtin protocol conformances
59+
const uint16_t SWIFTMODULE_VERSION_MINOR = 622; // 'isolated' in param decls
6060

6161
/// A standard hash seed used for all string hashes in a serialized module.
6262
///
@@ -1322,6 +1322,7 @@ namespace decls_block {
13221322
BCFixed<1>, // isIUO?
13231323
BCFixed<1>, // isVariadic?
13241324
BCFixed<1>, // isAutoClosure?
1325+
BCFixed<1>, // isIsolated?
13251326
DefaultArgumentField, // default argument kind
13261327
BCBlob // default argument text
13271328
>;

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3614,6 +3614,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
36143614
param->isImplicitlyUnwrappedOptional(),
36153615
param->isVariadic(),
36163616
param->isAutoClosure(),
3617+
param->isIsolated(),
36173618
getRawStableDefaultArgumentKind(argKind),
36183619
defaultArgumentText);
36193620

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public actor A {
2+
}
3+
4+
public struct S {
5+
public func f(a: isolated A) {
6+
}
7+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %empty-directory(%t-scratch)
3+
// RUN: %target-swift-frontend -emit-module -o %t-scratch/def_isolated~partial.swiftmodule -primary-file %S/Inputs/def_isolated.swift -module-name def_isolated -disable-availability-checking
4+
// RUN: %target-swift-frontend -merge-modules -emit-module -parse-as-library -enable-testing %t-scratch/def_isolated~partial.swiftmodule -module-name def_isolated -o %t/def_isolated.swiftmodule -disable-availability-checking
5+
// RUN: %target-swift-frontend -typecheck -I%t -verify %s -verify-ignore-unknown -disable-availability-checking
6+
7+
// REQUIRES: concurrency
8+
9+
import def_isolated
10+
11+
func test(a: A, a2: isolated A, s: S) async {
12+
await s.f(a: a)
13+
s.f(a: a) // expected-error{{expression is 'async' but is not marked with 'await'}}
14+
// expected-note@-1{{calls to instance method 'f(a:)' from outside of its actor context are implicitly asynchronous}}
15+
16+
s.f(a: a2)
17+
}

0 commit comments

Comments
 (0)