Skip to content

Commit e7ef8ab

Browse files
committed
Migrate getTypeOfExpressionWithoutApplying
1 parent 1123b1f commit e7ef8ab

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

lib/Sema/CSDiag.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class FailureDiagnosis :public ASTVisitor<FailureDiagnosis, /*exprresult*/bool>{
167167
FreeTypeVariableBinding allowFreeTypeVariables =
168168
FreeTypeVariableBinding::Disallow,
169169
ExprTypeCheckListener *listener = nullptr) {
170-
CS.TC.getPossibleTypesOfExpressionWithoutApplying(
170+
TypeChecker::getPossibleTypesOfExpressionWithoutApplying(
171171
expr, dc, types, allowFreeTypeVariables, listener);
172172
CS.cacheExprTypes(expr);
173173
}
@@ -177,8 +177,11 @@ class FailureDiagnosis :public ASTVisitor<FailureDiagnosis, /*exprresult*/bool>{
177177
FreeTypeVariableBinding allowFreeTypeVariables =
178178
FreeTypeVariableBinding::Disallow,
179179
ExprTypeCheckListener *listener = nullptr) {
180-
auto type = CS.TC.getTypeOfExpressionWithoutApplying(expr, dc, referencedDecl,
181-
allowFreeTypeVariables, listener);
180+
auto type =
181+
TypeChecker::getTypeOfExpressionWithoutApplying(expr, dc,
182+
referencedDecl,
183+
allowFreeTypeVariables,
184+
listener);
182185
CS.cacheExprTypes(expr);
183186
return type;
184187
}
@@ -1757,7 +1760,8 @@ bool FailureDiagnosis::diagnoseImplicitSelfErrors(
17571760
for (unsigned i = 0, e = argTuple->getNumElements(); i < e; ++i) {
17581761
ConcreteDeclRef ref = nullptr;
17591762
auto *el = argTuple->getElement(i);
1760-
auto typeResult = getTypeOfExpressionWithoutApplying(el, CS.DC, ref);
1763+
auto typeResult =
1764+
TypeChecker::getTypeOfExpressionWithoutApplying(el, CS.DC, ref);
17611765
if (!typeResult)
17621766
return false;
17631767
auto flags = ParameterTypeFlags().withInOut(typeResult->is<InOutType>());
@@ -2097,7 +2101,7 @@ bool FailureDiagnosis::diagnoseSubscriptErrors(SubscriptExpr *SE,
20972101
ConcreteDeclRef decl = nullptr;
20982102
message = diag::cannot_subscript_with_index;
20992103

2100-
if (getTypeOfExpressionWithoutApplying(expr, CS.DC, decl))
2104+
if (TypeChecker::getTypeOfExpressionWithoutApplying(expr, CS.DC, decl))
21012105
return false;
21022106

21032107
// If we are down to a single candidate but with an unresolved
@@ -2587,7 +2591,7 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
25872591
"unexpected declaration reference");
25882592

25892593
ConcreteDeclRef decl = nullptr;
2590-
Type type = getTypeOfExpressionWithoutApplying(
2594+
Type type = TypeChecker::getTypeOfExpressionWithoutApplying(
25912595
fnExpr, CS.DC, decl, FreeTypeVariableBinding::UnresolvedType,
25922596
&listener);
25932597

@@ -3213,7 +3217,7 @@ bool FailureDiagnosis::diagnoseClosureExpr(
32133217
// diagnose situations where contextual type expected one result
32143218
// type but actual closure produces a different one without explicitly
32153219
// declaring it (e.g. by using anonymous parameters).
3216-
auto type = getTypeOfExpressionWithoutApplying(
3220+
auto type = TypeChecker::getTypeOfExpressionWithoutApplying(
32173221
closure, CS.DC, decl, FreeTypeVariableBinding::Disallow);
32183222

32193223
if (type && resultTypeProcessor(type, expectedResultType))
@@ -4072,7 +4076,7 @@ diagnoseAmbiguousMultiStatementClosure(ClosureExpr *closure) {
40724076
// successfully type-checked its type cleanup is going to be disabled
40734077
// (we are allowing unresolved types), and as a side-effect it might
40744078
// also be transformed e.g. OverloadedDeclRefExpr -> DeclRefExpr.
4075-
auto type = getTypeOfExpressionWithoutApplying(
4079+
auto type = TypeChecker::getTypeOfExpressionWithoutApplying(
40764080
resultExpr, CS.DC, decl, FreeTypeVariableBinding::UnresolvedType);
40774081
if (type)
40784082
resultType = type->getRValueType();

lib/Sema/TypeChecker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ static Optional<Type> getTypeOfCompletionContextExpr(
645645
}
646646

647647
Type originalType = parsedExpr->getType();
648-
if (auto T = TC.getTypeOfExpressionWithoutApplying(parsedExpr, DC,
648+
if (auto T = TypeChecker::getTypeOfExpressionWithoutApplying(parsedExpr, DC,
649649
referencedDecl, FreeTypeVariableBinding::UnresolvedType))
650650
return T;
651651

lib/Sema/TypeChecker.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,14 +1175,14 @@ class TypeChecker final {
11751175
///
11761176
/// \returns the type of \p expr on success, Type() otherwise.
11771177
/// FIXME: expr may still be modified...
1178-
Type getTypeOfExpressionWithoutApplying(
1178+
static Type getTypeOfExpressionWithoutApplying(
11791179
Expr *&expr, DeclContext *dc,
11801180
ConcreteDeclRef &referencedDecl,
11811181
FreeTypeVariableBinding allowFreeTypeVariables =
11821182
FreeTypeVariableBinding::Disallow,
11831183
ExprTypeCheckListener *listener = nullptr);
11841184

1185-
void getPossibleTypesOfExpressionWithoutApplying(
1185+
static void getPossibleTypesOfExpressionWithoutApplying(
11861186
Expr *&expr, DeclContext *dc, SmallPtrSetImpl<TypeBase *> &types,
11871187
FreeTypeVariableBinding allowFreeTypeVariables =
11881188
FreeTypeVariableBinding::Disallow,

0 commit comments

Comments
 (0)