mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #77057 from sophiapoirier/preconcurrency_import_warning_for_suppressed_sendable_diagnostic
[Concurrency] fix erroneous "@preconcurrency import" diagnostic
This commit is contained in:
@@ -4263,13 +4263,17 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
|
|||||||
diagnoseSendabilityErrorBasedOn(conformance->getProtocol(), sendFrom,
|
diagnoseSendabilityErrorBasedOn(conformance->getProtocol(), sendFrom,
|
||||||
[&](DiagnosticBehavior limit) {
|
[&](DiagnosticBehavior limit) {
|
||||||
auto &diags = DC->getASTContext().Diags;
|
auto &diags = DC->getASTContext().Diags;
|
||||||
diags.diagnose(getLocForDiagnosingWitness(conformance, witness),
|
auto preconcurrencyBehaviorLimit =
|
||||||
diag::witness_not_as_sendable,
|
sendFrom.preconcurrencyBehavior(nominal);
|
||||||
witness, conformance->getProtocol())
|
diags
|
||||||
|
.diagnose(getLocForDiagnosingWitness(conformance, witness),
|
||||||
|
diag::witness_not_as_sendable, witness,
|
||||||
|
conformance->getProtocol())
|
||||||
.limitBehaviorUntilSwiftVersion(limit, 6)
|
.limitBehaviorUntilSwiftVersion(limit, 6)
|
||||||
.limitBehaviorIf(sendFrom.preconcurrencyBehavior(nominal));
|
.limitBehaviorIf(preconcurrencyBehaviorLimit);
|
||||||
diags.diagnose(requirement, diag::less_sendable_reqt_here);
|
diags.diagnose(requirement, diag::less_sendable_reqt_here);
|
||||||
return false;
|
return preconcurrencyBehaviorLimit &&
|
||||||
|
(*preconcurrencyBehaviorLimit == DiagnosticBehavior::Ignore);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,3 +204,16 @@ public struct TestSendableWitnesses2 : NoSendableReqs {
|
|||||||
var prop = globalFn // Ok (no warnings)
|
var prop = globalFn // Ok (no warnings)
|
||||||
static let staticProp = globalFn // Ok (no warnings)
|
static let staticProp = globalFn // Ok (no warnings)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @preconcurrency attributes to make it akin to an imported Obj-C API
|
||||||
|
@preconcurrency @MainActor public protocol EscapingSendableProtocol {
|
||||||
|
// expected-complete-and-tns-note @+1 {{protocol requires function 'f(handler:)' with type '(@escaping @MainActor @Sendable (Int) -> Void) -> ()'}}
|
||||||
|
@preconcurrency func f(handler: @escaping @MainActor @Sendable (Int) -> Void)
|
||||||
|
}
|
||||||
|
|
||||||
|
// expected-complete-and-tns-error @+2 {{type 'TestEscapingOnly' does not conform to protocol 'EscapingSendableProtocol'}}
|
||||||
|
// expected-complete-and-tns-note @+1 {{add stubs for conformance}}
|
||||||
|
class TestEscapingOnly: EscapingSendableProtocol {
|
||||||
|
// expected-complete-and-tns-note @+1 {{candidate has non-matching type '(@escaping (Int) -> Void) -> ()'}}
|
||||||
|
func f(handler: @escaping (Int) -> Void) {}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user