@@ -2033,11 +2033,6 @@ TypeConverter::getFunctionInterfaceTypeWithCaptures(CanAnyFunctionType funcType,
2033
2033
return CanFunctionType::get (capturedInputs, funcType, extInfo);
2034
2034
}
2035
2035
2036
- CanAnyFunctionType
2037
- TypeConverter::getConstantFormalTypeWithoutCaptures (SILDeclRef c) {
2038
- return makeConstantType (c, /* withCaptures*/ false );
2039
- }
2040
-
2041
2036
// / Replace any DynamicSelf types with their underlying Self type.
2042
2037
static Type replaceDynamicSelfWithSelf (Type t) {
2043
2038
return t.transform ([](Type type) -> Type {
@@ -2052,8 +2047,7 @@ static CanType replaceDynamicSelfWithSelf(CanType t) {
2052
2047
return replaceDynamicSelfWithSelf (Type (t))->getCanonicalType ();
2053
2048
}
2054
2049
2055
- CanAnyFunctionType TypeConverter::makeConstantInterfaceType (SILDeclRef c,
2056
- bool withCaptures) {
2050
+ CanAnyFunctionType TypeConverter::makeConstantInterfaceType (SILDeclRef c) {
2057
2051
ValueDecl *vd = c.loc .dyn_cast <ValueDecl *>();
2058
2052
2059
2053
switch (c.kind ) {
@@ -2064,7 +2058,6 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c,
2064
2058
auto funcTy = cast<AnyFunctionType>(ACE->getType ()->getCanonicalType ());
2065
2059
funcTy = cast<AnyFunctionType>(
2066
2060
getInterfaceTypeOutOfContext (funcTy, ACE->getParent ()));
2067
- if (!withCaptures) return funcTy;
2068
2061
return getFunctionInterfaceTypeWithCaptures (funcTy, ACE);
2069
2062
}
2070
2063
@@ -2075,7 +2068,6 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c,
2075
2068
funcTy = cast<AnyFunctionType>(
2076
2069
getInterfaceTypeOutOfContext (funcTy, func->getParent ()));
2077
2070
funcTy = cast<AnyFunctionType>(replaceDynamicSelfWithSelf (funcTy));
2078
- if (!withCaptures) return funcTy;
2079
2071
return getFunctionInterfaceTypeWithCaptures (funcTy, func);
2080
2072
}
2081
2073
@@ -2121,12 +2113,10 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c,
2121
2113
2122
2114
// / Get the context generic parameters for an entity.
2123
2115
std::pair<GenericParamList *, GenericParamList *>
2124
- TypeConverter::getConstantContextGenericParams (SILDeclRef c,
2125
- bool withCaptures) {
2116
+ TypeConverter::getConstantContextGenericParams (SILDeclRef c) {
2126
2117
ValueDecl *vd = c.loc .dyn_cast <ValueDecl *>();
2127
2118
2128
- // / Get the function generic params, including outer params if withCaptures is
2129
- // / set.
2119
+ // / Get the function generic params, including outer params.
2130
2120
auto getLocalFuncParams = [&](FuncDecl *func) -> GenericParamList * {
2131
2121
// FIXME: For local generic functions we need to chain the local generic
2132
2122
// context to the outer context.
@@ -2139,9 +2129,7 @@ TypeConverter::getConstantContextGenericParams(SILDeclRef c,
2139
2129
case SILDeclRef::Kind::Func: {
2140
2130
if (auto *ACE = c.getAbstractClosureExpr ()) {
2141
2131
// 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 };
2145
2133
}
2146
2134
FuncDecl *func = cast<FuncDecl>(vd);
2147
2135
return {getLocalFuncParams (func), func->getGenericParams ()};
@@ -2172,27 +2160,23 @@ TypeConverter::getConstantContextGenericParams(SILDeclRef c,
2172
2160
return {cast<ClassDecl>(vd)->getGenericParamsOfContext (), nullptr };
2173
2161
case SILDeclRef::Kind::DefaultArgGenerator:
2174
2162
// Use the context generic parameters of the original declaration.
2175
- return getConstantContextGenericParams (SILDeclRef (c.getDecl ()),
2176
- /* captures*/ false );
2163
+ return getConstantContextGenericParams (SILDeclRef (c.getDecl ()));
2177
2164
}
2178
2165
}
2179
2166
2180
- CanAnyFunctionType TypeConverter::makeConstantType (SILDeclRef c,
2181
- bool withCaptures) {
2167
+ CanAnyFunctionType TypeConverter::makeConstantType (SILDeclRef c) {
2182
2168
ValueDecl *vd = c.loc .dyn_cast <ValueDecl *>();
2183
2169
2184
2170
switch (c.kind ) {
2185
2171
case SILDeclRef::Kind::Func: {
2186
2172
if (auto *ACE = c.loc .dyn_cast <AbstractClosureExpr *>()) {
2187
2173
auto funcTy = cast<AnyFunctionType>(ACE->getType ()->getCanonicalType ());
2188
- if (!withCaptures) return funcTy;
2189
2174
return getFunctionTypeWithCaptures (funcTy, ACE);
2190
2175
}
2191
2176
2192
2177
FuncDecl *func = cast<FuncDecl>(vd);
2193
2178
auto funcTy = cast<AnyFunctionType>(func->getType ()->getCanonicalType ());
2194
2179
funcTy = cast<AnyFunctionType>(replaceDynamicSelfWithSelf (funcTy));
2195
- if (!withCaptures) return funcTy;
2196
2180
return getFunctionTypeWithCaptures (funcTy, func);
2197
2181
}
2198
2182
0 commit comments