@@ -1978,10 +1978,9 @@ static ConstraintFix *fixRequirementFailure(ConstraintSystem &cs, Type type1,
1978
1978
// / Attempt to repair typing failures and record fixes if needed.
1979
1979
// / \return true if at least some of the failures has been repaired
1980
1980
// / successfully, which allows type matcher to continue.
1981
- static bool
1982
- repairFailures (ConstraintSystem &cs, Type lhs, Type rhs,
1983
- SmallVectorImpl<RestrictionOrFix> &conversionsOrFixes,
1984
- ConstraintLocatorBuilder locator) {
1981
+ bool ConstraintSystem::repairFailures (
1982
+ Type lhs, Type rhs, SmallVectorImpl<RestrictionOrFix> &conversionsOrFixes,
1983
+ ConstraintLocatorBuilder locator) {
1985
1984
SmallVector<LocatorPathElt, 4 > path;
1986
1985
auto *anchor = locator.getLocatorParts (path);
1987
1986
@@ -2005,14 +2004,14 @@ repairFailures(ConstraintSystem &cs, Type lhs, Type rhs,
2005
2004
case ConstraintLocator::ApplyArgToParam: {
2006
2005
if (lhs->getOptionalObjectType () && !rhs->getOptionalObjectType ()) {
2007
2006
conversionsOrFixes.push_back (
2008
- ForceOptional::create (cs , lhs, lhs->getOptionalObjectType (),
2009
- cs. getConstraintLocator (locator)));
2007
+ ForceOptional::create (* this , lhs, lhs->getOptionalObjectType (),
2008
+ getConstraintLocator (locator)));
2010
2009
}
2011
2010
break ;
2012
2011
}
2013
2012
2014
2013
case ConstraintLocator::FunctionArgument: {
2015
- auto *argLoc = cs. getConstraintLocator (
2014
+ auto *argLoc = getConstraintLocator (
2016
2015
locator.withPathElement (LocatorPathElt::getSynthesizedArgument (0 )));
2017
2016
2018
2017
// Let's drop the last element which points to a single argument
@@ -2023,7 +2022,7 @@ repairFailures(ConstraintSystem &cs, Type lhs, Type rhs,
2023
2022
path.back ().getKind () == ConstraintLocator::ContextualType))
2024
2023
return false ;
2025
2024
2026
- auto arg = llvm::find_if (cs. getTypeVariables (),
2025
+ auto arg = llvm::find_if (getTypeVariables (),
2027
2026
[&argLoc](const TypeVariableType *typeVar) {
2028
2027
return typeVar->getImpl ().getLocator () == argLoc;
2029
2028
});
@@ -2040,27 +2039,27 @@ repairFailures(ConstraintSystem &cs, Type lhs, Type rhs,
2040
2039
//
2041
2040
// But if `T.Element` didn't get resolved to `Void` we'd like
2042
2041
// to diagnose this as a missing argument which can't be ignored.
2043
- if (arg != cs. getTypeVariables ().end ()) {
2042
+ if (arg != getTypeVariables ().end ()) {
2044
2043
auto fnType = FunctionType::get ({FunctionType::Param (lhs)},
2045
- cs. getASTContext ().TheEmptyTupleType );
2044
+ getASTContext ().TheEmptyTupleType );
2046
2045
conversionsOrFixes.push_back (AddMissingArguments::create (
2047
- cs , fnType, {FunctionType::Param (*arg)},
2048
- cs. getConstraintLocator (anchor, path,
2049
- /* summaryFlags=*/ 0 )));
2046
+ * this , fnType, {FunctionType::Param (*arg)},
2047
+ getConstraintLocator (anchor, path,
2048
+ /* summaryFlags=*/ 0 )));
2050
2049
}
2051
2050
break ;
2052
2051
}
2053
2052
2054
2053
case ConstraintLocator::TypeParameterRequirement:
2055
2054
case ConstraintLocator::ConditionalRequirement: {
2056
- if (auto *fix = fixRequirementFailure (cs , lhs, rhs, anchor, path))
2055
+ if (auto *fix = fixRequirementFailure (* this , lhs, rhs, anchor, path))
2057
2056
conversionsOrFixes.push_back (fix);
2058
2057
break ;
2059
2058
}
2060
2059
2061
2060
case ConstraintLocator::ClosureResult: {
2062
- auto *fix = ContextualMismatch::create (cs , lhs, rhs,
2063
- cs. getConstraintLocator (locator));
2061
+ auto *fix = ContextualMismatch::create (* this , lhs, rhs,
2062
+ getConstraintLocator (locator));
2064
2063
conversionsOrFixes.push_back (fix);
2065
2064
break ;
2066
2065
}
@@ -2070,14 +2069,14 @@ repairFailures(ConstraintSystem &cs, Type lhs, Type rhs,
2070
2069
// between them are mutability and/or root, value type mismatch.
2071
2070
if (isKnownKeyPathType (lhs) && isKnownKeyPathType (rhs)) {
2072
2071
auto *fix = KeyPathContextualMismatch::create (
2073
- cs , lhs, rhs, cs. getConstraintLocator (locator));
2072
+ * this , lhs, rhs, getConstraintLocator (locator));
2074
2073
conversionsOrFixes.push_back (fix);
2075
2074
}
2076
2075
2077
2076
if (lhs->is <FunctionType>() && !rhs->is <AnyFunctionType>() &&
2078
2077
isa<ClosureExpr>(anchor)) {
2079
- auto *fix = ContextualMismatch::create (cs , lhs, rhs,
2080
- cs. getConstraintLocator (locator));
2078
+ auto *fix = ContextualMismatch::create (* this , lhs, rhs,
2079
+ getConstraintLocator (locator));
2081
2080
conversionsOrFixes.push_back (fix);
2082
2081
}
2083
2082
break ;
@@ -2899,7 +2898,7 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
2899
2898
2900
2899
// Attempt to repair any failures identifiable at this point.
2901
2900
if (attemptFixes) {
2902
- if (repairFailures (* this , type1, type2, conversionsOrFixes, locator)) {
2901
+ if (repairFailures (type1, type2, conversionsOrFixes, locator)) {
2903
2902
if (conversionsOrFixes.empty ())
2904
2903
return getTypeMatchSuccess ();
2905
2904
}
0 commit comments