AST: Replace remaining uses of Type::transform() with transformRec()

This commit is contained in:
Slava Pestov
2024-08-12 14:00:33 -04:00
parent d35af38ce4
commit b601c294ac
22 changed files with 154 additions and 174 deletions

View File

@@ -95,7 +95,7 @@ Type FailureDiagnostic::getRawType(ASTNode node) const {
Type FailureDiagnostic::resolveType(Type rawType, bool reconstituteSugar,
bool wantRValue) const {
rawType = rawType.transform([&](Type type) -> Type {
rawType = rawType.transformRec([&](Type type) -> std::optional<Type> {
if (auto *typeVar = type->getAs<TypeVariableType>()) {
auto resolvedType = S.simplifyType(typeVar);
@@ -126,8 +126,10 @@ Type FailureDiagnostic::resolveType(Type rawType, bool reconstituteSugar,
return env->mapElementTypeIntoPackContext(type);
}
return type->isPlaceholder() ? Type(type->getASTContext().TheUnresolvedType)
: type;
if (type->isPlaceholder())
return Type(type->getASTContext().TheUnresolvedType);
return std::nullopt;
});
if (reconstituteSugar)
@@ -199,7 +201,7 @@ Type FailureDiagnostic::restoreGenericParameters(
Type type,
llvm::function_ref<void(GenericTypeParamType *, Type)> substitution) {
llvm::SmallPtrSet<GenericTypeParamType *, 4> processed;
return type.transform([&](Type type) -> Type {
return type.transformRec([&](Type type) -> std::optional<Type> {
if (auto *typeVar = type->getAs<TypeVariableType>()) {
type = resolveType(typeVar);
if (auto *GP = typeVar->getImpl().getGenericParameter()) {
@@ -209,7 +211,7 @@ Type FailureDiagnostic::restoreGenericParameters(
}
}
return type;
return std::nullopt;
});
}