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

@@ -269,8 +269,7 @@ static EnumDecl *validateCodingKeysType(const DerivedConformance &derived,
// Ensure that the type we found conforms to the CodingKey protocol.
auto *codingKeyProto = C.getProtocol(KnownProtocolKind::CodingKey);
if (!TypeChecker::conformsToProtocol(codingKeysType, codingKeyProto,
derived.getParentModule())) {
if (!derived.getParentModule()->checkConformance(codingKeysType, codingKeyProto)) {
// If CodingKeys is a typealias which doesn't point to a valid nominal type,
// codingKeysTypeDecl will be nullptr here. In that case, we need to warn on
// the location of the usage, since there isn't an underlying type to
@@ -337,8 +336,7 @@ static bool validateCodingKeysEnum(const DerivedConformance &derived,
// We have a property to map to. Ensure it's {En,De}codable.
auto target = derived.getConformanceContext()->mapTypeIntoContext(
it->second->getValueInterfaceType());
if (TypeChecker::conformsToProtocol(target, derived.Protocol,
derived.getParentModule())
if (derived.getParentModule()->checkConformance(target, derived.Protocol)
.isInvalid()) {
TypeLoc typeLoc = {
it->second->getTypeReprOrParentPatternTypeRepr(),
@@ -1944,8 +1942,7 @@ static bool canSynthesize(DerivedConformance &derived, ValueDecl *requirement,
if (auto *superclassDecl = classDecl->getSuperclassDecl()) {
DeclName memberName;
auto superType = superclassDecl->getDeclaredInterfaceType();
if (TypeChecker::conformsToProtocol(superType, proto,
derived.getParentModule())) {
if (derived.getParentModule()->checkConformance(superType, proto)) {
// super.init(from:) must be accessible.
memberName = cast<ConstructorDecl>(requirement)->getName();
} else {