@@ -46,6 +46,10 @@ struct G : P {
4646 static func static_member_fn()
4747}
4848
49+ struct GenFwdP<T : P> : P {
50+ static func static_member_fn()
51+ }
52+
4953sil private @A_static_member_fn : $@convention(witness_method: P) (@thick A.Type) -> () {
5054bb0(%0 : $@thick A.Type):
5155 %printGenericTypeAndWord = function_ref @printGenericTypeAndWord : $@convention(thin) <T> (@thick T.Type, Builtin.Word) -> ()
@@ -124,6 +128,21 @@ sil_witness_table G : P module main {
124128 method #P.static_member_fn: <Self where Self : P> (Self.Type) -> () -> () : @G_static_member_fn
125129}
126130
131+ sil private @GenFwdP_static_member_fn : $@convention(witness_method: P) <T : P> (@thick GenFwdP<T>.Type) -> () {
132+ bb0(%0 : $@thick GenFwdP<T>.Type):
133+ %printGenericType = function_ref @printGenericType : $@convention(thin) <T> (@thick T.Type) -> ()
134+ apply %printGenericType<GenFwdP<T>>(%0) : $@convention(thin) <T> (@thick T.Type) -> ()
135+ %forwardee = metatype $@thick T.Type
136+ %forwarded_static_member_fn = witness_method $T, #P.static_member_fn : <Self where Self : P> (Self.Type) -> () -> () : $@convention(witness_method: P) <T : P> (@thick T.Type) -> ()
137+ apply %forwarded_static_member_fn<T>(%forwardee) : $@convention(witness_method: P) <T : P> (@thick T.Type) -> ()
138+ %4 = tuple ()
139+ return %4 : $()
140+ }
141+
142+ sil_witness_table <T : P> GenFwdP<T>: P module main {
143+ method #P.static_member_fn: <Self where Self : P> (Self.Type) -> () -> () : @GenFwdP_static_member_fn
144+ }
145+
127146sil [ossa] @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
128147bb0(%argc : $Int32, %argv : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
129148 %0 = integer_literal $Builtin.Word, 0
@@ -315,6 +334,57 @@ bb0(%argc : $Int32, %argv : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<
315334 // CHECK: 5
316335 apply %direct_access_from_parameter_with_conformance<Pack{A, B, C, D, E, F}>(%5) : $@convention(thin) <T_1... : P> (Builtin.Word) -> ()
317336
337+
338+ /// Expect the following
339+ /// GenFwdP<INNER> // from direct_access_from_parameter_with_conformance's call to printGenericType
340+ /// GenFwdP<INNER> // from GenFwdP_static_member_fn's call to printGenericType
341+ /// INNER // from INNER::static_member_fn's call to printGenericTypeAndWord
342+ /// INNER.INDEX // from INNER::static_member_fn's call to printGenericTypeAndWord
343+ %wrap_in_GenFwdP = function_ref @wrap_in_GenFwdP : $@convention(thin) <T_1...: P> (Builtin.Word) -> ()
344+ // U_1 -> {A, B, C, D, E, F}
345+ // --0---> ^
346+ // CHECK: GenFwdP<A>
347+ // CHECK: GenFwdP<A>
348+ // CHECK: A
349+ // CHECK: 0
350+ apply %wrap_in_GenFwdP<Pack{A, B, C, D, E, F}>(%0) : $@convention(thin) <T_1... : P> (Builtin.Word) -> ()
351+ // U_1 -> {A, B, C, D, E, F}
352+ // ----1----> ^
353+ // CHECK: GenFwdP<B>
354+ // CHECK: GenFwdP<B>
355+ // CHECK: B
356+ // CHECK: 1
357+ apply %wrap_in_GenFwdP<Pack{A, B, C, D, E, F}>(%1) : $@convention(thin) <T_1... : P> (Builtin.Word) -> ()
358+ // U_1 -> {A, B, C, D, E, F}
359+ // -----2------> ^
360+ // CHECK: GenFwdP<C>
361+ // CHECK: GenFwdP<C>
362+ // CHECK: C
363+ // CHECK: 2
364+ apply %wrap_in_GenFwdP<Pack{A, B, C, D, E, F}>(%2) : $@convention(thin) <T_1... : P> (Builtin.Word) -> ()
365+ // U_1 -> {A, B, C, D, E, F}
366+ // -------3-------> ^
367+ // CHECK: GenFwdP<D>
368+ // CHECK: GenFwdP<D>
369+ // CHECK: D
370+ // CHECK: 3
371+ apply %wrap_in_GenFwdP<Pack{A, B, C, D, E, F}>(%3) : $@convention(thin) <T_1... : P> (Builtin.Word) -> ()
372+ // U_1 -> {A, B, C, D, E, F}
373+ // --------4---------> ^
374+ // CHECK: GenFwdP<E>
375+ // CHECK: GenFwdP<E>
376+ // CHECK: E
377+ // CHECK: 4
378+ apply %wrap_in_GenFwdP<Pack{A, B, C, D, E, F}>(%4) : $@convention(thin) <T_1... : P> (Builtin.Word) -> ()
379+ // U_1 -> {A, B, C, D, E, F}
380+ // ----------5----------> ^
381+ // CHECK: GenFwdP<F>
382+ // CHECK: GenFwdP<F>
383+ // CHECK: F
384+ // CHECK: 5
385+ apply %wrap_in_GenFwdP<Pack{A, B, C, D, E, F}>(%5) : $@convention(thin) <T_1... : P> (Builtin.Word) -> ()
386+
387+
318388 %outb = integer_literal $Builtin.Int32, 0
319389 %out = struct $Int32 (%outb : $Builtin.Int32)
320390 return %out : $Int32
@@ -393,3 +463,11 @@ entry(%intIndex : $Builtin.Word):
393463 %t = tuple ()
394464 return %t : $()
395465}
466+
467+ sil @wrap_in_GenFwdP : $<T_1... : P> (Builtin.Word) -> () {
468+ entry(%intIndex : $Builtin.Word):
469+ %direct_access_from_parameter_with_conformance = function_ref @direct_access_from_parameter_with_conformance : $@convention(thin) <T_1...: P> (Builtin.Word) -> ()
470+ apply %direct_access_from_parameter_with_conformance<Pack{repeat GenFwdP<each T_1>}>(%intIndex) : $@convention(thin) <T_1...: P> (Builtin.Word) -> ()
471+ %t = tuple ()
472+ return %t : $()
473+ }
0 commit comments