Skip to content

Commit c6077ee

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 9a88803 commit c6077ee

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
@@ -5297,6 +5297,9 @@ class AbstractStorageDecl : public ValueDecl {
52975297
/// used carefully.
52985298
void setImplInfo(StorageImplInfo implInfo);
52995299

5300+
/// Cache the implementation-info, for use by the request-evaluator.
5301+
void cacheImplInfo(StorageImplInfo implInfo);
5302+
53005303
ReadImplKind getReadImpl() const {
53015304
return getImplInfo().getReadImpl();
53025305
}

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:
@@ -6398,15 +6398,23 @@ StorageImplInfo AbstractStorageDecl::getImplInfo() const {
63986398
StorageImplInfo::getSimpleStored(StorageIsMutable));
63996399
}
64006400

6401-
void AbstractStorageDecl::setImplInfo(StorageImplInfo implInfo) {
6401+
void AbstractStorageDecl::cacheImplInfo(StorageImplInfo implInfo) {
64026402
LazySemanticInfo.ImplInfoComputed = 1;
64036403
ImplInfo = implInfo;
6404+
}
6405+
6406+
void AbstractStorageDecl::setImplInfo(StorageImplInfo implInfo) {
6407+
cacheImplInfo(implInfo);
64046408

64056409
if (isImplicit()) {
64066410
auto &evaluator = getASTContext().evaluator;
64076411
HasStorageRequest request{this};
64086412
if (!evaluator.hasCachedResult(request))
64096413
evaluator.cacheOutput(request, implInfo.hasStorage());
6414+
else {
6415+
assert(
6416+
evaluateOrDefault(evaluator, request, false) == implInfo.hasStorage());
6417+
}
64106418
}
64116419
}
64126420

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)