Skip to content

Commit cf43a56

Browse files
committed
[CodeCompletion] Check visibility in lookup mode when collecting value requirements
1 parent ca686a5 commit cf43a56

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/Sema/LookupVisibleDecls.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,9 @@ static void lookupDeclsFromProtocolsBeingConformedTo(
434434
continue;
435435
}
436436
if (auto *VD = dyn_cast<ValueDecl>(Member)) {
437+
if (!isDeclVisibleInLookupMode(VD, LS, FromContext))
438+
continue;
439+
437440
if (!VD->isProtocolRequirement())
438441
continue;
439442

test/IDE/complete_value_expr.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@
200200
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_DICTIONARY_LITERAL_1 | %FileCheck %s -check-prefix=SIMPLE_OBJECT_DOT
201201
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_DICTIONARY_LITERAL_2 | %FileCheck %s -check-prefix=SIMPLE_OBJECT_DOT
202202
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE_CALL_RESULT | %FileCheck %s -check-prefix=COMPLETE_CALL_RESULT
203+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-keywords=false -code-completion-token=BROKEN_CONFORMANCE | %FileCheck %s -check-prefix=BROKEN_CONFORMANCE
203204

204205
// Test code completion of expressions that produce a value.
205206

@@ -2185,3 +2186,19 @@ func testWrapSuccess(promise: Int, seal: Resolver<Void>) {
21852186
// COMPLETE_CALL_RESULT: Pattern/CurrModule: ({#Void#}, {#Bool#})[#Void#]; name=(Void, Bool)
21862187
// COMPLETE_CALL_RESULT: End completions
21872188
}
2189+
2190+
protocol BrokenConformanceP {
2191+
static func staticFunc()
2192+
func instanceFunc()
2193+
}
2194+
extension BrokenConformanceP {
2195+
static func staticFuncExtension() {}
2196+
}
2197+
struct BrokenConformanceS: BrokenConformanceP {
2198+
}
2199+
func testBrokenConformance(arg: BrokenConformanceS) {
2200+
arg.#^BROKEN_CONFORMANCE^#
2201+
// BROKEN_CONFORMANCE: Begin completions, 1 items
2202+
// BROKEN_CONFORMANCE: Decl[InstanceMethod]/Super: instanceFunc()[#Void#];
2203+
// BROKEN_CONFORMANCE: End completions
2204+
}

0 commit comments

Comments
 (0)