Skip to content

Commit f633505

Browse files
committed
fix to check all parameters
1 parent 5a6d928 commit f633505

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,10 +1166,11 @@ bool swift::diagnoseNonSendableTypesInReference(
11661166
if (funcCheckOptions.contains(FunctionCheckKind::Params)) {
11671167
// only check params if funcCheckKind specifies so
11681168
for (auto param : *function->getParameters()) {
1169-
if (param->isSending())
1170-
return true;
1171-
11721169
Type paramType = param->getInterfaceType().subst(subs);
1170+
if (param->isSending() && !paramType->hasError()) {
1171+
continue;
1172+
}
1173+
11731174
if (diagnoseNonSendableTypes(
11741175
paramType, fromDC, derivedConformanceType,
11751176
refLoc, diagnoseLoc.isInvalid() ? refLoc : diagnoseLoc,

test/Sema/issue-76710.swift

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class NonSendableKlass1 {}
66

77
protocol P1 {
8-
func bar(_ a: sending NonSendableKlass1) async -> sending NonSendableKlass1
8+
func bar(_ a: sending NonSendableKlass1) async -> sending NonSendableKlass1
99
}
1010

1111
@MainActor
@@ -50,3 +50,27 @@ actor P4Actor: P4 {
5050
// expected-error@-2 {{non-sendable parameter type 'NonSendableKlass4' cannot be sent from caller of protocol requirement 'bar' into actor-isolated implementation}}
5151
}
5252

53+
class NonSendableKlass5 {}
54+
// expected-note@-1 {{class 'NonSendableKlass5' does not conform to the 'Sendable' protocol}}
55+
56+
57+
protocol P5 {
58+
func bar(_ a: sending NonSendableKlass5, _ b: NonSendableKlass5) async -> sending NonSendableKlass5
59+
}
60+
61+
@MainActor
62+
class P5Class: P5 {
63+
func bar(_ a: sending NonSendableKlass5, _ b: NonSendableKlass5) async -> sending NonSendableKlass5 { a }
64+
// expected-error@-1 {{non-sendable parameter type 'NonSendableKlass5' cannot be sent from caller of protocol requirement 'bar' into main actor-isolated implementation}}
65+
}
66+
67+
class NonSendableKlass6 {}
68+
69+
protocol P6 {
70+
func bar(_ a: sending NonSendableKlass6, _ b: sending NonSendableKlass6) async -> sending NonSendableKlass6
71+
}
72+
73+
@MainActor
74+
class P6Class: P6 {
75+
func bar(_ a: sending NonSendableKlass6, _ b: sending NonSendableKlass6) async -> sending NonSendableKlass6 { a }
76+
}

0 commit comments

Comments
 (0)