Skip to content

Commit 9569714

Browse files
committed
Clarify method names in SolutionApplicationTarget.
1 parent 36366bc commit 9569714

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7320,7 +7320,7 @@ Optional<SolutionApplicationTarget> ConstraintSystem::applySolution(
73207320
// We are supposed to use contextual type only if it is present and
73217321
// this expression doesn't represent the implicit return of the single
73227322
// expression function which got deduced to be `Never`.
7323-
Type convertType = target.getExprConversionTypeForConstraint();
7323+
Type convertType = target.getExprConversionType();
73247324
auto shouldCoerceToContextualType = [&]() {
73257325
return convertType &&
73267326
!target.isOptionalSomePatternInit() &&

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ ConstraintSystem::solveImpl(SolutionApplicationTarget &target,
12591259

12601260
// If there is a type that we're expected to convert to, add the conversion
12611261
// constraint.
1262-
if (Type convertType = target.getExprConversionTypeForConstraint()) {
1262+
if (Type convertType = target.getExprConversionType()) {
12631263
// Determine whether we know more about the contextual type.
12641264
ContextualTypePurpose ctp = target.getExprContextualTypePurpose();
12651265
bool isOpaqueReturnType = target.infersOpaqueReturnType();

lib/Sema/ConstraintSystem.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,11 @@ class SolutionApplicationTarget {
12241224
return expression.contextualPurpose;
12251225
}
12261226

1227-
Type getExprConversionType() const {
1228-
return getExprConversionTypeLoc().getType();
1227+
Type getExprContextualType() const {
1228+
return getExprContextualTypeLoc().getType();
12291229
}
12301230

1231-
TypeLoc getExprConversionTypeLoc() const {
1231+
TypeLoc getExprContextualTypeLoc() const {
12321232
assert(kind == Kind::expression);
12331233

12341234
// For an @autoclosure parameter, the conversion type is
@@ -1241,10 +1241,12 @@ class SolutionApplicationTarget {
12411241
return expression.convertType;
12421242
}
12431243

1244-
Type getExprConversionTypeForConstraint() const {
1244+
/// Retrieve the type to which an expression should be converted, or
1245+
/// a NULL type if no conversion constraint should be generated.
1246+
Type getExprConversionType() const {
12451247
if (contextualTypeIsOnlyAHint())
12461248
return Type();
1247-
return getExprConversionType();
1249+
return getExprContextualType();
12481250
}
12491251

12501252
/// Returns the autoclosure parameter type, or \c nullptr if the

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@ TypeChecker::typeCheckExpression(
21332133
contextualTypeExpr = loadExpr->getSubExpr();
21342134
cs.setContextualType(
21352135
contextualTypeExpr,
2136-
target.getExprConversionTypeLoc(),
2136+
target.getExprContextualTypeLoc(),
21372137
target.getExprContextualTypePurpose(),
21382138
target.infersOpaqueReturnType());
21392139

@@ -2147,7 +2147,8 @@ TypeChecker::typeCheckExpression(
21472147
// type variable and update the target's type with an optional of that
21482148
// type variable.
21492149
if (target.isOptionalSomePatternInit()) {
2150-
assert(!target.getExprConversionType() && "convertType and type check options conflict");
2150+
assert(!target.getExprContextualType() &&
2151+
"some pattern cannot have contextual type pre-configured");
21512152
auto *convertTypeLocator =
21522153
cs.getConstraintLocator(expr, LocatorPathElt::ContextualType());
21532154
Type var = cs.createTypeVariable(convertTypeLocator, TVO_CanBindToNoEscape);
@@ -2166,8 +2167,8 @@ TypeChecker::typeCheckExpression(
21662167
// because they will leak out into arbitrary places in the resultant AST.
21672168
if (options.contains(TypeCheckExprFlags::AllowUnresolvedTypeVariables) &&
21682169
(viable->size() != 1 ||
2169-
(target.getExprConversionTypeForConstraint() &&
2170-
target.getExprConversionTypeForConstraint()->hasUnresolvedType()))) {
2170+
(target.getExprConversionType() &&
2171+
target.getExprConversionType()->hasUnresolvedType()))) {
21712172
// FIXME: This hack should only be needed for CSDiag.
21722173
unresolvedTypeExprs = true;
21732174
return target;

0 commit comments

Comments
 (0)