by cherryteastain · 2y ago · 0 comments
func foo[V any, X Yer[V]](x X) V
can be called with only one type (X) and therefore manages to emit the same code in main_main_pc0. It all falls apart when you add a second struct which satisfies Yer [1], which leads the compiler to emit a virtual function table instead. You can see it in the following instructions in the code with a second implementation for Yer added: LEAQ main..dict.foo[int,*main.X](SB), DX
LEAQ main.(*X).Y(SB), CX
CALL CX
[1] https://godbolt.org/z/zTco4ardxThe intent was for you to try it in other implementations to see how they optimize the code.