Skip to content

Commit 979fc28

Browse files
committed
AST: Remove ProtocolConformanceState::CheckingTypeWitnesses
1 parent 5645539 commit 979fc28

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

include/swift/AST/ProtocolConformance.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ enum class ProtocolConformanceState {
8686
Complete = 0,
8787
/// The conformance is known but is not yet complete.
8888
Incomplete,
89-
/// The conformance's type witnesses are currently being resolved.
90-
CheckingTypeWitnesses,
9189
/// The conformance is being checked.
9290
Checking,
9391

@@ -225,7 +223,6 @@ class alignas(1 << DeclAlignInBits) ProtocolConformance
225223
/// Determine whether this conformance is incomplete.
226224
bool isIncomplete() const {
227225
return getState() == ProtocolConformanceState::Incomplete ||
228-
getState() == ProtocolConformanceState::CheckingTypeWitnesses ||
229226
getState() == ProtocolConformanceState::Checking;
230227
}
231228

lib/AST/ASTVerifier.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2803,7 +2803,6 @@ class Verifier : public ASTWalker {
28032803
// Ignore incomplete conformances; we didn't need them.
28042804
return;
28052805

2806-
case ProtocolConformanceState::CheckingTypeWitnesses:
28072806
case ProtocolConformanceState::Checking:
28082807
dumpRef(decl);
28092808
Out << " has a protocol conformance that is still being checked "

lib/AST/ProtocolConformance.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,12 @@ NormalProtocolConformance::getTypeWitnessAndDecl(AssociatedTypeDecl *assocType,
479479

480480
// If this conformance is in a state where it is inferring type witnesses but
481481
// we didn't find anything, fail.
482-
if (getState() == ProtocolConformanceState::CheckingTypeWitnesses) {
482+
//
483+
// FIXME: This is unsound, because we may not have diagnosed anything but
484+
// still end up with an ErrorType in the AST.
485+
if (getDeclContext()->getASTContext().evaluator.hasActiveRequest(
486+
ResolveTypeWitnessesRequest{
487+
const_cast<NormalProtocolConformance *>(this)})) {
483488
return { Type(), nullptr };
484489
}
485490

lib/AST/SubstitutionMap.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,13 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
436436
if (!normal->hasComputedAssociatedConformances()) {
437437
// If we're in the process of checking the type witnesses, fail
438438
// gracefully.
439-
// FIXME: Seems like we should be able to get at the intermediate state
440-
// to use that.
441-
if (normal->getState() == ProtocolConformanceState::CheckingTypeWitnesses)
439+
//
440+
// FIXME: This is unsound, because we may not have diagnosed anything but
441+
// still end up with an ErrorType in the AST.
442+
if (proto->getASTContext().evaluator.hasActiveRequest(
443+
ResolveTypeWitnessesRequest{normal})) {
442444
return ProtocolConformanceRef::forInvalid();
445+
}
443446
}
444447

445448
// Get the associated conformance.

lib/Sema/AssociatedTypeInference.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3515,12 +3515,7 @@ auto AssociatedTypeInference::solve()
35153515
<< ": " << conformance->getProtocol()->getName()
35163516
<< " ============\n";);
35173517

3518-
// Track when we are checking type witnesses.
3519-
ProtocolConformanceState initialState = conformance->getState();
3520-
conformance->setState(ProtocolConformanceState::CheckingTypeWitnesses);
35213518
SWIFT_DEFER {
3522-
conformance->setState(initialState);
3523-
35243519
LLVM_DEBUG(llvm::dbgs() << "============ Finish " << conformance->getType()
35253520
<< ": " << conformance->getProtocol()->getName()
35263521
<< " ============\n";);

lib/Sema/TypeCheckNameLookup.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/AST/NameLookup.h"
2323
#include "swift/AST/NameLookupRequests.h"
2424
#include "swift/AST/ProtocolConformance.h"
25+
#include "swift/AST/TypeCheckRequests.h"
2526
#include "swift/Basic/TopCollection.h"
2627
#include <algorithm>
2728

@@ -496,13 +497,15 @@ LookupTypeResult TypeChecker::lookupMemberType(DeclContext *dc,
496497
}
497498

498499
// Use the type witness.
499-
auto concrete = conformance.getConcrete();
500+
auto *concrete = conformance.getConcrete();
501+
auto *normal = concrete->getRootNormalConformance();
500502

501503
// This is the only case where NormalProtocolConformance::
502504
// getTypeWitnessAndDecl() returns a null type.
503-
if (concrete->getState() ==
504-
ProtocolConformanceState::CheckingTypeWitnesses)
505+
if (dc->getASTContext().evaluator.hasActiveRequest(
506+
ResolveTypeWitnessesRequest{normal})) {
505507
continue;
508+
}
506509

507510
auto *typeDecl =
508511
concrete->getTypeWitnessAndDecl(assocType).getWitnessDecl();

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,6 @@ checkIndividualConformance(NormalProtocolConformance *conformance) {
21782178
// Check the rest of the conformance below.
21792179
break;
21802180

2181-
case ProtocolConformanceState::CheckingTypeWitnesses:
21822181
case ProtocolConformanceState::Checking:
21832182
case ProtocolConformanceState::Complete:
21842183
// Nothing to do.

0 commit comments

Comments
 (0)