mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #82276 from xedin/rdar-152689053-6.2
[6.2][Concurrency] NonisolatedNonsendingByDefault: Except `@Test` test-cases and `$` prefixed declarations from migration
This commit is contained in:
@@ -362,7 +362,7 @@ public:
|
||||
}
|
||||
|
||||
bool hasDollarPrefix() const {
|
||||
return getIdentifier().hasDollarPrefix();
|
||||
return !isSpecial() && getIdentifier().hasDollarPrefix();
|
||||
}
|
||||
|
||||
/// A representation of the name to be displayed to users. May be ambiguous
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "swift/AST/Decl.h"
|
||||
#include "swift/AST/DiagnosticsSema.h"
|
||||
#include "swift/AST/Expr.h"
|
||||
#include "swift/AST/Module.h"
|
||||
#include "swift/AST/ParameterList.h"
|
||||
#include "swift/AST/TypeRepr.h"
|
||||
#include "swift/Basic/Assertions.h"
|
||||
@@ -55,6 +56,27 @@ public:
|
||||
/// behavior.
|
||||
void diagnose() const;
|
||||
};
|
||||
|
||||
/// Determine whether the decl represents a test function that is
|
||||
/// annotated with `@Test` macro from the swift-testing framework.
|
||||
/// Such functions should be exempt from the migration because their
|
||||
/// execution is controlled by the framework and the change in
|
||||
/// behavior doesn't affect them.
|
||||
static bool isSwiftTestingTestFunction(ValueDecl *decl) {
|
||||
if (!isa<FuncDecl>(decl))
|
||||
return false;
|
||||
|
||||
return llvm::any_of(decl->getAttrs(), [&decl](DeclAttribute *attr) {
|
||||
auto customAttr = dyn_cast<CustomAttr>(attr);
|
||||
if (!customAttr)
|
||||
return false;
|
||||
|
||||
auto *macro = decl->getResolvedMacro(customAttr);
|
||||
return macro && macro->getBaseIdentifier().is("Test") &&
|
||||
macro->getParentModule()->getName().is("Testing");
|
||||
});
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
void NonisolatedNonsendingByDefaultMigrationTarget::diagnose() const {
|
||||
@@ -78,6 +100,17 @@ void NonisolatedNonsendingByDefaultMigrationTarget::diagnose() const {
|
||||
return;
|
||||
}
|
||||
|
||||
// `@Test` test-case have special semantics.
|
||||
if (isSwiftTestingTestFunction(decl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A special declaration that was either synthesized by the compiler
|
||||
// or a macro expansion.
|
||||
if (decl->getBaseName().hasDollarPrefix()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the attribute cannot appear on this kind of declaration, we can't
|
||||
// diagnose it.
|
||||
if (!DeclAttribute::canAttributeAppearOnDecl(DeclAttrKind::Concurrent,
|
||||
|
||||
Reference in New Issue
Block a user