Skip to content

Commit 3b9b803

Browse files
authored
Merge pull request #19045 from xedin/move-is-explicit-conversion-to-constraint
[ConstraintSystem] NFC: Move `isExplicitConversion` to `Constraint`
2 parents 11f70e4 + 3be5c20 commit 3b9b803

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ bool ConstraintSystem::solveForDisjunction(
20662066

20672067
auto noSolutions = solveForDisjunctionChoices(
20682068
disjunction->getNestedConstraints(), locator, solutions,
2069-
allowFreeTypeVariables, isExplicitConversionConstraint(disjunction));
2069+
allowFreeTypeVariables, disjunction->isExplicitConversion());
20702070

20712071
if (hasDisabledChoices) {
20722072
// Re-enable previously disabled overload choices.

lib/Sema/Constraint.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,17 @@ static void uniqueTypeVariables(SmallVectorImpl<TypeVariableType *> &typeVars) {
536536
typeVars.end());
537537
}
538538

539+
bool Constraint::isExplicitConversion() const {
540+
assert(Kind == ConstraintKind::Disjunction);
541+
542+
if (auto *locator = getLocator()) {
543+
if (auto anchor = locator->getAnchor())
544+
return isa<CoerceExpr>(anchor);
545+
}
546+
547+
return false;
548+
}
549+
539550
Constraint *Constraint::create(ConstraintSystem &cs, ConstraintKind kind,
540551
Type first, Type second,
541552
ConstraintLocator *locator) {

lib/Sema/Constraint.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,10 @@ class Constraint final : public llvm::ilist_node<Constraint>,
583583
return count;
584584
}
585585

586+
/// Determine if this constraint represents explicit conversion,
587+
/// e.g. coercion constraint "as X" which forms a disjunction.
588+
bool isExplicitConversion() const;
589+
586590
/// Retrieve the overload choice for an overload-binding constraint.
587591
OverloadChoice getOverloadChoice() const {
588592
assert(Kind == ConstraintKind::BindOverload);

lib/Sema/ConstraintSystem.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,20 +2108,6 @@ class ConstraintSystem {
21082108
Type getResultType(const AbstractClosureExpr *E);
21092109

21102110
private:
2111-
/// Determine if the given constraint represents explicit conversion,
2112-
/// e.g. coercion constraint "as X" which forms a disjunction.
2113-
bool isExplicitConversionConstraint(Constraint *constraint) const {
2114-
if (constraint->getKind() != ConstraintKind::Disjunction)
2115-
return false;
2116-
2117-
if (auto locator = constraint->getLocator()) {
2118-
if (auto anchor = locator->getAnchor())
2119-
return isa<CoerceExpr>(anchor);
2120-
}
2121-
2122-
return false;
2123-
}
2124-
21252111
/// Introduce the constraints associated with the given type variable
21262112
/// into the worklist.
21272113
void addTypeVariableConstraintsToWorkList(TypeVariableType *typeVar);

0 commit comments

Comments
 (0)