Skip to content

Commit 17fdc6f

Browse files
authored
Merge pull request #40958 from hborla/opened-archetype-dependent-member
[Sema] Enable substituting the base of a dependent member type with an opened archetype.
2 parents 45f65b9 + 8991415 commit 17fdc6f

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

lib/AST/Type.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3875,11 +3875,6 @@ static Type getMemberForBaseType(LookupConformanceFn lookupConformances,
38753875
if (auto *selfType = substBase->getAs<DynamicSelfType>())
38763876
substBase = selfType->getSelfType();
38773877

3878-
// Error recovery path.
3879-
// FIXME: Generalized existentials will look here.
3880-
if (substBase->isOpenedExistential())
3881-
return failed();
3882-
38833878
// If the parent is an archetype, extract the child archetype with the
38843879
// given name.
38853880
if (auto archetypeParent = substBase->getAs<ArchetypeType>()) {

test/SILGen/dependent_member_lowering.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,18 @@ struct Bar<T>: P {
2020
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s25dependent_member_lowering3BarVyxGAA1PA2aEP1fyy1AQzFTW : $@convention(witness_method: P) <τ_0_0> (@in_guaranteed @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> @out τ_0_1 for <Int, τ_0_0>, @in_guaranteed Bar<τ_0_0>) -> ()
2121
// CHECK: bb0(%0 : $*@callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> @out τ_0_1 for <Int, τ_0_0>, %1 : $*Bar<τ_0_0>):
2222
}
23+
24+
protocol P0 {
25+
associatedtype Foo
26+
func foo() -> Foo
27+
}
28+
29+
protocol P1: P0 where Foo == String {
30+
func foo() -> String
31+
}
32+
33+
// CHECK-LABEL: sil hidden [ossa] @$s25dependent_member_lowering26existentialDependentMemberySSAA2P1_pF : $@convention(thin) (@in_guaranteed P1) -> @owned String
34+
func existentialDependentMember(_ p1: P1) -> String {
35+
// CHECK: $@convention(witness_method: P0) <τ_0_0 where τ_0_0 : P0> (@in_guaranteed τ_0_0) -> @out τ_0_0.Foo
36+
return p1.foo()
37+
}

0 commit comments

Comments
 (0)