Skip to content

Commit 6187c9e

Browse files
committed
[CodeComplete] Show global completions from modules that are imported as @_spi
If a module is imported as `@_spi`, we didn’t receive any global completions from it. rdar://99027179
1 parent f680ddc commit 6187c9e

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,9 +1351,12 @@ void swift::ide::deliverCompletionResults(
13511351
// Add results for all imported modules.
13521352
SmallVector<ImportedModule, 4> Imports;
13531353
SF.getImportedModules(
1354-
Imports, {ModuleDecl::ImportFilterKind::Exported,
1355-
ModuleDecl::ImportFilterKind::Default,
1356-
ModuleDecl::ImportFilterKind::ImplementationOnly});
1354+
Imports, {
1355+
ModuleDecl::ImportFilterKind::Exported,
1356+
ModuleDecl::ImportFilterKind::Default,
1357+
ModuleDecl::ImportFilterKind::ImplementationOnly,
1358+
ModuleDecl::ImportFilterKind::SPIAccessControl,
1359+
});
13571360

13581361
for (auto Imported : Imports) {
13591362
for (auto Import : namelookup::getAllImports(Imported.importedModule))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %empty-directory(%t/split)
2+
// RUN: %empty-directory(%t/build)
3+
// RUN: %{python} %utils/split_file.py -o %t/split %s
4+
5+
// RUN: %target-swift-frontend -emit-module -o %t/build %t/split/pck.swift
6+
7+
// RUN: %target-swift-ide-test -code-completion -source-filename %t/split/test.swift -I %t/build -code-completion-token=COMPLETE | %FileCheck %s
8+
9+
// BEGIN pck.swift
10+
11+
public func apiFunc() {}
12+
13+
@_spi(MySPI)
14+
public func spiFunc() {}
15+
16+
// BEGIN test.swift
17+
18+
@_spi(MySPI) import pck
19+
20+
func test() {
21+
#^COMPLETE^#
22+
}
23+
24+
// CHECK: Begin completions
25+
// CHECK-DAG: Decl[FreeFunction]/OtherModule[pck]: apiFunc()[#Void#]; name=apiFunc()
26+
// CHECK-DAG: Decl[FreeFunction]/OtherModule[pck]: spiFunc()[#Void#]; name=spiFunc()
27+
// CHECK: End completions

0 commit comments

Comments
 (0)