Skip to content

Commit 2afeb10

Browse files
committed
SIL: withCaptures parameters were dead, NFC
Swift SVN r32160
1 parent 636d194 commit 2afeb10

File tree

3 files changed

+14
-35
lines changed

3 files changed

+14
-35
lines changed

include/swift/SIL/TypeLowering.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -532,15 +532,14 @@ class TypeConverter {
532532
/// The current generic context signature.
533533
CanGenericSignature CurGenericContext;
534534

535-
CanAnyFunctionType makeConstantType(SILDeclRef constant, bool addCaptures);
536-
CanAnyFunctionType makeConstantInterfaceType(SILDeclRef constant,
537-
bool addCaptures);
535+
CanAnyFunctionType makeConstantType(SILDeclRef constant);
536+
CanAnyFunctionType makeConstantInterfaceType(SILDeclRef constant);
538537

539538
/// Get the context parameters for a constant. Returns a pair of the innermost
540539
/// generic parameter list and the generic param list that directly applies
541540
/// to the constant, if any.
542541
std::pair<GenericParamList *, GenericParamList*>
543-
getConstantContextGenericParams(SILDeclRef constant, bool addCaptures);
542+
getConstantContextGenericParams(SILDeclRef constant);
544543

545544
// Types converted during foreign bridging.
546545
#define BRIDGING_KNOWN_TYPE(BridgedModule,BridgedType) \
@@ -674,9 +673,6 @@ class TypeConverter {
674673
/// Returns the formal type, lowered AST type, and SILFunctionType
675674
/// for a constant reference.
676675
SILConstantInfo getConstantInfo(SILDeclRef constant);
677-
678-
/// Returns the type of a local function without any additional captures.
679-
CanAnyFunctionType getConstantFormalTypeWithoutCaptures(SILDeclRef constant);
680676

681677
/// Returns the SIL type of a constant reference.
682678
SILType getConstantType(SILDeclRef constant) {

lib/SIL/SILFunctionType.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,12 +1426,11 @@ SILConstantInfo TypeConverter::getConstantInfo(SILDeclRef constant) {
14261426

14271427
// First, get a function type for the constant. This creates the
14281428
// right type for a getter or setter.
1429-
auto formalType = makeConstantType(constant, /*withCaptures*/ true);
1430-
auto formalInterfaceType = makeConstantInterfaceType(constant,
1431-
/*withCaptures*/ true);
1429+
auto formalType = makeConstantType(constant);
1430+
auto formalInterfaceType = makeConstantInterfaceType(constant);
14321431
GenericParamList *contextGenerics, *innerGenerics;
14331432
std::tie(contextGenerics, innerGenerics)
1434-
= getConstantContextGenericParams(constant, /*withCaptures*/true);
1433+
= getConstantContextGenericParams(constant);
14351434

14361435
// The formal type is just that with the right representation.
14371436
auto rep = getDeclRefRepresentation(constant);
@@ -1742,8 +1741,8 @@ SILConstantInfo TypeConverter::getConstantOverrideInfo(SILDeclRef derived,
17421741
// vtable thunk the same signature as the derived method.
17431742
auto basePattern = AbstractionPattern(baseInfo.LoweredType);
17441743

1745-
auto baseInterfaceTy = makeConstantInterfaceType(base, false);
1746-
auto derivedInterfaceTy = makeConstantInterfaceType(derived, false);
1744+
auto baseInterfaceTy = makeConstantInterfaceType(base);
1745+
auto derivedInterfaceTy = makeConstantInterfaceType(derived);
17471746

17481747
auto selfInterfaceTy = derivedInterfaceTy.getInput()->getRValueInstanceType();
17491748

lib/SIL/TypeLowering.cpp

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,11 +2033,6 @@ TypeConverter::getFunctionInterfaceTypeWithCaptures(CanAnyFunctionType funcType,
20332033
return CanFunctionType::get(capturedInputs, funcType, extInfo);
20342034
}
20352035

2036-
CanAnyFunctionType
2037-
TypeConverter::getConstantFormalTypeWithoutCaptures(SILDeclRef c) {
2038-
return makeConstantType(c, /*withCaptures*/ false);
2039-
}
2040-
20412036
/// Replace any DynamicSelf types with their underlying Self type.
20422037
static Type replaceDynamicSelfWithSelf(Type t) {
20432038
return t.transform([](Type type) -> Type {
@@ -2052,8 +2047,7 @@ static CanType replaceDynamicSelfWithSelf(CanType t) {
20522047
return replaceDynamicSelfWithSelf(Type(t))->getCanonicalType();
20532048
}
20542049

2055-
CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c,
2056-
bool withCaptures) {
2050+
CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c) {
20572051
ValueDecl *vd = c.loc.dyn_cast<ValueDecl *>();
20582052

20592053
switch (c.kind) {
@@ -2064,7 +2058,6 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c,
20642058
auto funcTy = cast<AnyFunctionType>(ACE->getType()->getCanonicalType());
20652059
funcTy = cast<AnyFunctionType>(
20662060
getInterfaceTypeOutOfContext(funcTy, ACE->getParent()));
2067-
if (!withCaptures) return funcTy;
20682061
return getFunctionInterfaceTypeWithCaptures(funcTy, ACE);
20692062
}
20702063

@@ -2075,7 +2068,6 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c,
20752068
funcTy = cast<AnyFunctionType>(
20762069
getInterfaceTypeOutOfContext(funcTy, func->getParent()));
20772070
funcTy = cast<AnyFunctionType>(replaceDynamicSelfWithSelf(funcTy));
2078-
if (!withCaptures) return funcTy;
20792071
return getFunctionInterfaceTypeWithCaptures(funcTy, func);
20802072
}
20812073

@@ -2121,12 +2113,10 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c,
21212113

21222114
/// Get the context generic parameters for an entity.
21232115
std::pair<GenericParamList *, GenericParamList *>
2124-
TypeConverter::getConstantContextGenericParams(SILDeclRef c,
2125-
bool withCaptures) {
2116+
TypeConverter::getConstantContextGenericParams(SILDeclRef c) {
21262117
ValueDecl *vd = c.loc.dyn_cast<ValueDecl *>();
21272118

2128-
/// Get the function generic params, including outer params if withCaptures is
2129-
/// set.
2119+
/// Get the function generic params, including outer params.
21302120
auto getLocalFuncParams = [&](FuncDecl *func) -> GenericParamList * {
21312121
// FIXME: For local generic functions we need to chain the local generic
21322122
// context to the outer context.
@@ -2139,9 +2129,7 @@ TypeConverter::getConstantContextGenericParams(SILDeclRef c,
21392129
case SILDeclRef::Kind::Func: {
21402130
if (auto *ACE = c.getAbstractClosureExpr()) {
21412131
// Closures are currently never natively generic.
2142-
if (!withCaptures) return {nullptr, nullptr};
2143-
return {getEffectiveGenericParamsForContext(ACE->getParent()),
2144-
nullptr};
2132+
return {getEffectiveGenericParamsForContext(ACE->getParent()), nullptr};
21452133
}
21462134
FuncDecl *func = cast<FuncDecl>(vd);
21472135
return {getLocalFuncParams(func), func->getGenericParams()};
@@ -2172,27 +2160,23 @@ TypeConverter::getConstantContextGenericParams(SILDeclRef c,
21722160
return {cast<ClassDecl>(vd)->getGenericParamsOfContext(), nullptr};
21732161
case SILDeclRef::Kind::DefaultArgGenerator:
21742162
// Use the context generic parameters of the original declaration.
2175-
return getConstantContextGenericParams(SILDeclRef(c.getDecl()),
2176-
/*captures*/ false);
2163+
return getConstantContextGenericParams(SILDeclRef(c.getDecl()));
21772164
}
21782165
}
21792166

2180-
CanAnyFunctionType TypeConverter::makeConstantType(SILDeclRef c,
2181-
bool withCaptures) {
2167+
CanAnyFunctionType TypeConverter::makeConstantType(SILDeclRef c) {
21822168
ValueDecl *vd = c.loc.dyn_cast<ValueDecl *>();
21832169

21842170
switch (c.kind) {
21852171
case SILDeclRef::Kind::Func: {
21862172
if (auto *ACE = c.loc.dyn_cast<AbstractClosureExpr *>()) {
21872173
auto funcTy = cast<AnyFunctionType>(ACE->getType()->getCanonicalType());
2188-
if (!withCaptures) return funcTy;
21892174
return getFunctionTypeWithCaptures(funcTy, ACE);
21902175
}
21912176

21922177
FuncDecl *func = cast<FuncDecl>(vd);
21932178
auto funcTy = cast<AnyFunctionType>(func->getType()->getCanonicalType());
21942179
funcTy = cast<AnyFunctionType>(replaceDynamicSelfWithSelf(funcTy));
2195-
if (!withCaptures) return funcTy;
21962180
return getFunctionTypeWithCaptures(funcTy, func);
21972181
}
21982182

0 commit comments

Comments
 (0)