Skip to content

Commit 4a30637

Browse files
committed
[CodeCompletion] Don't complete unavailable methods in override
We generally don't want to override unavailable methods. We already filter out unavailable decls when completing values, but that's in a separate visible decl consumer. rdar://problem/25058233
1 parent 2840478 commit 4a30637

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3795,6 +3795,9 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer {
37953795
if (Reason == DeclVisibilityKind::MemberOfCurrentNominal)
37963796
return;
37973797

3798+
if (AvailableAttr::isUnavailable(D))
3799+
return;
3800+
37983801
if (D->getAttrs().hasAttribute<FinalAttr>())
37993802
return;
38003803

test/IDE/complete_not_recommended.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
// CHECK1: Decl[Constructor]/CurrNominal: init()[#A#]; name=init(){{$}}
55
// CHECK1: End completions
66

7+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=OVERRIDE_1 | FileCheck %s -check-prefix=OVERRIDE_1
8+
79
class A {
810
func foo() {}
911
@available(*, unavailable) func unavail() {}
@@ -12,3 +14,12 @@ class A {
1214
func glob() {
1315
A.#^MEMBER^#
1416
}
17+
18+
class B : A {
19+
override func #^OVERRIDE_1^#
20+
// OVERRIDE_1: Begin completions
21+
// OVERRIDE_1-NOT: Decl[InstanceMethod]
22+
// OVERRIDE_1: Decl[InstanceMethod]/Super: foo() {|};
23+
// OVERRIDE_1-NOT: Decl[InstanceMethod]
24+
// OVERRIDE_1: End completions
25+
}

0 commit comments

Comments
 (0)