File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -4263,13 +4263,17 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
4263
4263
diagnoseSendabilityErrorBasedOn (conformance->getProtocol (), sendFrom,
4264
4264
[&](DiagnosticBehavior limit) {
4265
4265
auto &diags = DC->getASTContext ().Diags ;
4266
- diags.diagnose (getLocForDiagnosingWitness (conformance, witness),
4267
- diag::witness_not_as_sendable,
4268
- witness, conformance->getProtocol ())
4266
+ auto preconcurrencyBehaviorLimit =
4267
+ sendFrom.preconcurrencyBehavior (nominal);
4268
+ diags
4269
+ .diagnose (getLocForDiagnosingWitness (conformance, witness),
4270
+ diag::witness_not_as_sendable, witness,
4271
+ conformance->getProtocol ())
4269
4272
.limitBehaviorUntilSwiftVersion (limit, 6 )
4270
- .limitBehaviorIf (sendFrom. preconcurrencyBehavior (nominal) );
4273
+ .limitBehaviorIf (preconcurrencyBehaviorLimit );
4271
4274
diags.diagnose (requirement, diag::less_sendable_reqt_here);
4272
- return false ;
4275
+ return preconcurrencyBehaviorLimit &&
4276
+ (*preconcurrencyBehaviorLimit == DiagnosticBehavior::Ignore);
4273
4277
});
4274
4278
});
4275
4279
}
Original file line number Diff line number Diff line change @@ -204,3 +204,16 @@ public struct TestSendableWitnesses2 : NoSendableReqs {
204
204
var prop = globalFn // Ok (no warnings)
205
205
static let staticProp = globalFn // Ok (no warnings)
206
206
}
207
+
208
+ // @preconcurrency attributes to make it akin to an imported Obj-C API
209
+ @preconcurrency @MainActor public protocol EscapingSendableProtocol {
210
+ // expected-complete-and-tns-note @+1 {{protocol requires function 'f(handler:)' with type '(@escaping @MainActor @Sendable (Int) -> Void) -> ()'}}
211
+ @preconcurrency func f( handler: @escaping @MainActor @Sendable ( Int ) -> Void )
212
+ }
213
+
214
+ // expected-complete-and-tns-error @+2 {{type 'TestEscapingOnly' does not conform to protocol 'EscapingSendableProtocol'}}
215
+ // expected-complete-and-tns-note @+1 {{add stubs for conformance}}
216
+ class TestEscapingOnly : EscapingSendableProtocol {
217
+ // expected-complete-and-tns-note @+1 {{candidate has non-matching type '(@escaping (Int) -> Void) -> ()'}}
218
+ func f( handler: @escaping ( Int ) -> Void ) { }
219
+ }
You can’t perform that action at this time.
0 commit comments