Skip to content

Commit cbf4219

Browse files
authored
Merge pull request #72347 from rjmccall/isolated-any-implies-sendable
Make `@isolated(any)` imply `@Sendable`
2 parents daea8dc + 590643c commit cbf4219

File tree

6 files changed

+83
-80
lines changed

6 files changed

+83
-80
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3991,6 +3991,9 @@ NeverNullType TypeResolver::resolveASTFunctionType(
39913991
conventionAttr->getConventionName());
39923992
} else {
39933993
isolation = FunctionTypeIsolation::forErased();
3994+
3995+
// @isolated(any) implies @Sendable, unconditionally for now.
3996+
sendable = true;
39943997
}
39953998
break;
39963999
}

test/Distributed/distributed_actor_isolated_any.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ func takeInheritingAsyncIsolatedAny(@_inheritActorContext fn: @escaping @isolate
1616

1717
// CHECK-LABEL: sil hidden [distributed] [ossa] @$s4test2DAC0A20DistributedIsolationyyF
1818
// CHECK: // function_ref closure #1
19-
// CHECK-NEXT: [[CLOSURE_FN:%.*]] = function_ref @$s4test2DAC0A20DistributedIsolationyyFyyYacfU_ : $@convention(thin) @async (@guaranteed Optional<any Actor>, @sil_isolated @guaranteed DA) -> ()
19+
// CHECK-NEXT: [[CLOSURE_FN:%.*]] = function_ref @$s4test2DAC0A20DistributedIsolationyyFyyYaYbcfU_ : $@convention(thin) @Sendable @async (@guaranteed Optional<any Actor>, @sil_isolated @guaranteed DA) -> ()
2020
// CHECK-NEXT: [[CAPTURE:%.*]] = copy_value %0 : $DA
2121
// CHECK-NEXT: [[CAPTURE_FOR_ISOLATION:%.*]] = copy_value [[CAPTURE]] : $DA
2222
// The conformance here is special, but we don't record that in the printed SIL.
2323
// CHECK-NEXT: [[ISOLATION_OBJECT:%.*]] = init_existential_ref [[CAPTURE_FOR_ISOLATION]] : $DA : $DA, $any Actor
2424
// CHECK-NEXT: [[ISOLATION:%.*]] = enum $Optional<any Actor>, #Optional.some!enumelt, [[ISOLATION_OBJECT]] : $any Actor
2525
// CHECK-NEXT: [[CLOSURE:%.*]] = partial_apply [callee_guaranteed] [isolated_any] [[CLOSURE_FN]]([[ISOLATION]], [[CAPTURE]])
2626
// CHECK-NEXT: // function_ref
27-
// CHECK-NEXT: [[TAKE_FN:%.*]] = function_ref @$s4test30takeInheritingAsyncIsolatedAny2fnyyyYaYAc_tF
27+
// CHECK-NEXT: [[TAKE_FN:%.*]] = function_ref @$s4test30takeInheritingAsyncIsolatedAny2fnyyyYaYbYAc_tF
2828
// CHECK-NEXT: apply [[TAKE_FN]]([[CLOSURE]])
2929
// CHECK-NEXT: destroy_value [[CLOSURE]]
3030
distributed actor DA {

test/IRGen/isolated_any_metadata.sil

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ sil_stage canonical
77

88
// CHECK-LABEL: define{{.*}} swiftcc ptr @get_metadata
99
// CHECK: entry:
10-
// CHECK-ACCESSOR-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$syyYAcMa"([[INT]] 0)
10+
// CHECK-ACCESSOR-NEXT: [[T0:%.*]] = call swiftcc %swift.metadata_response @"$syyYbYAcMa"([[INT]] 0)
1111
// CHECK-ACCESSOR-NEXT: [[METADATA:%.]] = extractvalue %swift.metadata_response [[T0]], 0
12-
// CHECK-DEMANGLE: [[METADATA:%.*]] = call ptr @__swift_instantiateConcreteTypeFromMangledName(ptr @"$syyYAcMD")
12+
// CHECK-DEMANGLE: [[METADATA:%.*]] = call ptr @__swift_instantiateConcreteTypeFromMangledName(ptr @"$syyYbYAcMD")
1313
// CHECK-NEXT: ret ptr [[METADATA]]
1414
sil @get_metadata : $() -> @thick Any.Type {
1515
entry:
@@ -18,7 +18,7 @@ entry:
1818
return %result : $@thick Any.Type
1919
}
2020

21-
// CHECK-ACCESSOR-LABEL: define{{.*}} swiftcc %swift.metadata_response @"$syyYAcMa"
22-
// 2214592512 == 0x84000000 == (ExtendedFlags | Escaping)
21+
// CHECK-ACCESSOR-LABEL: define{{.*}} swiftcc %swift.metadata_response @"$syyYbYAcMa"
22+
// 3288334336 == 0xc4000000 == (ExtendedFlags | Sendable | Escaping)
2323
// 2 == IsolatedAny
24-
// CHECK-ACCESSOR: call ptr @swift_getExtendedFunctionTypeMetadata([[INT]] 2214592512, [[INT]] 0, ptr null, ptr null, ptr getelementptr inbounds {{.*}} @"$sytN"{{.*}}), ptr null, i32 2, ptr null)
24+
// CHECK-ACCESSOR: call ptr @swift_getExtendedFunctionTypeMetadata([[INT]] 3288334336, [[INT]] 0, ptr null, ptr null, ptr getelementptr inbounds {{.*}} @"$sytN"{{.*}}), ptr null, i32 2, ptr null)

test/ModuleInterface/isolated_any_suppression.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
// RUN: %target-swift-frontend -swift-version 5 -enable-library-evolution -module-name isolated_any -emit-module -o %t/isolated_any.swiftmodule -emit-module-interface-path - -enable-experimental-feature IsolatedAny %s | %FileCheck %s
44

55
// CHECK: #if compiler(>=5.3) && $IsolatedAny
6-
// CHECK-NEXT: {{^}}public func test1(fn: @isolated(any) () -> ())
6+
// CHECK-NEXT: {{^}}public func test1(fn: @isolated(any) @Sendable () -> ())
77
// CHECK-NEXT: #endif
88
public func test1(fn: @isolated(any) () -> ()) {}
99

1010
// CHECK-NEXT: #if compiler(>=5.3) && $IsolatedAny
11-
// CHECK-NEXT: {{^}}public func test2(fn: @isolated(any) () -> ())
11+
// CHECK-NEXT: {{^}}public func test2(fn: @isolated(any) @Sendable () -> ())
1212
// CHECK-NEXT: #endif
1313
@_allowFeatureSuppression(XXX)
1414
public func test2(fn: @isolated(any) () -> ()) {}
1515

1616
// CHECK-NEXT: #if compiler(>=5.3) && $IsolatedAny
17-
// CHECK-NEXT: {{^}}public func test3(fn: @isolated(any) () -> ())
17+
// CHECK-NEXT: {{^}}public func test3(fn: @isolated(any) @Sendable () -> ())
1818
// CHECK-NEXT: #else
19-
// CHECK-NEXT: {{^}}public func test3(fn: () -> ())
19+
// CHECK-NEXT: {{^}}public func test3(fn: @Sendable () -> ())
2020
// CHECK-NEXT: #endif
2121
@_allowFeatureSuppression(IsolatedAny)
2222
public func test3(fn: @isolated(any) () -> ()) {}

0 commit comments

Comments
 (0)