Skip to content

Commit 4f3f156

Browse files
committed
AST: Remove ProtocolConformanceState::CheckingTypeWitnesses
1 parent c359f7c commit 4f3f156

File tree

7 files changed

+16
-17
lines changed

7 files changed

+16
-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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,11 @@ 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{conformance})) {
483487
return { Type(), nullptr };
484488
}
485489

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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,15 @@ LookupTypeResult TypeChecker::lookupMemberType(DeclContext *dc,
496496
}
497497

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

501502
// This is the only case where NormalProtocolConformance::
502503
// getTypeWitnessAndDecl() returns a null type.
503-
if (concrete->getState() ==
504-
ProtocolConformanceState::CheckingTypeWitnesses)
504+
if (dc->getASTContext().evaluator.hasActiveRequest(
505+
ResolveTypeWitnessesRequest{normal})) {
505506
continue;
507+
}
506508

507509
auto *typeDecl =
508510
concrete->getTypeWitnessAndDecl(assocType).getWitnessDecl();

lib/Sema/TypeCheckProtocol.cpp

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

2174-
case ProtocolConformanceState::CheckingTypeWitnesses:
21752174
case ProtocolConformanceState::Checking:
21762175
case ProtocolConformanceState::Complete:
21772176
// Nothing to do.

0 commit comments

Comments
 (0)