mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Further improve AvailabilityWalker changes
Access context more quickly; document each flag’s purpose; perform a faster test before a slower one.
This commit is contained in:
@@ -2311,7 +2311,7 @@ class AvailabilityWalker : public ASTWalker {
|
||||
init->isImplicit() &&
|
||||
init->getParameters()->size() == 1 &&
|
||||
init->getParameters()->get(0)->getArgumentName() ==
|
||||
DC->getASTContext().Id_rawValue;
|
||||
TC.Context.Id_rawValue;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -2604,11 +2604,11 @@ AvailabilityWalker::diagAvailability(const ValueDecl *D, SourceRange R,
|
||||
if (!isAccessorWithDeprecatedStorage)
|
||||
TC.diagnoseIfDeprecated(R, DC, D, call);
|
||||
|
||||
if (Flags.contains(DeclAvailabilityFlag::AllowPotentiallyUnavailableProtocol)
|
||||
&& isa<ProtocolDecl>(D))
|
||||
if (Flags.contains(DeclAvailabilityFlag::AllowPotentiallyUnavailable))
|
||||
return false;
|
||||
|
||||
if (Flags.contains(DeclAvailabilityFlag::AllowPotentiallyUnavailable))
|
||||
if (Flags.contains(DeclAvailabilityFlag::AllowPotentiallyUnavailableProtocol)
|
||||
&& isa<ProtocolDecl>(D))
|
||||
return false;
|
||||
|
||||
// Diagnose (and possibly signal) for potential unavailability
|
||||
|
||||
@@ -35,9 +35,21 @@ void diagAvailability(TypeChecker &TC, const Expr *E,
|
||||
DeclContext *DC);
|
||||
|
||||
enum class DeclAvailabilityFlag : uint8_t {
|
||||
/// Do not diagnose uses of protocols in versions before they were introduced.
|
||||
/// Used when type-checking protocol conformances, since conforming to a
|
||||
/// protocol that doesn't exist yet is allowed.
|
||||
AllowPotentiallyUnavailableProtocol = 1 << 0,
|
||||
|
||||
/// Diagnose uses of declarations in versions before they were introduced, but
|
||||
/// do not return true to indicate that a diagnostic was emitted.
|
||||
ContinueOnPotentialUnavailability = 1 << 1,
|
||||
|
||||
/// If a diagnostic must be emitted, use a variant indicating that the usage
|
||||
/// is inout and both the getter and setter must be available.
|
||||
ForInout = 1 << 2,
|
||||
|
||||
/// Do not diagnose uses of declarations in versions before they were
|
||||
/// introduced. Used to work around availability-checker bugs.
|
||||
AllowPotentiallyUnavailable = 1 << 3,
|
||||
};
|
||||
using DeclAvailabilityFlags = OptionSet<DeclAvailabilityFlag>;
|
||||
|
||||
Reference in New Issue
Block a user