@@ -1657,8 +1657,30 @@ func extractType(tw *trap.Writer, tp types.Type) trap.Label {
16571657 // parent scope, so they are not dealt with by `extractScopes`
16581658 for i := 0 ; i < origintp .NumMethods (); i ++ {
16591659 meth := origintp .Method (i ).Origin ()
1660-
16611660 extractMethod (tw , meth )
1661+
1662+ // Consider a generic struct and a generic method:
1663+ //
1664+ // type S[P any] struct{}
1665+ // func (*S[P]) m[Q any](x Q) {}
1666+ //
1667+ // If we have a variable 's' of type 'S[int]' and the expression
1668+ // 's.m[string]("")', then the type of the selector expression 's.m'
1669+ // is ' func(Q)'. The method 'm' here is an instantiation of the
1670+ // declaration, which has its own type with type parameter 'Q'.
1671+ // As we do not extract method instantiations, 'populateTypeParamParents'
1672+ // does not automatically get called for the type parameter 'Q'
1673+ // from the instantiation of 'm'. To compensate, we add the type
1674+ // parameters here.
1675+ //
1676+ // As a parent we use the origin method. This suffices, as the name
1677+ // and index of the type parameter in the instantiation will be
1678+ // identical to those of the uninstantiated method, and as only
1679+ // these two properties will be extracted for a type parameter.
1680+ if tp .Method (i ) != meth {
1681+ signature := tp .Method (i ).Type ().(* types.Signature )
1682+ populateTypeParamParents (signature .TypeParams (), meth , false )
1683+ }
16621684 }
16631685
16641686 underlyingInterface , underlyingIsInterface := underlying .(* types.Interface )
0 commit comments