Skip to content

Commit e305b20

Browse files
committed
[AST] Allow computation of erroneous substitutions.
Be more tolerant of substitutions for erroneous types; the type checker will diagnose these issues, but later code paths might still form these substititions. Put in error types rather than crashing.
1 parent d947ed3 commit e305b20

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/AST/GenericSignature.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,16 @@ getSubstitutions(TypeSubstitutionFn subs,
389389
for (auto req: reqs) {
390390
assert(req.getKind() == RequirementKind::Conformance);
391391
auto protoType = req.getSecondType()->castTo<ProtocolType>();
392-
// TODO: Error handling for failed conformance lookup.
393-
currentConformances.push_back(
394-
*lookupConformance(depTy->getCanonicalType(), currentReplacement,
395-
protoType));
392+
if (auto conformance = lookupConformance(depTy->getCanonicalType(),
393+
currentReplacement,
394+
protoType)) {
395+
currentConformances.push_back(*conformance);
396+
} else {
397+
if (!currentReplacement->hasError())
398+
currentReplacement = ErrorType::get(currentReplacement);
399+
currentConformances.push_back(
400+
ProtocolConformanceRef(protoType->getDecl()));
401+
}
396402
}
397403

398404
// Add it to the final substitution list.

0 commit comments

Comments
 (0)