mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Concurrency] Diagnose mutating accesses to locals from concurrent code.
Replace the existing warning about any access to a local variable from concurrently-executing code with a more tailored error: concurrently-executing code may read a mutable varable, but cannot modify it. This is safe so long as we either always do by-value captures in concurrent closures or we ensure that no mutation of that variable can occur after the point of capture. We'll follow up with one of those. For now... be careful out there. Since we're promoting this to an error, narrow it down to concurrent closures and local functions, dropping the assumption that escaping closures "may execute concurrently."
This commit is contained in:
@@ -181,6 +181,17 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Whether this function is @concurrent.
|
||||
bool isConcurrent() const {
|
||||
if (!hasType())
|
||||
return false;
|
||||
|
||||
if (auto *fnType = getType()->getAs<AnyFunctionType>())
|
||||
return fnType->isConcurrent();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isObjC() const {
|
||||
if (auto afd = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
|
||||
return afd->isObjC();
|
||||
|
||||
Reference in New Issue
Block a user