Skip to content

Commit 1731b09

Browse files
committed
AST: Don't return null Type() from getTypeWitness()
1 parent ea0e017 commit 1731b09

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/AST/ProtocolConformanceRef.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,12 @@ Type ProtocolConformanceRef::getTypeWitness(AssociatedTypeDecl *assocType,
202202
auto conformingType = abstract->getType();
203203
ASSERT(abstract->getProtocol() == assocType->getProtocol());
204204

205-
if (auto *archetypeType = conformingType->getAs<ArchetypeType>())
206-
return archetypeType->getNestedType(assocType);
205+
if (auto *archetypeType = conformingType->getAs<ArchetypeType>()) {
206+
auto witnessType = archetypeType->getNestedType(assocType);
207+
if (!witnessType)
208+
return ErrorType::get(assocType->getASTContext());
209+
return witnessType;
210+
}
207211

208212
return DependentMemberType::get(conformingType, assocType);
209213
}

0 commit comments

Comments
 (0)