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

@@ -1461,14 +1461,14 @@ static bool optimizeStaticallyKnownProtocolConformance(
// SourceType is a non-existential type with a non-conditional
// conformance to a protocol represented by the TargetType.
//
// TypeChecker::conformsToProtocol checks any conditional conformances. If
// ModuleDecl::checkConformance() checks any conditional conformances. If
// they depend on information not known until runtime, the conformance
// will not be returned. For instance, if `X: P` where `T == Int` in `func
// foo<T>(_: T) { ... X<T>() as? P ... }`, the cast will succeed for
// `foo(0)` but not for `foo("string")`. There are many cases where
// everything is completely static (`X<Int>() as? P`), in which case a
// valid conformance will be returned.
auto Conformance = SM->conformsToProtocol(SourceType, Proto);
auto Conformance = SM->checkConformance(SourceType, Proto);
if (Conformance.isInvalid())
return false;