Skip to content

Commit 318f772

Browse files
committed
Check The DeclContext When Retrieving Conforming Decls
Checking for staticness is not enough because top-level decls count as non-static yet do not have a sufficient curry level to satisfy this check. Make sure we're looking for decls that reside inside of types. rdar://75299825, SR-14327
1 parent 4c7059f commit 318f772

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/IDE/ConformingMethodList.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ void ConformingMethodListCallbacks::doneParsing() {
9090
if (T->hasArchetype())
9191
T = T->mapTypeOutOfContext();
9292

93+
// If there are no (instance) members for this type, bail.
94+
if (!T->mayHaveMembers() || T->is<ModuleType>()) {
95+
return;
96+
}
97+
9398
llvm::SmallPtrSet<ProtocolDecl*, 8> expectedProtocols;
9499
for (auto Name: ExpectedTypeNames) {
95100
if (auto *PD = resolveProtocolName(CurDeclContext, Name)) {
@@ -107,8 +112,7 @@ void ConformingMethodListCallbacks::doneParsing() {
107112
void ConformingMethodListCallbacks::getMatchingMethods(
108113
Type T, llvm::SmallPtrSetImpl<ProtocolDecl*> &expectedTypes,
109114
SmallVectorImpl<ValueDecl *> &result) {
110-
if (!T->mayHaveMembers())
111-
return;
115+
assert(T->mayHaveMembers() && !T->is<ModuleType>());
112116

113117
class LocalConsumer : public VisibleDeclConsumer {
114118
ModuleDecl *CurModule;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: %target-swift-ide-test --conforming-methods --conforming-methods-expected-types=s:SQ -source-filename %s -code-completion-token=COMPLETE
2+
3+
Swift#^COMPLETE^#

0 commit comments

Comments
 (0)