Move resolving param type to CSApply

This commit is contained in:
Alejandro Alonso
2025-04-14 11:03:45 -07:00
parent ae355007fc
commit 79a51dfcc1
3 changed files with 13 additions and 10 deletions

View File

@@ -3247,6 +3247,18 @@ namespace {
auto toType = simplifyType(cs.getType(expr)); auto toType = simplifyType(cs.getType(expr));
ASSERT(toType->isEqual(expr->getParamDecl()->getValueType())); ASSERT(toType->isEqual(expr->getParamDecl()->getValueType()));
cs.setType(expr, toType); cs.setType(expr, toType);
auto declRefRepr = cast<DeclRefTypeRepr>(expr->getRepr());
auto resolvedTy =
TypeResolution::resolveContextualType(declRefRepr, cs.DC,
TypeResolverContext::InExpression,
nullptr, nullptr, nullptr);
if (!resolvedTy || resolvedTy->hasError())
return nullptr;
expr->setParamType(resolvedTy);
return expr; return expr;
} }

View File

@@ -1723,15 +1723,6 @@ namespace {
} }
Type visitTypeValueExpr(TypeValueExpr *E) { Type visitTypeValueExpr(TypeValueExpr *E) {
auto declRefRepr = cast<DeclRefTypeRepr>(E->getRepr());
auto resolvedTy = resolveTypeReferenceInExpression(declRefRepr,
TypeResolverContext::InExpression,
CS.getConstraintLocator(E));
if (!resolvedTy || resolvedTy->hasError())
return Type();
E->setParamType(resolvedTy);
return E->getParamDecl()->getValueType(); return E->getParamDecl()->getValueType();
} }

View File

@@ -2340,7 +2340,7 @@ TypeExpr *PreCheckTarget::simplifyTypeExpr(Expr *E) {
// When simplifying a type expr like "P1 & P2 -> P3 & P4 -> Int", // When simplifying a type expr like "P1 & P2 -> P3 & P4 -> Int",
// it may have been folded at the same time; recursively simplify it. // it may have been folded at the same time; recursively simplify it.
if (auto ArgsTypeExpr = simplifyTypeExpr(E)) if (auto ArgsTypeExpr = simplifyTypeExpr(E))
return ArgsTypeExpr->getTypeRepr(); return ArgsTypeExpr->getTypeRepr();
return nullptr; return nullptr;
}; };