@@ -489,9 +489,11 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
489
489
// FIXME: Should restrict this to the source file we care about.
490
490
DeclContext *currentDC = current->getDeclContext ();
491
491
SourceFile *currentFile = currentDC->getParentSourceFile ();
492
- if (!currentFile || currentDC-> isLocalContext () )
492
+ if (!currentFile)
493
493
return std::make_tuple<>();
494
494
495
+ auto &ctx = current->getASTContext ();
496
+
495
497
// Find other potential definitions.
496
498
SmallVector<ValueDecl *, 4 > otherDefinitions;
497
499
if (currentDC->isTypeContext ()) {
@@ -500,7 +502,17 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
500
502
auto found = nominal->lookupDirect (current->getBaseName ());
501
503
otherDefinitions.append (found.begin (), found.end ());
502
504
}
505
+ } else if (currentDC->isLocalContext ()) {
506
+ if (ctx.LangOpts .DisableParserLookup ) {
507
+ if (!current->isImplicit ()) {
508
+ ASTScope::lookupLocalDecls (currentFile, current->getBaseName (),
509
+ current->getLoc (),
510
+ /* stopAfterInnermostBraceStmt=*/ true ,
511
+ otherDefinitions);
512
+ }
513
+ }
503
514
} else {
515
+ assert (currentDC->isModuleScopeContext ());
504
516
// Look within a module context.
505
517
currentFile->getParentModule ()->lookupValue (current->getBaseName (),
506
518
NLKind::QualifiedLookup,
@@ -512,7 +524,6 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
512
524
OverloadSignature currentSig = current->getOverloadSignature ();
513
525
CanType currentSigType = current->getOverloadSignatureType ();
514
526
ModuleDecl *currentModule = current->getModuleContext ();
515
- auto &ctx = current->getASTContext ();
516
527
for (auto other : otherDefinitions) {
517
528
// Skip invalid declarations and ourselves.
518
529
//
@@ -547,7 +558,8 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
547
558
// shadows a non-private one, but only in the file where the shadowing
548
559
// happens. We will warn on conflicting non-private declarations in both
549
560
// files.
550
- if (!other->isAccessibleFrom (currentDC))
561
+ if (!currentDC->isLocalContext () &&
562
+ !other->isAccessibleFrom (currentDC))
551
563
continue ;
552
564
553
565
// Skip invalid declarations.
0 commit comments