[CS] Move getUnopenedTypeOfReference out of TypeChecker

For some reason, the changed caller in CS wasn't actually going to use any of the types in the constraint system from the entrypoint it was calling. Switch over to using the constraint-system-based entrypoint so we can pick up expression types consistently. Then, move the TypeChecker entrypoint onto ConstraintSystem to reduce the duplication here.

The remaining callers of buildCheckedRefExpr should be migrated.
This commit is contained in:
Robert Widmann
2020-03-11 11:13:25 -07:00
parent 2dc3390091
commit 4e67eec878
4 changed files with 29 additions and 49 deletions

View File

@@ -925,7 +925,7 @@ Type ConstraintSystem::getUnopenedTypeOfReference(VarDecl *value, Type baseType,
DeclContext *UseDC,
const DeclRefExpr *base,
bool wantInterfaceType) {
return TypeChecker::getUnopenedTypeOfReference(
return ConstraintSystem::getUnopenedTypeOfReference(
value, baseType, UseDC,
[&](VarDecl *var) -> Type {
if (Type type = getTypeIfAvailable(var))
@@ -940,7 +940,7 @@ Type ConstraintSystem::getUnopenedTypeOfReference(VarDecl *value, Type baseType,
base, wantInterfaceType);
}
Type TypeChecker::getUnopenedTypeOfReference(
Type ConstraintSystem::getUnopenedTypeOfReference(
VarDecl *value, Type baseType, DeclContext *UseDC,
llvm::function_ref<Type(VarDecl *)> getType, const DeclRefExpr *base,
bool wantInterfaceType) {
@@ -1405,9 +1405,9 @@ ConstraintSystem::getTypeOfMemberReference(
->castTo<AnyFunctionType>()->getParams();
refType = FunctionType::get(indices, elementTy);
} else {
refType = TypeChecker::getUnopenedTypeOfReference(
cast<VarDecl>(value), baseTy, useDC, base,
/*wantInterfaceType=*/true);
refType =
getUnopenedTypeOfReference(cast<VarDecl>(value), baseTy, useDC, base,
/*wantInterfaceType=*/true);
}
auto selfTy = outerDC->getSelfInterfaceType();