Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/Sema/LookupVisibleDecls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,10 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer {
OtherSignature, OtherSignatureType,
/*wouldConflictInSwift5*/nullptr,
/*skipProtocolExtensionCheck*/true)) {
if (VD->getFormalAccess() > OtherVD->getFormalAccess()) {
if (VD->getFormalAccess() > OtherVD->getFormalAccess() ||
//Prefer available one.
(!AvailableAttr::isUnavailable(VD) &&
AvailableAttr::isUnavailable(OtherVD))) {
PossiblyConflicting.erase(I);
PossiblyConflicting.insert(VD);

Expand Down
33 changes: 33 additions & 0 deletions test/IDE/complete_constructor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CLOSURE_IN_INIT_3 | %FileCheck %s -check-prefix=CLOSURE_IN_INIT_1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CLOSURE_IN_INIT_4 | %FileCheck %s -check-prefix=CLOSURE_IN_INIT_1

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=AVAILABLE_1 | %FileCheck %s -check-prefix=AVAILABLE_1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=AVAILABLE_2 | %FileCheck %s -check-prefix=AVAILABLE_2

func freeFunc() {}

//===---
Expand Down Expand Up @@ -332,3 +335,33 @@ struct ClosureInInit1 {
S(#^CLOSURE_IN_INIT_4^#
}()
}

public class AvailableTest {

@available(swift, obsoleted: 4)
init(opt: Int) { }

@available(swift, introduced: 4)
init?(opt: Int) { }

init(normal1: Int) { }
init(normal2: Int) { }


}
func testAvailable() {
let _ = AvailableTest(#^AVAILABLE_1^#
// AVAILABLE_1: Begin completions, 3 items
// AVAILABLE_1-DAG: Decl[Constructor]/CurrNominal: ['(']{#opt: Int#}[')'][#AvailableTest?#]; name=opt: Int
// AVAILABLE_1-DAG: Decl[Constructor]/CurrNominal: ['(']{#normal1: Int#}[')'][#AvailableTest#]; name=normal1: Int
// AVAILABLE_1-DAG: Decl[Constructor]/CurrNominal: ['(']{#normal2: Int#}[')'][#AvailableTest#]; name=normal2: Int
// AVAILABLE_1: End completions

let _ = AvailableTest.init(#^AVAILABLE_2^#
// AVAILABLE_2: Begin completions, 3 items
// AVAILABLE_2-DAG: Pattern/CurrModule: ['(']{#opt: Int#}[')'][#AvailableTest?#]; name=opt: Int
// AVAILABLE_2-DAG: Pattern/CurrModule: ['(']{#normal1: Int#}[')'][#AvailableTest#]; name=normal1: Int
// AVAILABLE_2-DAG: Pattern/CurrModule: ['(']{#normal2: Int#}[')'][#AvailableTest#]; name=normal2: Int
// AVAILABLE_2: End completions

}