Skip to content

Commit 0dc8e20

Browse files
authored
Merge pull request swiftlang#37125 from rintaro/ide-completion-rdar74233797
[Completion] Look through implicit expr when collecting possible callees
2 parents 246bb41 + a08e3e5 commit 0dc8e20

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,9 @@ static void collectPossibleCalleesByQualifiedLookup(
533533
SmallVectorImpl<FunctionTypeAndDecl> &candidates) {
534534
ConcreteDeclRef ref = nullptr;
535535

536+
if (auto ice = dyn_cast<ImplicitConversionExpr>(baseExpr))
537+
baseExpr = ice->getSyntacticSubExpr();
538+
536539
// Re-typecheck TypeExpr so it's typechecked without the arguments which may
537540
// affects the inference of the generic arguments.
538541
if (TypeExpr *tyExpr = dyn_cast<TypeExpr>(baseExpr)) {

test/IDE/complete_init_inherited.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TEST_D | %FileCheck %s -check-prefix=TEST_D
55
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TEST_D_DOT | %FileCheck %s -check-prefix=TEST_D_DOT
66
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=TEST_D_PAREN | %FileCheck %s -check-prefix=TEST_D_PAREN
7+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=METATYPE_CONVERSION | %FileCheck %s -check-prefix=METATYPE_CONVERSION
78

89
class A {
910
init(int i: Int) {}
@@ -96,3 +97,19 @@ func testD() {
9697
D.#^TEST_D_DOT^#
9798
D(#^TEST_D_PAREN^#
9899
}
100+
101+
class R74233797Base {
102+
init() {}
103+
convenience init(_ test: Bool) { self.init() }
104+
}
105+
class R74233797Derived : R74233797Base {
106+
convenience init(sub: Bool) { self.init(sub) }
107+
}
108+
func testR74233797() {
109+
R74233797Derived(#^METATYPE_CONVERSION^#)
110+
// METATYPE_CONVERSION: Begin completions
111+
// METATYPE_CONVERSION-DAG: Decl[Constructor]/CurrNominal: ['(']{#sub: Bool#}[')'][#R74233797Derived#];
112+
// METATYPE_CONVERSION-DAG: Decl[Constructor]/CurrNominal: ['('][')'][#R74233797Derived#];
113+
// METATYPE_CONVERSION-DAG: Decl[Constructor]/Super: ['(']{#(test): Bool#}[')'][#R74233797Base#];
114+
// METATYPE_CONVERSION: End completions
115+
}

0 commit comments

Comments
 (0)