mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Scope map] A local property name is in scope within its own accessors.
While the use of a local property from within its own accessors is a bit dubious, Swift 3 only warned on it, so model the existing lookup behavior in the scope map.
This commit is contained in:
@@ -918,26 +918,20 @@ VarDecl *PatternBindingEntry::getAnchoringVarDecl() const {
|
||||
return variables[0];
|
||||
}
|
||||
|
||||
SourceRange PatternBindingEntry::getSourceRange() const {
|
||||
ASTContext *ctx = nullptr;
|
||||
SourceRange PatternBindingEntry::getSourceRange(bool omitAccessors) const {
|
||||
// Patterns end at the initializer, if present.
|
||||
SourceLoc endLoc = getOrigInitRange().End;
|
||||
|
||||
SourceLoc endLoc;
|
||||
getPattern()->forEachVariable([&](VarDecl *var) {
|
||||
auto accessorsEndLoc = var->getBracesRange().End;
|
||||
if (accessorsEndLoc.isValid()) {
|
||||
endLoc = accessorsEndLoc;
|
||||
if (!ctx) ctx = &var->getASTContext();
|
||||
}
|
||||
});
|
||||
// If we're not banned from handling accessors, they follow the initializer.
|
||||
if (!omitAccessors) {
|
||||
getPattern()->forEachVariable([&](VarDecl *var) {
|
||||
auto accessorsEndLoc = var->getBracesRange().End;
|
||||
if (accessorsEndLoc.isValid())
|
||||
endLoc = accessorsEndLoc;
|
||||
});
|
||||
}
|
||||
|
||||
// Check the initializer.
|
||||
SourceLoc initEndLoc = getOrigInitRange().End;
|
||||
if (initEndLoc.isValid() &&
|
||||
(endLoc.isInvalid() ||
|
||||
(ctx && ctx->SourceMgr.isBeforeInBuffer(endLoc, initEndLoc))))
|
||||
endLoc = initEndLoc;
|
||||
|
||||
// Check the pattern.
|
||||
// If we didn't find an end yet, check the pattern.
|
||||
if (endLoc.isInvalid())
|
||||
endLoc = getPattern()->getEndLoc();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user