AST: TypeChecker::conformsToProtocol() => ModuleDecl::checkConformance()

This commit is contained in:
Slava Pestov
2024-01-16 15:18:44 -05:00
parent 1e950b1725
commit 14d1fcb51a
35 changed files with 151 additions and 193 deletions

View File

@@ -3162,8 +3162,8 @@ bool ContextualFailure::diagnoseThrowsTypeMismatch() const {
if (auto errorCodeProtocol =
Ctx.getProtocol(KnownProtocolKind::ErrorCodeProtocol)) {
Type errorCodeType = getFromType();
auto conformance = TypeChecker::conformsToProtocol(
errorCodeType, errorCodeProtocol, getParentModule());
auto conformance = getParentModule()->checkConformance(
errorCodeType, errorCodeProtocol);
if (conformance && toErrorExistential) {
Type errorType =
conformance
@@ -3403,8 +3403,7 @@ bool ContextualFailure::tryProtocolConformanceFixIt(
SmallVector<std::string, 8> missingProtoTypeStrings;
SmallVector<ProtocolDecl *, 8> missingProtocols;
for (auto protocol : layout.getProtocols()) {
if (!TypeChecker::conformsToProtocol(fromType, protocol,
getParentModule())) {
if (!getParentModule()->checkConformance(fromType, protocol)) {
auto protoTy = protocol->getDeclaredInterfaceType();
missingProtoTypeStrings.push_back(protoTy->getString());
missingProtocols.push_back(protocol);
@@ -9035,8 +9034,7 @@ bool CheckedCastToUnrelatedFailure::diagnoseAsError() {
auto *protocol = TypeChecker::getLiteralProtocol(ctx, sub);
// Special handle for literals conditional checked cast when they can
// be statically coerced to the cast type.
if (protocol && TypeChecker::conformsToProtocol(toType, protocol,
dc->getParentModule())) {
if (protocol && dc->getParentModule()->checkConformance(toType, protocol)) {
emitDiagnostic(diag::literal_conditional_downcast_to_coercion, fromType,
toType);
return true;