@@ -1273,73 +1273,6 @@ EnumRawValuesRequest::evaluate(Evaluator &eval, EnumDecl *ED,
1273
1273
return std::make_tuple<>();
1274
1274
}
1275
1275
1276
- bool SimpleDidSetRequest::evaluate (Evaluator &evaluator,
1277
- AccessorDecl *decl) const {
1278
-
1279
- class OldValueFinder : public ASTWalker {
1280
- const ParamDecl *OldValueParam;
1281
- bool foundOldValueRef = false ;
1282
-
1283
- public:
1284
- OldValueFinder (const ParamDecl *param) : OldValueParam(param) {}
1285
-
1286
- virtual std::pair<bool , Expr *> walkToExprPre (Expr *E) override {
1287
- if (!E)
1288
- return {true , E};
1289
- if (auto DRE = dyn_cast<DeclRefExpr>(E)) {
1290
- if (auto decl = DRE->getDecl ()) {
1291
- if (decl == OldValueParam) {
1292
- foundOldValueRef = true ;
1293
- return {false , nullptr };
1294
- }
1295
- }
1296
- }
1297
-
1298
- return {true , E};
1299
- }
1300
-
1301
- bool didFindOldValueRef () { return foundOldValueRef; }
1302
- };
1303
-
1304
- // If this is not a didSet accessor, bail out.
1305
- if (decl->getAccessorKind () != AccessorKind::DidSet) {
1306
- return false ;
1307
- }
1308
-
1309
- // Always assume non-simple 'didSet' in code completion mode.
1310
- if (decl->getASTContext ().SourceMgr .hasCodeCompletionBuffer ())
1311
- return false ;
1312
-
1313
- // didSet must have a single parameter.
1314
- if (decl->getParameters ()->size () != 1 ) {
1315
- return false ;
1316
- }
1317
-
1318
- auto param = decl->getParameters ()->get (0 );
1319
- // If this parameter is not implicit, then it means it has been explicitly
1320
- // provided by the user (i.e. 'didSet(oldValue)'). This means we cannot
1321
- // consider this a "simple" didSet because we have to fetch the oldValue
1322
- // regardless of whether it's referenced in the body or not.
1323
- if (!param->isImplicit ()) {
1324
- return false ;
1325
- }
1326
-
1327
- // If we find a reference to the implicit 'oldValue' parameter, then it is
1328
- // not a "simple" didSet because we need to fetch it.
1329
- auto walker = OldValueFinder (param);
1330
- decl->getTypecheckedBody ()->walk (walker);
1331
- auto hasOldValueRef = walker.didFindOldValueRef ();
1332
- if (!hasOldValueRef) {
1333
- // If the body does not refer to implicit 'oldValue', it means we can
1334
- // consider this as a "simple" didSet. Let's also erase the implicit
1335
- // oldValue as it is never used.
1336
- auto &ctx = decl->getASTContext ();
1337
- decl->setParameters (ParameterList::createEmpty (ctx));
1338
- return true ;
1339
- }
1340
- return false ;
1341
- }
1342
-
1343
1276
const ConstructorDecl *
1344
1277
swift::findNonImplicitRequiredInit (const ConstructorDecl *CD) {
1345
1278
while (CD->isImplicit ()) {
0 commit comments