Skip to content

Commit 8151a34

Browse files
committed
[Constraint solver] Merge the two areConservativelyCompatibleArgumentLabels()
The decl-based version is only used by the OverloadChoice-based version anyway.
1 parent 7249c92 commit 8151a34

File tree

2 files changed

+21
-38
lines changed

2 files changed

+21
-38
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -135,34 +135,6 @@ bool constraints::areConservativelyCompatibleArgumentLabels(
135135
hasCurriedSelf = true;
136136
}
137137

138-
return areConservativelyCompatibleArgumentLabels(
139-
decl, hasCurriedSelf, labels, hasTrailingClosure);
140-
}
141-
142-
Expr *constraints::getArgumentLabelTargetExpr(Expr *fn) {
143-
// Dig out the function, looking through, parentheses, ?, and !.
144-
do {
145-
fn = fn->getSemanticsProvidingExpr();
146-
147-
if (auto force = dyn_cast<ForceValueExpr>(fn)) {
148-
fn = force->getSubExpr();
149-
continue;
150-
}
151-
152-
if (auto bind = dyn_cast<BindOptionalExpr>(fn)) {
153-
fn = bind->getSubExpr();
154-
continue;
155-
}
156-
157-
return fn;
158-
} while (true);
159-
}
160-
161-
bool constraints::
162-
areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
163-
bool hasCurriedSelf,
164-
ArrayRef<Identifier> labels,
165-
bool hasTrailingClosure) {
166138
const AnyFunctionType *fTy;
167139

168140
if (auto fn = dyn_cast<AbstractFunctionDecl>(decl)) {
@@ -173,7 +145,7 @@ areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
173145
} else {
174146
return true;
175147
}
176-
148+
177149
SmallVector<AnyFunctionType::Param, 8> argInfos;
178150
for (auto argLabel : labels) {
179151
argInfos.push_back(AnyFunctionType::Param(Type(), argLabel, {}));
@@ -184,7 +156,7 @@ areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
184156
levelTy = levelTy->getResult()->getAs<AnyFunctionType>();
185157
assert(levelTy && "Parameter list curry level does not match type");
186158
}
187-
159+
188160
auto params = levelTy->getParams();
189161
SmallBitVector defaultMap =
190162
computeDefaultMap(params, decl, hasCurriedSelf);
@@ -198,6 +170,25 @@ areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
198170
listener, unusedParamBindings);
199171
}
200172

173+
Expr *constraints::getArgumentLabelTargetExpr(Expr *fn) {
174+
// Dig out the function, looking through, parentheses, ?, and !.
175+
do {
176+
fn = fn->getSemanticsProvidingExpr();
177+
178+
if (auto force = dyn_cast<ForceValueExpr>(fn)) {
179+
fn = force->getSubExpr();
180+
continue;
181+
}
182+
183+
if (auto bind = dyn_cast<BindOptionalExpr>(fn)) {
184+
fn = bind->getSubExpr();
185+
continue;
186+
}
187+
188+
return fn;
189+
} while (true);
190+
}
191+
201192
/// Determine the default type-matching options to use when decomposing a
202193
/// constraint into smaller constraints.
203194
static ConstraintSystem::TypeMatchOptions getDefaultDecompositionOptions(

lib/Sema/ConstraintSystem.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3548,14 +3548,6 @@ matchCallArguments(ConstraintSystem &cs,
35483548
/// subscript, etc.), find the underlying target expression.
35493549
Expr *getArgumentLabelTargetExpr(Expr *fn);
35503550

3551-
/// Attempt to prove that arguments with the given labels at the
3552-
/// given parameter depth cannot be used with the given value.
3553-
/// If this cannot be proven, conservatively returns true.
3554-
bool areConservativelyCompatibleArgumentLabels(ValueDecl *decl,
3555-
bool hasCurriedSelf,
3556-
ArrayRef<Identifier> labels,
3557-
bool hasTrailingClosure);
3558-
35593551
/// Attempt to prove that arguments with the given labels at the
35603552
/// given parameter depth cannot be used with the given value.
35613553
/// If this cannot be proven, conservatively returns true.

0 commit comments

Comments
 (0)