Skip to content

Commit faf5be8

Browse files
authored
Merge pull request #25912 from rintaro/5.1-ide-complettion-gettypeofmember-rdar52386176
[5.1][CodeCompletion] Fix a crash in callee analysis
2 parents dae59d3 + c3fa88a commit faf5be8

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
@@ -354,9 +354,10 @@ void collectPossibleCalleesByQualifiedLookup(
354354
}
355355
}
356356

357-
auto fnType = baseTy->getMetatypeInstanceType()->getTypeOfMember(
358-
DC.getParentModule(), VD, declaredMemberType);
359-
357+
auto subs = baseTy->getMetatypeInstanceType()->getMemberSubstitutionMap(
358+
DC.getParentModule(), VD,
359+
VD->getInnermostDeclContext()->getGenericEnvironmentOfContext());
360+
auto fnType = declaredMemberType.subst(subs, SubstFlags::UseErrorType);
360361
if (!fnType)
361362
continue;
362363

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)