Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/swift/Sema/ConstraintSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -2401,6 +2401,10 @@ class ConstraintSystem {
llvm::DenseMap<std::pair<TypeBase *, ProtocolDecl *>, ProtocolConformanceRef>
Conformances;

/// A cache for unavailability checks peformed by the solver.
llvm::DenseMap<std::pair<const Decl *, ConstraintLocator *>, bool>
UnavailableDecls;

/// The list of all generic requirements fixed along the current
/// solver path.
using FixedRequirement =
Expand Down
9 changes: 8 additions & 1 deletion lib/Sema/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4810,13 +4810,20 @@ void ConstraintSystem::diagnoseFailureFor(SyntacticElementTarget target) {

bool ConstraintSystem::isDeclUnavailable(const Decl *D,
ConstraintLocator *locator) const {
auto found = UnavailableDecls.find(std::make_pair(D, locator));
if (found != UnavailableDecls.end())
return found->second;

SourceLoc loc;
if (locator) {
if (auto anchor = locator->getAnchor())
loc = getLoc(anchor);
}

return getUnsatisfiedAvailabilityConstraint(D, DC, loc).has_value();
auto result = getUnsatisfiedAvailabilityConstraint(D, DC, loc).has_value();
const_cast<ConstraintSystem *>(this)->UnavailableDecls.insert(
std::make_pair(std::make_pair(D, locator), result));
return result;
}

bool ConstraintSystem::isConformanceUnavailable(ProtocolConformanceRef conformance,
Expand Down