Skip to content

Commit 2f2bbfb

Browse files
author
David Ungar
committed
Better method scope lookup
1 parent 16ca723 commit 2f2bbfb

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

include/swift/AST/ASTScope.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,8 @@ class MethodBodyScope final : public AbstractFunctionBodyScope {
828828
public:
829829
MethodBodyScope(AbstractFunctionDecl *e) : AbstractFunctionBodyScope(e) {}
830830
std::string getClassName() const override;
831+
bool lookupLocalBindings(Optional<bool>,
832+
DeclConsumer consumer) const override;
831833

832834
protected:
833835
NullablePtr<DeclContext>

lib/AST/ASTScopeLookup.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,22 @@ bool AbstractFunctionBodyScope::lookupLocalBindings(
377377
isCascadingUse))
378378
return true;
379379
}
380-
if (auto *s = decl->getImplicitSelfDecl()) {
381-
if (consumer.consume({s}, DeclVisibilityKind::FunctionParameter,
382-
isCascadingUse))
383-
return true;
384-
}
385380
return false;
386381
}
387382

383+
bool MethodBodyScope::lookupLocalBindings(Optional<bool> isCascadingUse,
384+
DeclConsumer consumer) const {
385+
assert(decl->getImplicitSelfDecl());
386+
if (AbstractFunctionBodyScope::lookupLocalBindings(isCascadingUse, consumer))
387+
return true;
388+
return consumer.consume({decl->getImplicitSelfDecl()},
389+
DeclVisibilityKind::FunctionParameter,
390+
isCascadingUse);
391+
}
392+
388393
bool PureFunctionBodyScope::lookupLocalBindings(Optional<bool> isCascadingUse,
389394
DeclConsumer consumer) const {
395+
assert(!decl->getImplicitSelfDecl());
390396
if (AbstractFunctionBodyScope::lookupLocalBindings(isCascadingUse, consumer))
391397
return true;
392398

0 commit comments

Comments
 (0)