@@ -489,9 +489,11 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
489489 // FIXME: Should restrict this to the source file we care about.
490490 DeclContext *currentDC = current->getDeclContext ();
491491 SourceFile *currentFile = currentDC->getParentSourceFile ();
492- if (!currentFile || currentDC-> isLocalContext () )
492+ if (!currentFile)
493493 return std::make_tuple<>();
494494
495+ auto &ctx = current->getASTContext ();
496+
495497 // Find other potential definitions.
496498 SmallVector<ValueDecl *, 4 > otherDefinitions;
497499 if (currentDC->isTypeContext ()) {
@@ -500,7 +502,17 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
500502 auto found = nominal->lookupDirect (current->getBaseName ());
501503 otherDefinitions.append (found.begin (), found.end ());
502504 }
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+ }
503514 } else {
515+ assert (currentDC->isModuleScopeContext ());
504516 // Look within a module context.
505517 currentFile->getParentModule ()->lookupValue (current->getBaseName (),
506518 NLKind::QualifiedLookup,
@@ -512,7 +524,6 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
512524 OverloadSignature currentSig = current->getOverloadSignature ();
513525 CanType currentSigType = current->getOverloadSignatureType ();
514526 ModuleDecl *currentModule = current->getModuleContext ();
515- auto &ctx = current->getASTContext ();
516527 for (auto other : otherDefinitions) {
517528 // Skip invalid declarations and ourselves.
518529 //
@@ -547,7 +558,8 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
547558 // shadows a non-private one, but only in the file where the shadowing
548559 // happens. We will warn on conflicting non-private declarations in both
549560 // files.
550- if (!other->isAccessibleFrom (currentDC))
561+ if (!currentDC->isLocalContext () &&
562+ !other->isAccessibleFrom (currentDC))
551563 continue ;
552564
553565 // Skip invalid declarations.
0 commit comments