mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: TypeChecker::conformsToProtocol() => ModuleDecl::checkConformance()
This commit is contained in:
@@ -83,8 +83,8 @@ getStoredPropertiesForDifferentiation(
|
||||
if (vd->getInterfaceType()->hasError())
|
||||
continue;
|
||||
auto varType = DC->mapTypeIntoContext(vd->getValueInterfaceType());
|
||||
auto conformance = TypeChecker::conformsToProtocol(
|
||||
varType, diffableProto, DC->getParentModule());
|
||||
auto conformance = DC->getParentModule()->checkConformance(
|
||||
varType, diffableProto);
|
||||
if (!conformance)
|
||||
continue;
|
||||
// Skip `let` stored properties with a mutating `move(by:)` if requested.
|
||||
@@ -117,8 +117,7 @@ static Type getTangentVectorInterfaceType(Type contextualType,
|
||||
auto *diffableProto = C.getProtocol(KnownProtocolKind::Differentiable);
|
||||
assert(diffableProto && "`Differentiable` protocol not found");
|
||||
auto conf =
|
||||
TypeChecker::conformsToProtocol(contextualType, diffableProto,
|
||||
DC->getParentModule());
|
||||
DC->getParentModule()->checkConformance(contextualType, diffableProto);
|
||||
assert(conf && "Contextual type must conform to `Differentiable`");
|
||||
if (!conf)
|
||||
return nullptr;
|
||||
@@ -140,8 +139,7 @@ static bool canDeriveTangentVectorAsSelf(NominalTypeDecl *nominal,
|
||||
auto *diffableProto = C.getProtocol(KnownProtocolKind::Differentiable);
|
||||
auto *addArithProto = C.getProtocol(KnownProtocolKind::AdditiveArithmetic);
|
||||
// `Self` must conform to `AdditiveArithmetic`.
|
||||
if (!TypeChecker::conformsToProtocol(nominalTypeInContext, addArithProto,
|
||||
DC->getParentModule()))
|
||||
if (!DC->getParentModule()->checkConformance(nominalTypeInContext, addArithProto))
|
||||
return false;
|
||||
for (auto *field : nominal->getStoredProperties()) {
|
||||
// `Self` must not have any `@noDerivative` stored properties.
|
||||
@@ -149,8 +147,7 @@ static bool canDeriveTangentVectorAsSelf(NominalTypeDecl *nominal,
|
||||
return false;
|
||||
// `Self` must have all stored properties satisfy `Self == TangentVector`.
|
||||
auto fieldType = DC->mapTypeIntoContext(field->getValueInterfaceType());
|
||||
auto conf = TypeChecker::conformsToProtocol(fieldType, diffableProto,
|
||||
DC->getParentModule());
|
||||
auto conf = DC->getParentModule()->checkConformance(fieldType, diffableProto);
|
||||
if (!conf)
|
||||
return false;
|
||||
auto tangentType = conf.getTypeWitnessByName(fieldType, C.Id_TangentVector);
|
||||
@@ -213,8 +210,7 @@ bool DerivedConformance::canDeriveDifferentiable(NominalTypeDecl *nominal,
|
||||
if (v->getInterfaceType()->hasError())
|
||||
return false;
|
||||
auto varType = DC->mapTypeIntoContext(v->getValueInterfaceType());
|
||||
return (bool)TypeChecker::conformsToProtocol(varType, diffableProto,
|
||||
DC->getParentModule());
|
||||
return (bool) DC->getParentModule()->checkConformance(varType, diffableProto);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -556,8 +552,7 @@ static void checkAndDiagnoseImplicitNoDerivative(ASTContext &Context,
|
||||
// Check whether to diagnose stored property.
|
||||
auto varType = DC->mapTypeIntoContext(vd->getValueInterfaceType());
|
||||
auto diffableConformance =
|
||||
TypeChecker::conformsToProtocol(varType, diffableProto,
|
||||
DC->getParentModule());
|
||||
DC->getParentModule()->checkConformance(varType, diffableProto);
|
||||
// If stored property should not be diagnosed, continue.
|
||||
if (diffableConformance &&
|
||||
canInvokeMoveByOnProperty(vd, diffableConformance))
|
||||
|
||||
Reference in New Issue
Block a user