Skip to content

[Sema] Enable substituting the base of a dependent member type with an opened archetype. #40958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3875,11 +3875,6 @@ static Type getMemberForBaseType(LookupConformanceFn lookupConformances,
if (auto *selfType = substBase->getAs<DynamicSelfType>())
substBase = selfType->getSelfType();

// Error recovery path.
// FIXME: Generalized existentials will look here.
if (substBase->isOpenedExistential())
return failed();

// If the parent is an archetype, extract the child archetype with the
// given name.
if (auto archetypeParent = substBase->getAs<ArchetypeType>()) {
Expand Down
15 changes: 15 additions & 0 deletions test/SILGen/dependent_member_lowering.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,18 @@ struct Bar<T>: P {
// 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>) -> ()
// 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>):
}

protocol P0 {
associatedtype Foo
func foo() -> Foo
}

protocol P1: P0 where Foo == String {
func foo() -> String
}

// CHECK-LABEL: sil hidden [ossa] @$s25dependent_member_lowering26existentialDependentMemberySSAA2P1_pF : $@convention(thin) (@in_guaranteed P1) -> @owned String
func existentialDependentMember(_ p1: P1) -> String {
// CHECK: $@convention(witness_method: P0) <τ_0_0 where τ_0_0 : P0> (@in_guaranteed τ_0_0) -> @out τ_0_0.Foo
return p1.foo()
}