@@ -222,7 +222,7 @@ bool ASTScopeImpl::lookInGenericParametersOf(
222
222
SmallVector<ValueDecl *, 32 > bindings;
223
223
for (auto *param : paramList.get ()->getParams ())
224
224
bindings.push_back (param);
225
- if (consumer.consume (bindings, DeclVisibilityKind::GenericParameter ))
225
+ if (consumer.consume (bindings))
226
226
return true ;
227
227
return false ;
228
228
}
@@ -289,28 +289,26 @@ PatternEntryInitializerScope::getLookupParent() const {
289
289
290
290
bool GenericParamScope::lookupLocalsOrMembers (DeclConsumer consumer) const {
291
291
auto *param = paramList->getParams ()[index];
292
- return consumer.consume ({param}, DeclVisibilityKind::GenericParameter );
292
+ return consumer.consume ({param});
293
293
}
294
294
295
295
bool PatternEntryDeclScope::lookupLocalsOrMembers (DeclConsumer consumer) const {
296
- if (vis != DeclVisibilityKind::LocalVariable )
297
- return false ; // look in self type will find this later
298
- return lookupLocalBindingsInPattern (getPattern (), vis, consumer);
296
+ if (!isLocalBinding )
297
+ return false ;
298
+ return lookupLocalBindingsInPattern (getPattern (), consumer);
299
299
}
300
300
301
301
bool ForEachPatternScope::lookupLocalsOrMembers (DeclConsumer consumer) const {
302
- return lookupLocalBindingsInPattern (
303
- stmt->getPattern (), DeclVisibilityKind::LocalVariable, consumer);
302
+ return lookupLocalBindingsInPattern (stmt->getPattern (), consumer);
304
303
}
305
304
306
305
bool CaseLabelItemScope::lookupLocalsOrMembers (DeclConsumer consumer) const {
307
- return lookupLocalBindingsInPattern (
308
- item.getPattern (), DeclVisibilityKind::LocalVariable, consumer);
306
+ return lookupLocalBindingsInPattern (item.getPattern (), consumer);
309
307
}
310
308
311
309
bool CaseStmtBodyScope::lookupLocalsOrMembers (DeclConsumer consumer) const {
312
310
for (auto *var : stmt->getCaseBodyVariablesOrEmptyArray ())
313
- if (consumer.consume ({var}, DeclVisibilityKind::LocalVariable ))
311
+ if (consumer.consume ({var}))
314
312
return true ;
315
313
316
314
return false ;
@@ -320,13 +318,12 @@ bool FunctionBodyScope::lookupLocalsOrMembers(
320
318
DeclConsumer consumer) const {
321
319
if (auto *paramList = decl->getParameters ()) {
322
320
for (auto *paramDecl : *paramList)
323
- if (consumer.consume ({paramDecl}, DeclVisibilityKind::FunctionParameter ))
321
+ if (consumer.consume ({paramDecl}))
324
322
return true ;
325
323
}
326
324
327
325
if (decl->getDeclContext ()->isTypeContext ()) {
328
- return consumer.consume ({decl->getImplicitSelfDecl ()},
329
- DeclVisibilityKind::FunctionParameter);
326
+ return consumer.consume ({decl->getImplicitSelfDecl ()});
330
327
}
331
328
332
329
// Consider \c var t: T { (did/will/)get/set { ... t }}
@@ -335,7 +332,7 @@ bool FunctionBodyScope::lookupLocalsOrMembers(
335
332
// then t needs to be found as a local binding:
336
333
if (auto *accessor = dyn_cast<AccessorDecl>(decl)) {
337
334
if (auto *storage = accessor->getStorage ())
338
- if (consumer.consume ({storage}, DeclVisibilityKind::LocalVariable ))
335
+ if (consumer.consume ({storage}))
339
336
return true ;
340
337
}
341
338
@@ -346,7 +343,7 @@ bool SpecializeAttributeScope::lookupLocalsOrMembers(
346
343
DeclConsumer consumer) const {
347
344
if (auto *params = whatWasSpecialized->getGenericParams ())
348
345
for (auto *param : params->getParams ())
349
- if (consumer.consume ({param}, DeclVisibilityKind::GenericParameter ))
346
+ if (consumer.consume ({param}))
350
347
return true ;
351
348
return false ;
352
349
}
@@ -356,7 +353,7 @@ bool DifferentiableAttributeScope::lookupLocalsOrMembers(
356
353
auto visitAbstractFunctionDecl = [&](AbstractFunctionDecl *afd) {
357
354
if (auto *params = afd->getGenericParams ())
358
355
for (auto *param : params->getParams ())
359
- if (consumer.consume ({param}, DeclVisibilityKind::GenericParameter ))
356
+ if (consumer.consume ({param}))
360
357
return true ;
361
358
return false ;
362
359
};
@@ -371,20 +368,10 @@ bool DifferentiableAttributeScope::lookupLocalsOrMembers(
371
368
}
372
369
373
370
bool BraceStmtScope::lookupLocalsOrMembers (DeclConsumer consumer) const {
374
- // All types and functions are visible anywhere within a brace statement
375
- // scope. When ordering matters (i.e. var decl) we will have split the brace
376
- // statement into nested scopes.
377
- //
378
- // Don't stop at the first one, there may be local funcs with same base name
379
- // and want them all.
380
- SmallVector<ValueDecl *, 32 > localBindings;
381
- for (auto braceElement : stmt->getElements ()) {
382
- if (auto localBinding = braceElement.dyn_cast <Decl *>()) {
383
- if (auto *vd = dyn_cast<ValueDecl>(localBinding))
384
- localBindings.push_back (vd);
385
- }
386
- }
387
- if (consumer.consume (localBindings, DeclVisibilityKind::LocalVariable))
371
+ if (consumer.consume (localFuncsAndTypes))
372
+ return true ;
373
+
374
+ if (consumer.consumePossiblyNotInScope (localVars))
388
375
return true ;
389
376
390
377
if (consumer.finishLookupInBraceStmt (stmt))
@@ -400,18 +387,15 @@ bool PatternEntryInitializerScope::lookupLocalsOrMembers(
400
387
decl->getInitContext (0 ));
401
388
if (initContext) {
402
389
if (auto *selfParam = initContext->getImplicitSelfDecl ()) {
403
- return consumer.consume ({selfParam},
404
- DeclVisibilityKind::FunctionParameter);
390
+ return consumer.consume ({selfParam});
405
391
}
406
392
}
407
393
return false ;
408
394
}
409
395
410
396
bool CaptureListScope::lookupLocalsOrMembers (DeclConsumer consumer) const {
411
397
for (auto &e : expr->getCaptureList ()) {
412
- if (consumer.consume (
413
- {e.Var },
414
- DeclVisibilityKind::LocalVariable)) // or FunctionParameter??
398
+ if (consumer.consume ({e.Var }))
415
399
return true ;
416
400
}
417
401
return false ;
@@ -420,26 +404,24 @@ bool CaptureListScope::lookupLocalsOrMembers(DeclConsumer consumer) const {
420
404
bool ClosureParametersScope::lookupLocalsOrMembers (
421
405
DeclConsumer consumer) const {
422
406
for (auto param : *closureExpr->getParameters ())
423
- if (consumer.consume ({param}, DeclVisibilityKind::FunctionParameter ))
407
+ if (consumer.consume ({param}))
424
408
return true ;
425
409
return false ;
426
410
}
427
411
428
412
bool ConditionalClausePatternUseScope::lookupLocalsOrMembers (
429
413
DeclConsumer consumer) const {
430
- return lookupLocalBindingsInPattern (
431
- pattern, DeclVisibilityKind::LocalVariable, consumer);
414
+ return lookupLocalBindingsInPattern (pattern, consumer);
432
415
}
433
416
434
417
bool ASTScopeImpl::lookupLocalBindingsInPattern (const Pattern *p,
435
- DeclVisibilityKind vis,
436
418
DeclConsumer consumer) {
437
419
if (!p)
438
420
return false ;
439
421
bool isDone = false ;
440
422
p->forEachVariable ([&](VarDecl *var) {
441
423
if (!isDone)
442
- isDone = consumer.consume ({var}, vis );
424
+ isDone = consumer.consume ({var});
443
425
});
444
426
return isDone;
445
427
}
0 commit comments