Skip to content

Commit 25c9084

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents ea098b6 + cc17c04 commit 25c9084

File tree

9 files changed

+81
-29
lines changed

9 files changed

+81
-29
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ root = true
66
indent_style = space
77
indent_size = 2
88
insert_final_newline = true
9+
10+
[*.py]
11+
indent_size = 4

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8735,11 +8735,6 @@ ERROR(execution_behavior_incompatible_isolated_parameter,none,
87358735
"an isolated parameter: %2",
87368736
(DeclAttribute, ValueDecl *, ValueDecl *))
87378737

8738-
ERROR(execution_behavior_incompatible_dynamically_isolated_parameter,none,
8739-
"cannot use %0 on %kind1 because it has "
8740-
"a dynamically isolated parameter: %2",
8741-
(DeclAttribute, ValueDecl *, ValueDecl *))
8742-
87438738
ERROR(execution_behavior_attr_incompatible_with_global_isolation,none,
87448739
"cannot use %0 because function type is isolated to a global actor %1",
87458740
(DeclAttribute, Type))

lib/Sema/TypeCheckAttr.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
230230
attr, decl, P);
231231
return;
232232
}
233-
234-
if (auto *attrType = dyn_cast<AttributedTypeRepr>(repr)) {
235-
if (attrType->has(TypeAttrKind::Isolated)) {
236-
diagnoseAndRemoveAttr(
237-
attr,
238-
diag::
239-
execution_behavior_incompatible_dynamically_isolated_parameter,
240-
attr, decl, P);
241-
return;
242-
}
243-
}
244233
}
245234
}
246235

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,11 +1052,17 @@ bool swift::diagnoseNonSendableTypes(
10521052
Type type, SendableCheckContext fromContext,
10531053
Type inDerivedConformance, SourceLoc loc,
10541054
llvm::function_ref<bool(Type, DiagnosticBehavior)> diagnose) {
1055+
auto &ctx = type->getASTContext();
1056+
10551057
// If the Sendable protocol is missing, do nothing.
1056-
auto proto = type->getASTContext().getProtocol(KnownProtocolKind::Sendable);
1058+
auto proto = ctx.getProtocol(KnownProtocolKind::Sendable);
10571059
if (!proto)
10581060
return false;
10591061

1062+
// Unwrap pack expansions here to allow packs of Sendable type.
1063+
if (auto *expansion = type->getAs<PackExpansionType>())
1064+
type = PackType::get(ctx, {expansion});
1065+
10601066
// FIXME: More detail for unavailable conformances.
10611067
auto conformance = lookupConformance(type, proto, /*allowMissing=*/true);
10621068
if (conformance.isInvalid() || conformance.hasUnavailableConformance()) {
@@ -3055,12 +3061,6 @@ namespace {
30553061
->mapTypeIntoContext(decl->getInterfaceType())
30563062
->getReferenceStorageReferent();
30573063

3058-
// Pack expansions are okay to capture as long as the pattern
3059-
// type is Sendable.
3060-
if (auto *expansion = type->getAs<PackExpansionType>()) {
3061-
type = expansion->getPatternType();
3062-
}
3063-
30643064
if (type->hasError())
30653065
continue;
30663066

stdlib/public/core/SIMDFloatConcreteOperations.swift.gyb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ compares = [
122122
/// result[i] = (a[i] ${op} b)
123123
/// }
124124
/// ```
125-
@_alwaysEmitIntoClient @_transparent
125+
@_alwaysEmitIntoClient @_transparent @_disfavoredOverload
126126
public static func .${op}(a: Self, b: Scalar) -> SIMDMask<MaskStorage> {
127127
a .${op} Self(repeating: b)
128128
}
@@ -139,7 +139,7 @@ compares = [
139139
/// result[i] = (a ${op} b[i])
140140
/// }
141141
/// ```
142-
@_alwaysEmitIntoClient @_transparent
142+
@_alwaysEmitIntoClient @_transparent @_disfavoredOverload
143143
public static func .${op}(a: Scalar, b: Self) -> SIMDMask<MaskStorage> {
144144
Self(repeating: a) .${op} b
145145
}

test/Concurrency/sendable_checking.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,27 @@ func test(value: (_: Int, _: () -> Void)) {
534534
takesSendable(value.1) // Ok
535535
// expected-warning@-1 {{converting non-Sendable function value to '@Sendable () -> Void' may introduce data races}}
536536
}
537+
538+
// Don't forget about parameter packs -- https://github.com/swiftlang/swift/issues/82614
539+
540+
@available(SwiftStdlib 5.1, *)
541+
protocol PackProto {
542+
func foo<each A: Sendable>(_ a: repeat each A) async
543+
func bar<each A>(_ a: repeat each A) async
544+
// expected-note@-1 {{consider making generic parameter 'each A' conform to the 'Sendable' protocol}}
545+
}
546+
547+
@available(SwiftStdlib 5.1, *)
548+
actor PackActor: PackProto {
549+
func foo<each A: Sendable>(_ a: repeat each A) async {
550+
for b in repeat (each a) {
551+
print(b)
552+
}
553+
}
554+
func bar<each A>(_ a: repeat each A) async {
555+
// expected-warning@-1 {{non-Sendable parameter type 'repeat each A' cannot be sent from caller of protocol requirement 'bar' into actor-isolated implementation; this is an error in the Swift 6 language mode}}
556+
for b in repeat (each a) {
557+
print(b)
558+
}
559+
}
560+
}

test/IRGen/ptrauth-protocols.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bb0:
7575
// Fetch T.Assoc : P.
7676
// CHECK-NEXT: %T.Assoc.P = call swiftcc ptr @swift_getAssociatedConformanceWitness(ptr %T.Q, ptr %T, ptr [[T_ASSOC]]
7777
// Fetch T.Assoc.foo
78-
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds ptr, ptr %T.Assoc.P, i32 1
78+
// CHECK: [[T0:%.*]] = getelementptr inbounds ptr, ptr %T.Assoc.P, i32 1
7979
// CHECK-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]], align 8
8080
// CHECK-NEXT: [[T2:%.*]] = ptrtoint ptr [[T0]] to i64
8181
// CHECK-NEXT: [[DISC:%.*]] = call i64 @llvm.ptrauth.blend(i64 [[T2]], i64 53700)

test/SILGen/execution_attr.swift

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// REQUIRES: swift_feature_NonisolatedNonsendingByDefault
66

77
// Validate that both with and without the experimental flag we properly codegen
8-
// execution(caller) and execution(concurrent).
8+
// `@concurrent` and `nonisolated(nonsending)`
99

1010
// CHECK-LABEL: // executionCaller()
1111
// CHECK-NEXT: // Isolation: caller_isolation_inheriting
@@ -62,3 +62,36 @@ extension S {
6262
// CHECK: sil hidden [ossa] @$s14execution_attr1SV0A17CallerFieldMethodyyyyYaYCXEF : $@convention(method) (@guaranteed @noescape @async @callee_guaranteed (@sil_isolated @sil_implicit_leading_param @guaranteed Optional<any Actor>) -> (), @guaranteed S) -> () {
6363
func executionCallerFieldMethod(_ x: nonisolated(nonsending) () async -> ()) {}
6464
}
65+
66+
// CHECK-LABEL: sil hidden [ossa] @$s14execution_attr24testWithDynamicIsolation2fnyyyYAXE_tYaF : $@convention(thin) @async (@guaranteed @isolated(any) @noescape @callee_guaranteed () -> ()) -> () {
67+
// CHECK: bb0([[PARAM_FN:%.*]] : @guaranteed $@isolated(any) @noescape @callee_guaranteed () -> ()):
68+
// CHECK: [[GENERIC_EXEC:%.*]] = enum $Optional<Builtin.Executor>, #Optional.none!enumelt
69+
// CHECK-NEXT: hop_to_executor [[GENERIC_EXEC]]
70+
// CHECK-NEXT: [[FN:%.*]] = copy_value [[PARAM_FN]]
71+
// CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]]
72+
// CHECK-NEXT: [[FN_ISOLATION:%.*]] = function_extract_isolation [[BORROWED_FN]]
73+
// CHECK-NEXT: hop_to_executor [[FN_ISOLATION]]
74+
// CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]]
75+
// CHECK-NEXT: apply [[BORROWED_FN]]()
76+
// CHECK: hop_to_executor [[GENERIC_EXEC]]
77+
// CHECK: } // end sil function '$s14execution_attr24testWithDynamicIsolation2fnyyyYAXE_tYaF'
78+
@concurrent
79+
func testWithDynamicIsolation(fn: @isolated(any) () -> Void) async {
80+
await fn()
81+
}
82+
83+
// CHECK-LABEL: sil hidden [ossa] @$s14execution_attr38testCallerIsolatedWithDynamicIsolation2fnyyyYAXE_tYaF : $@convention(thin) @async (@sil_isolated @sil_implicit_leading_param @guaranteed Optional<any Actor>, @guaranteed @isolated(any) @noescape @callee_guaranteed () -> ()) -> () {
84+
// CHECK: bb0([[ISOLATION:%.*]] : @guaranteed $Optional<any Actor>, [[PARAM_FN:%.*]] : @guaranteed $@isolated(any) @noescape @callee_guaranteed () -> ()):
85+
// CHECK: hop_to_executor [[ISOLATION]]
86+
// CHECK-NEXT: [[FN:%.*]] = copy_value [[PARAM_FN]]
87+
// CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]]
88+
// CHECK-NEXT: [[FN_ISOLATION:%.*]] = function_extract_isolation [[BORROWED_FN]]
89+
// CHECK-NEXT: hop_to_executor [[FN_ISOLATION]]
90+
// CHECK-NEXT: [[BORROWED_FN:%.*]] = begin_borrow [[FN]]
91+
// CHECK-NEXT: apply [[BORROWED_FN]]()
92+
// CHECK: hop_to_executor [[ISOLATION]]
93+
// CHECK: } // end sil function '$s14execution_attr38testCallerIsolatedWithDynamicIsolation2fnyyyYAXE_tYaF'
94+
nonisolated(nonsending)
95+
func testCallerIsolatedWithDynamicIsolation(fn: @isolated(any) () -> Void) async {
96+
await fn()
97+
}

test/attr/execution_behavior_attrs.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ struct TestAttributeCollisions {
9494
}
9595

9696
@concurrent func testIsolationAny(arg: @isolated(any) () -> Void) async {}
97-
// expected-error@-1 {{cannot use @concurrent on instance method 'testIsolationAny(arg:)' because it has a dynamically isolated parameter: 'arg'}}
9897
@concurrent subscript(testIsolationAny arg: @isolated(any) () -> Void) -> Int {
99-
// expected-error@-1 {{cannot use @concurrent on subscript 'subscript(testIsolationAny:)' because it has a dynamically isolated parameter: 'arg'}}
10098
get async {}
10199
}
102100

@@ -158,3 +156,13 @@ do {
158156
})
159157
}
160158
}
159+
160+
do {
161+
nonisolated(nonsending)
162+
func testOnDecl(_: @isolated(any) () -> Void) async {} // Ok
163+
164+
func testOnType1(_: nonisolated(nonsending) @isolated(any) () async -> Void) {}
165+
// expected-error@-1 {{cannot use 'nonisolated(nonsending)' together with '@isolated(any)'}}
166+
func testOnType2(_: @concurrent @isolated(any) () async -> Void) {}
167+
// expected-error@-1 {{cannot use '@concurrent' together with '@isolated(any)'}}
168+
}

0 commit comments

Comments
 (0)