mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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.
This commit is contained in:
@@ -389,10 +389,16 @@ getSubstitutions(TypeSubstitutionFn subs,
|
||||
for (auto req: reqs) {
|
||||
assert(req.getKind() == RequirementKind::Conformance);
|
||||
auto protoType = req.getSecondType()->castTo<ProtocolType>();
|
||||
// TODO: Error handling for failed conformance lookup.
|
||||
currentConformances.push_back(
|
||||
*lookupConformance(depTy->getCanonicalType(), currentReplacement,
|
||||
protoType));
|
||||
if (auto conformance = lookupConformance(depTy->getCanonicalType(),
|
||||
currentReplacement,
|
||||
protoType)) {
|
||||
currentConformances.push_back(*conformance);
|
||||
} else {
|
||||
if (!currentReplacement->hasError())
|
||||
currentReplacement = ErrorType::get(currentReplacement);
|
||||
currentConformances.push_back(
|
||||
ProtocolConformanceRef(protoType->getDecl()));
|
||||
}
|
||||
}
|
||||
|
||||
// Add it to the final substitution list.
|
||||
|
||||
Reference in New Issue
Block a user