mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Implement customizable Sendable conformance diagnostics.
Rework Sendable checking to be completely based on "missing" conformances, so that we can individually diagnose missing Sendable conformances based on both the module in which the conformance check happened as well as where the type was declared. The basic rules here are to only diagnose if either the module where the non-Sendable type was declared or the module where it was checked was compiled with a mode that consistently diagnoses `Sendable`, either by virtue of being Swift 6 or because `-warn-concurrency` was provided on the command line. And have that diagnostic be an error in Swift 6 or warning in Swift 5.x. There is much tuning to be done here.
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
#include "swift/Basic/Debug.h"
|
||||
#include "llvm/ADT/Hashing.h"
|
||||
#include "llvm/ADT/PointerUnion.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "swift/AST/ProtocolConformanceRef.h"
|
||||
#include "swift/AST/Requirement.h"
|
||||
#include "swift/AST/TypeAlignments.h"
|
||||
#include "swift/AST/Type.h"
|
||||
@@ -29,6 +31,7 @@ namespace llvm {
|
||||
|
||||
namespace swift {
|
||||
|
||||
class BuiltinProtocolConformance;
|
||||
class ConcreteDeclRef;
|
||||
class ProtocolConformance;
|
||||
enum class EffectKind : uint8_t;
|
||||
@@ -72,6 +75,11 @@ public:
|
||||
return ProtocolConformanceRef();
|
||||
}
|
||||
|
||||
/// Retrieve an invalid or missing conformance, as appropriate, when a
|
||||
/// legitimate conformance doesn't exist.
|
||||
static ProtocolConformanceRef forMissingOrInvalid(
|
||||
Type type, ProtocolDecl *proto);
|
||||
|
||||
bool isInvalid() const {
|
||||
return !Union;
|
||||
}
|
||||
@@ -103,6 +111,19 @@ public:
|
||||
/// cannot be depended on to always exist.
|
||||
bool hasMissingConformance(ModuleDecl *module) const;
|
||||
|
||||
/// Enumerate the missing conformances in this conformance.
|
||||
///
|
||||
/// Calls \c fn with each missing conformance found within this conformance,
|
||||
/// including this conformance or any conditional conformances it depends on.
|
||||
/// If the invocation of \c fn returns \c true, the traversal exits early
|
||||
/// and the overall function returns \c true.
|
||||
///
|
||||
/// \returns \c true if any invocation of \c fn returned true,
|
||||
/// \c false otherwise.
|
||||
bool forEachMissingConformance(
|
||||
ModuleDecl *module,
|
||||
llvm::function_ref<bool(BuiltinProtocolConformance *missing)> fn) const;
|
||||
|
||||
using OpaqueValue = void*;
|
||||
OpaqueValue getOpaqueValue() const { return Union.getOpaqueValue(); }
|
||||
static ProtocolConformanceRef getFromOpaqueValue(OpaqueValue value) {
|
||||
|
||||
Reference in New Issue
Block a user