Skip to content

Commit 6941886

Browse files
committed
[AST] Use LookUpConformanceInModule to check if extension applied
rdar://problem/53401609 (cherry picked from commit 32854b3)
1 parent 3baa54f commit 6941886

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

lib/Sema/CSGen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3643,7 +3643,9 @@ static bool areGenericRequirementsSatisfied(
36433643

36443644
// For every requirement, add a constraint.
36453645
for (auto Req : sig->getRequirements()) {
3646-
if (auto resolved = Req.subst(Substitutions)) {
3646+
if (auto resolved = Req.subst(
3647+
QuerySubstitutionMap{Substitutions},
3648+
LookUpConformanceInModule(DC->getParentModule()))) {
36473649
CS.addConstraint(*resolved, Loc);
36483650
} else if (isExtension) {
36493651
return false;

test/IDE/complete_constrained.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONDITIONAL_OVERLOAD_ARG | %FileCheck %s -check-prefix=CONDITIONAL_OVERLOAD_ARG
44
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONDITIONAL_OVERLOAD_INIT_ARG | %FileCheck %s -check-prefix=CONDITIONAL_OVERLOAD_ARG
55
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONDITIONAL_INAPPLICABLE_ARG | %FileCheck %s -check-prefix=CONDITIONAL_INAPPLICABLE_ARG
6+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CONDITIONAL_DEPENDENT_TYPEALIAS | %FileCheck %s -check-prefix=CONDITIONAL_DEPENDENT_TYPEALIAS
67

78
protocol SomeProto {
89
associatedtype Assoc
@@ -127,3 +128,22 @@ func testVegetarian(chef: Chef<Vegetarian>) {
127128
chef.eat(.#^CONDITIONAL_INAPPLICABLE_ARG^#)
128129
// CONDITIONAL_INAPPLICABLE_ARG-NOT: Begin completion
129130
}
131+
132+
// rdar://problem/53401609
133+
protocol MyProto {
134+
associatedtype Index
135+
}
136+
extension MyProto where Index: Strideable, Index.Stride == Int {
137+
func indices() {}
138+
}
139+
struct MyConcrete {}
140+
extension MyConcrete: MyProto {
141+
typealias Index = Int
142+
}
143+
func testHasIndex(value: MyConcrete) {
144+
value.#^CONDITIONAL_DEPENDENT_TYPEALIAS^#
145+
// CONDITIONAL_DEPENDENT_TYPEALIAS: Begin completions, 2 items
146+
// CONDITIONAL_DEPENDENT_TYPEALIAS-DAG: Keyword[self]/CurrNominal: self[#MyConcrete#];
147+
// CONDITIONAL_DEPENDENT_TYPEALIAS-DAG: Decl[InstanceMethod]/Super: indices()[#Void#];
148+
// CONDITIONAL_DEPENDENT_TYPEALIAS: End completions
149+
}

0 commit comments

Comments
 (0)