Skip to content

Commit 449ef61

Browse files
committed
[CSGen] NFC: Remove obsolete closure handling logic
Since we no longer walk into closures it's possible to remove `{enter, exit}Closure` and `getClosureParams`.
1 parent 1c803a7 commit 449ef61

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

lib/Sema/CSGen.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,6 @@ namespace {
920920
ConstraintSystem &CS;
921921
DeclContext *CurDC;
922922
ConstraintSystemPhase CurrPhase;
923-
SmallVector<DeclContext*, 4> DCStack;
924923

925924
static const unsigned numEditorPlaceholderVariables = 2;
926925

@@ -1131,25 +1130,10 @@ namespace {
11311130

11321131
virtual ~ConstraintGenerator() {
11331132
CS.setPhase(CurrPhase);
1134-
// We really ought to have this assertion:
1135-
// assert(DCStack.empty() && CurDC == CS.DC);
1136-
// Unfortunately, ASTWalker is really bad at letting us establish
1137-
// invariants like this because walkToExprPost isn't called if
1138-
// something early-aborts the walk.
11391133
}
11401134

11411135
ConstraintSystem &getConstraintSystem() const { return CS; }
11421136

1143-
void enterClosure(ClosureExpr *closure) {
1144-
DCStack.push_back(CurDC);
1145-
CurDC = closure;
1146-
}
1147-
1148-
void exitClosure(ClosureExpr *closure) {
1149-
assert(CurDC == closure);
1150-
CurDC = DCStack.pop_back_val();
1151-
}
1152-
11531137
virtual Type visitErrorExpr(ErrorExpr *E) {
11541138
// FIXME: Can we do anything with error expressions at this point?
11551139
return nullptr;
@@ -2141,40 +2125,6 @@ namespace {
21412125
return FunctionType::get(closureParams, resultTy, extInfo);
21422126
}
21432127

2144-
/// Give each parameter in a ClosureExpr a fresh type variable if parameter
2145-
/// types were not specified, and return the eventual function type.
2146-
void getClosureParams(ClosureExpr *closureExpr,
2147-
SmallVectorImpl<AnyFunctionType::Param> &params) {
2148-
auto *paramList = closureExpr->getParameters();
2149-
unsigned i = 0;
2150-
2151-
for (auto *param : *paramList) {
2152-
auto *locator = CS.getConstraintLocator(
2153-
closureExpr, LocatorPathElt::TupleElement(i++));
2154-
Type paramType, internalType;
2155-
2156-
// If a type was explicitly specified, use its opened type.
2157-
if (param->getTypeRepr()) {
2158-
paramType = closureExpr->mapTypeIntoContext(param->getInterfaceType());
2159-
// FIXME: Need a better locator for a pattern as a base.
2160-
paramType = CS.openUnboundGenericType(paramType, locator);
2161-
internalType = paramType;
2162-
} else {
2163-
// Otherwise, create fresh type variables.
2164-
paramType = CS.createTypeVariable(locator,
2165-
TVO_CanBindToInOut |
2166-
TVO_CanBindToNoEscape);
2167-
internalType = CS.createTypeVariable(locator,
2168-
TVO_CanBindToLValue |
2169-
TVO_CanBindToNoEscape);
2170-
CS.addConstraint(ConstraintKind::BindParam, paramType, internalType,
2171-
locator);
2172-
}
2173-
CS.setType(param, internalType);
2174-
params.push_back(param->toFunctionParam(paramType));
2175-
}
2176-
}
2177-
21782128
/// Produces a type for the given pattern, filling in any missing
21792129
/// type information with fresh type variables.
21802130
///

0 commit comments

Comments
 (0)