Skip to content

Commit 6077aca

Browse files
committed
RequirementMachine: Handle null pointer return from getTypeWitness()
ProtocolConformance::getTypeWitness() can return a null Type in case of circularity. Handle this by replacing it with an ErrorType to match the behavior of the GSB.
1 parent 0513812 commit 6077aca

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/AST/RequirementMachine/EquivalenceClassMap.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,8 +692,17 @@ void EquivalenceClassMap::concretizeNestedTypesFromConcreteParent(
692692
<< " on " << concreteType << "\n";
693693
}
694694

695-
auto typeWitness = concrete->getTypeWitness(assocType)
696-
->getCanonicalType();
695+
auto t = concrete->getTypeWitness(assocType);
696+
if (!t) {
697+
if (DebugConcretizeNestedTypes) {
698+
llvm::dbgs() << "^^ " << "Type witness for " << assocType->getName()
699+
<< " of " << concreteType << " could not be inferred\n";
700+
}
701+
702+
t = ErrorType::get(concreteType);
703+
}
704+
705+
auto typeWitness = t->getCanonicalType();
697706

698707
if (DebugConcretizeNestedTypes) {
699708
llvm::dbgs() << "^^ " << "Type witness for " << assocType->getName()

0 commit comments

Comments
 (0)