@@ -1188,109 +1188,6 @@ namespace {
1188
1188
thunkTy, locator);
1189
1189
}
1190
1190
1191
- AutoClosureExpr *buildPropertyWrapperFnThunk (
1192
- Expr *fnRef, FunctionType *fnType, AnyFunctionRef fnDecl, ConcreteDeclRef ref,
1193
- ArrayRef<AppliedPropertyWrapper> appliedPropertyWrappers) {
1194
- auto &context = cs.getASTContext ();
1195
- auto paramInfo = fnType->getParams ();
1196
-
1197
- SmallVector<Argument, 4 > args;
1198
-
1199
- auto *innerParams = fnDecl.getParameters ();
1200
- SmallVector<AnyFunctionType::Param, 4 > innerParamTypes;
1201
-
1202
- OptionSet<ParameterList::CloneFlags> options
1203
- = (ParameterList::Implicit |
1204
- ParameterList::NamedArguments);
1205
- auto *outerParams = innerParams->clone (context, options);
1206
- SmallVector<AnyFunctionType::Param, 4 > outerParamTypes;
1207
-
1208
- unsigned appliedWrapperIndex = 0 ;
1209
- for (auto i : indices (*innerParams)) {
1210
- auto *innerParam = innerParams->get (i);
1211
- auto *outerParam = outerParams->get (i);
1212
- auto outerParamType = paramInfo[i].getPlainType ();
1213
-
1214
- Expr *paramRef = new (context) DeclRefExpr (outerParam, DeclNameLoc (),
1215
- /* implicit=*/ true );
1216
- paramRef->setType (outerParam->isInOut ()
1217
- ? LValueType::get (outerParamType) : outerParamType);
1218
- cs.cacheType (paramRef);
1219
-
1220
- if (innerParam->hasAttachedPropertyWrapper ()) {
1221
- // Rewrite the parameter ref to the backing wrapper initialization
1222
- // expression.
1223
- auto appliedWrapper = appliedPropertyWrappers[appliedWrapperIndex++];
1224
- auto wrapperType = appliedWrapper.wrapperType ;
1225
- auto initKind = appliedWrapper.initKind ;
1226
-
1227
- using ValueKind = AppliedPropertyWrapperExpr::ValueKind;
1228
- ValueKind valueKind = (initKind == PropertyWrapperInitKind::ProjectedValue ?
1229
- ValueKind::ProjectedValue : ValueKind::WrappedValue);
1230
-
1231
- paramRef = AppliedPropertyWrapperExpr::create (context, ref, innerParam, SourceLoc (),
1232
- wrapperType, paramRef, valueKind);
1233
- cs.cacheExprTypes (paramRef);
1234
-
1235
- // SILGen knows how to emit property-wrapped parameters, but the
1236
- // function type needs the backing wrapper type in its param list.
1237
- innerParamTypes.push_back (AnyFunctionType::Param (
1238
- paramRef->getType (), innerParam->getArgumentName (),
1239
- ParameterTypeFlags (), innerParam->getParameterName ()));
1240
- } else {
1241
- // Rewrite the parameter ref if necessary.
1242
- if (outerParam->isInOut ()) {
1243
- paramRef = new (context) InOutExpr (SourceLoc (), paramRef,
1244
- outerParamType, /* implicit=*/ true );
1245
- } else if (innerParam->isVariadic ()) {
1246
- assert (outerParamType->isEqual (paramRef->getType ()));
1247
- paramRef = VarargExpansionExpr::createParamExpansion (context, paramRef);
1248
- }
1249
- cs.cacheType (paramRef);
1250
-
1251
- innerParamTypes.push_back (innerParam->toFunctionParam ());
1252
- }
1253
-
1254
- // The outer parameters are for an autoclosure, which shouldn't have
1255
- // argument labels.
1256
- outerParamTypes.push_back (AnyFunctionType::Param (outerParamType,
1257
- Identifier (),
1258
- paramInfo[i].getParameterFlags ()));
1259
- outerParam->setInterfaceType (outerParamType->mapTypeOutOfContext ());
1260
-
1261
- Identifier label;
1262
- if (fnDecl.getAbstractFunctionDecl ())
1263
- label = innerParam->getArgumentName ();
1264
-
1265
- args.emplace_back (SourceLoc (), label, paramRef);
1266
- }
1267
-
1268
- // FIXME: Verify ExtInfo state is correct, not working by accident.
1269
- FunctionType::ExtInfo fnInfo;
1270
- fnRef->setType (
1271
- FunctionType::get (innerParamTypes, fnType->getResult (), fnInfo));
1272
- cs.cacheType (fnRef);
1273
-
1274
- auto *argList = ArgumentList::createImplicit (context, args);
1275
- auto *fnCall = CallExpr::createImplicit (context, fnRef, argList);
1276
- fnCall->setType (fnType->getResult ());
1277
- cs.cacheType (fnCall);
1278
-
1279
- auto discriminator = AutoClosureExpr::InvalidDiscriminator;
1280
-
1281
- // FIXME: Verify ExtInfo state is correct, not working by accident.
1282
- FunctionType::ExtInfo closureInfo;
1283
- auto *autoClosureType =
1284
- FunctionType::get (outerParamTypes, fnType->getResult (), closureInfo);
1285
- auto *autoClosure = new (context)
1286
- AutoClosureExpr (fnCall, autoClosureType, discriminator, dc);
1287
- autoClosure->setParameterList (outerParams);
1288
- autoClosure->setThunkKind (AutoClosureExpr::Kind::SingleCurryThunk);
1289
- cs.cacheType (autoClosure);
1290
-
1291
- return autoClosure;
1292
- }
1293
-
1294
1191
AutoClosureExpr *buildCurryThunk (ValueDecl *member,
1295
1192
FunctionType *selfFnTy,
1296
1193
Expr *selfParamRef,
0 commit comments