Skip to content

Commit ecc9e32

Browse files
committed
Sema: Remove validateAbstractStorageDecl()
Validating a variable or subscript no longer forces accessor synthesis.
1 parent 15a8316 commit ecc9e32

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,10 @@ void TypeChecker::synthesizeWitnessAccessorsForStorage(
14041404
AbstractStorageDecl *storage) {
14051405
bool addedAccessor = false;
14061406

1407+
// Make sure the protocol requirement itself has the right accessors.
1408+
// FIXME: This should be a request kicked off by SILGen.
1409+
DeclsToFinalize.insert(requirement);
1410+
14071411
requirement->visitExpectedOpaqueAccessors([&](AccessorKind kind) {
14081412
// If the accessor already exists, we have nothing to do.
14091413
if (storage->getAccessor(kind))

lib/Sema/TypeCheckDecl.cpp

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,19 +2153,6 @@ OpaqueReadOwnershipRequest::evaluate(Evaluator &evaluator,
21532153
: OpaqueReadOwnership::Owned);
21542154
}
21552155

2156-
static void validateAbstractStorageDecl(TypeChecker &TC,
2157-
AbstractStorageDecl *storage) {
2158-
if (storage->getOpaqueResultTypeDecl()) {
2159-
if (auto sf = storage->getInnermostDeclContext()->getParentSourceFile()) {
2160-
sf->markDeclWithOpaqueResultTypeAsValidated(storage);
2161-
}
2162-
}
2163-
2164-
// Everything else about the accessors can wait until finalization.
2165-
// This will validate all the accessors.
2166-
TC.DeclsToFinalize.insert(storage);
2167-
}
2168-
21692156
/// Check the requirements in the where clause of the given \c source
21702157
/// to ensure that they don't introduce additional 'Self' requirements.
21712158
static void checkProtocolSelfRequirements(ProtocolDecl *proto,
@@ -3975,8 +3962,11 @@ void TypeChecker::validateDecl(ValueDecl *D) {
39753962
checkDeclAttributesEarly(VD);
39763963
validateAttributes(*this, VD);
39773964

3978-
// Perform accessor-related validation.
3979-
validateAbstractStorageDecl(*this, VD);
3965+
if (VD->getOpaqueResultTypeDecl()) {
3966+
if (auto SF = VD->getInnermostDeclContext()->getParentSourceFile()) {
3967+
SF->markDeclWithOpaqueResultTypeAsValidated(VD);
3968+
}
3969+
}
39803970

39813971
break;
39823972
}
@@ -4254,7 +4244,11 @@ void TypeChecker::validateDecl(ValueDecl *D) {
42544244
}
42554245

42564246
// Perform accessor-related validation.
4257-
validateAbstractStorageDecl(*this, SD);
4247+
if (SD->getOpaqueResultTypeDecl()) {
4248+
if (auto SF = SD->getInnermostDeclContext()->getParentSourceFile()) {
4249+
SF->markDeclWithOpaqueResultTypeAsValidated(SD);
4250+
}
4251+
}
42584252

42594253
break;
42604254
}
@@ -4523,12 +4517,9 @@ static void finalizeType(TypeChecker &TC, NominalTypeDecl *nominal) {
45234517
forceConformance(TC.Context.getProtocol(KnownProtocolKind::Hashable));
45244518
}
45254519

4526-
// validateDeclForNameLookup will not trigger an immediate full
4527-
// validation of protocols, but clients will assume that things
4528-
// like the requirement signature have been set.
45294520
if (auto PD = dyn_cast<ProtocolDecl>(nominal)) {
4530-
(void)PD->getInheritedProtocols();
4531-
TC.validateDecl(PD);
4521+
for (auto *inherited : PD->getInheritedProtocols())
4522+
TC.requestNominalLayout(inherited);
45324523
}
45334524
}
45344525

0 commit comments

Comments
 (0)