Skip to content

Commit 19b704b

Browse files
authored
Merge pull request swiftlang#25886 from rintaro/ide-complettion-gettypeofmember-rdar52386176
[CodeCompletion] Fix a crash in callee analysis
2 parents 7a0b895 + dfc4d77 commit 19b704b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,10 @@ static void collectPossibleCalleesByQualifiedLookup(
307307
}
308308
}
309309

310-
auto fnType = baseTy->getMetatypeInstanceType()->getTypeOfMember(
311-
DC.getParentModule(), VD, declaredMemberType);
312-
310+
auto subs = baseTy->getMetatypeInstanceType()->getMemberSubstitutionMap(
311+
DC.getParentModule(), VD,
312+
VD->getInnermostDeclContext()->getGenericEnvironmentOfContext());
313+
auto fnType = declaredMemberType.subst(subs, SubstFlags::UseErrorType);
313314
if (!fnType)
314315
continue;
315316

test/IDE/complete_call_arg.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_SECOND | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SECOND
8484
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IMPLICIT_MEMBER_SKIPPED | %FileCheck %s -check-prefix=IMPLICIT_MEMBER_SKIPPED
8585

86+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ARCHETYPE_GENERIC_1 | %FileCheck %s -check-prefix=ARCHETYPE_GENERIC_1
87+
8688
var i1 = 1
8789
var i2 = 2
8890
var oi1 : Int?
@@ -686,3 +688,12 @@ func testImplicitMember() {
686688
// IMPLICIT_MEMBER_SKIPPED: Keyword/ExprSpecific: arg4: [#Argument name#];
687689
// IMPLICIT_MEMBER_SKIPPED: End completions
688690
}
691+
692+
struct Wrap<T> {
693+
func method<U>(_ fn: (T) -> U) -> Wrap<U> {}
694+
}
695+
func testGenricMethodOnGenericOfArchetype<Wrapped>(value: Wrap<Wrapped>) {
696+
value.method(#^ARCHETYPE_GENERIC_1^#)
697+
// ARCHETYPE_GENERIC_1: Begin completions
698+
// ARCHETYPE_GENERIC_1: Decl[InstanceMethod]/CurrNominal: ['(']{#(fn): (Wrapped) -> _##(Wrapped) -> _#}[')'][#Wrap<_>#];
699+
}

0 commit comments

Comments
 (0)