Skip to content

Commit 655f35c

Browse files
committed
Separate the "set for caching" and "set programmatically" for storage impl info
Slightly cleanup, and make an assertion less strict in the face of invalid code.
1 parent e3ac3c0 commit 655f35c

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

include/swift/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5295,6 +5295,9 @@ class AbstractStorageDecl : public ValueDecl {
52955295
/// used carefully.
52965296
void setImplInfo(StorageImplInfo implInfo);
52975297

5298+
/// Cache the implementation-info, for use by the request-evaluator.
5299+
void cacheImplInfo(StorageImplInfo implInfo);
5300+
52985301
ReadImplKind getReadImpl() const {
52995302
return getImplInfo().getReadImpl();
53005303
}

lib/AST/Decl.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,7 +2525,7 @@ AbstractStorageDecl::getAccessStrategy(AccessSemantics semantics,
25252525
ResilienceExpansion expansion) const {
25262526
switch (semantics) {
25272527
case AccessSemantics::DirectToStorage:
2528-
assert(hasStorage());
2528+
assert(hasStorage() || getASTContext().Diags.hadAnyError());
25292529
return AccessStrategy::getStorage();
25302530

25312531
case AccessSemantics::DistributedThunk:
@@ -6407,15 +6407,23 @@ StorageImplInfo AbstractStorageDecl::getImplInfo() const {
64076407
StorageImplInfo::getSimpleStored(StorageIsMutable));
64086408
}
64096409

6410-
void AbstractStorageDecl::setImplInfo(StorageImplInfo implInfo) {
6410+
void AbstractStorageDecl::cacheImplInfo(StorageImplInfo implInfo) {
64116411
LazySemanticInfo.ImplInfoComputed = 1;
64126412
ImplInfo = implInfo;
6413+
}
6414+
6415+
void AbstractStorageDecl::setImplInfo(StorageImplInfo implInfo) {
6416+
cacheImplInfo(implInfo);
64136417

64146418
if (isImplicit()) {
64156419
auto &evaluator = getASTContext().evaluator;
64166420
HasStorageRequest request{this};
64176421
if (!evaluator.hasCachedResult(request))
64186422
evaluator.cacheOutput(request, implInfo.hasStorage());
6423+
else {
6424+
assert(
6425+
evaluateOrDefault(evaluator, request, false) == implInfo.hasStorage());
6426+
}
64196427
}
64206428
}
64216429

lib/AST/TypeCheckRequests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ StorageImplInfoRequest::getCachedResult() const {
687687

688688
void StorageImplInfoRequest::cacheResult(StorageImplInfo value) const {
689689
auto *storage = std::get<0>(getStorage());
690-
storage->setImplInfo(value);
690+
storage->cacheImplInfo(value);
691691
}
692692

693693
//----------------------------------------------------------------------------//

0 commit comments

Comments
 (0)