|
27 | 27 | #include "swift/Basic/STLExtras.h"
|
28 | 28 | #include "swift/Basic/SourceManager.h"
|
29 | 29 | #include "swift/Basic/Statistic.h"
|
| 30 | +#include "swift/Parse/Lexer.h" |
30 | 31 | #include "llvm/ADT/DenseMap.h"
|
31 | 32 | #include "llvm/ADT/TinyPtrVector.h"
|
32 | 33 | #include "llvm/Support/Debug.h"
|
@@ -147,7 +148,7 @@ namespace {
|
147 | 148 |
|
148 | 149 | #pragma mark context-based lookup declarations
|
149 | 150 |
|
150 |
| - bool isOutsideBodyOfFunction(const AbstractFunctionDecl *const AFD) const; |
| 151 | + bool isInsideBodyOfFunction(const AbstractFunctionDecl *const AFD) const; |
151 | 152 |
|
152 | 153 | /// For diagnostic purposes, move aside the unavailables, and put
|
153 | 154 | /// them back as a last-ditch effort.
|
@@ -319,11 +320,11 @@ void UnqualifiedLookupFactory::lookUpTopLevelNamesInModuleScopeContext(
|
319 | 320 |
|
320 | 321 | #pragma mark context-based lookup definitions
|
321 | 322 |
|
322 |
| -bool UnqualifiedLookupFactory::isOutsideBodyOfFunction( |
| 323 | +bool UnqualifiedLookupFactory::isInsideBodyOfFunction( |
323 | 324 | const AbstractFunctionDecl *const AFD) const {
|
324 |
| - return !AFD->isImplicit() && Loc.isValid() && |
325 |
| - AFD->getBodySourceRange().isValid() && |
326 |
| - !SM.rangeContainsTokenLoc(AFD->getBodySourceRange(), Loc); |
| 325 | + auto range = Lexer::getCharSourceRangeFromSourceRange( |
| 326 | + SM, AFD->getBodySourceRange()); |
| 327 | + return range.contains(Loc); |
327 | 328 | }
|
328 | 329 |
|
329 | 330 | void UnqualifiedLookupFactory::ResultFinderForTypeContext::findResults(
|
@@ -635,7 +636,7 @@ bool ASTScopeDeclConsumerForUnqualifiedLookup::lookInMembers(
|
635 | 636 | NominalTypeDecl *const nominal) {
|
636 | 637 | if (candidateSelfDC) {
|
637 | 638 | if (auto *afd = dyn_cast<AbstractFunctionDecl>(candidateSelfDC)) {
|
638 |
| - assert(!factory.isOutsideBodyOfFunction(afd) && "Should be inside"); |
| 639 | + assert(factory.isInsideBodyOfFunction(afd) && "Should be inside"); |
639 | 640 | }
|
640 | 641 | }
|
641 | 642 |
|
|
0 commit comments