@@ -30,6 +30,21 @@ enum E: String {
3030 case a, b, c, d, e
3131}
3232
33+ protocol P2 {
34+ associatedtype A: Q
35+ }
36+
37+ protocol Q {
38+ }
39+
40+ public struct S2: P2 {
41+ var x: String
42+ struct A: Q {
43+ var y: String
44+ }
45+ }
46+
47+
3348sil @cl : $@convention(thin) () -> Int
3449
3550// CHECK-LABEL: sil [ossa] @thick_to_thin :
@@ -64,6 +79,7 @@ sil_vtable Bar {
6479}
6580
6681sil @createit : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@thick τ_0_0.Type, Int) -> @out τ_0_0
82+ sil @create2 : $@convention(thin) <τ_0_0 where τ_0_0 : Q> (Int) -> @out τ_0_0
6783sil @useGenS : $@convention(thin) <τ_0_0 where τ_0_0 : P> (GenS<τ_0_0>) -> ()
6884sil @returnGenS : $@convention(thin) <τ_0_0 where τ_0_0 : P> (@thick τ_0_0.Type) -> GenS<τ_0_0>
6985
@@ -128,6 +144,22 @@ bb0(%0 : $Int):
128144 return %11
129145}
130146
147+ // TODO: we don't support dependent existential archetypes, yet. Once we do, change this test case.
148+ // CHECK-LABEL: sil [ossa] @dont_replace_dependent_archetype :
149+ // CHECK: apply %{{[0-9]+}}<(@opened
150+ // CHECK: } // end sil function 'dont_replace_dependent_archetype'
151+ sil [ossa] @dont_replace_dependent_archetype : $@convention(thin) (Int) -> @out any Q {
152+ bb0(%0 : $*any Q, %1 : $Int):
153+ %2 = metatype $@thick S2.Type
154+ %3 = init_existential_metatype %2, $@thick any P2.Type
155+ %4 = open_existential_metatype %3 to $@thick (@opened("0FC03D78-E9DB-11EF-B47C-0EA13E3AABB4", any P2) Self).Type
156+ %6 = function_ref @create2 : $@convention(thin) <τ_0_0 where τ_0_0 : Q> (Int) -> @out τ_0_0
157+ %7 = init_existential_addr %0, $(@opened("0FC03D78-E9DB-11EF-B47C-0EA13E3AABB4", any P2) Self).A
158+ %8 = apply %6<(@opened("0FC03D78-E9DB-11EF-B47C-0EA13E3AABB4", any P2) Self).A>(%7, %1) : $@convention(thin) <τ_0_0 where τ_0_0 : Q> (Int) -> @out τ_0_0
159+ %11 = tuple ()
160+ return %11
161+ }
162+
131163// CHECK-LABEL: sil [ossa] @dont_replace_returned_embedded_archetype :
132164// CHECK: apply %{{[0-9]+}}<@opened
133165// CHECK: } // end sil function 'dont_replace_returned_embedded_archetype'
0 commit comments