Go: Update to 1.27#22042
Conversation
f0842b5 to
91e1d28
Compare
| for i := 0; i < origintp.NumMethods(); i++ { | ||
| meth := origintp.Method(i).Origin() | ||
|
|
||
| typeParams := tp.Method(i).Type().(*types.Signature).TypeParams() |
There was a problem hiding this comment.
Are you sure that this line wants to use the instantiated receiver type (tp instead of origintp), and the instantiated method type (tp.Method(i).Type() rather than tp.Method(i).Type().Origin())? It seems odd to assign meth as the parent in the line below when meth is different from tp.Method(i). Do we even need to populate type param parents here, as we will do something very similar in extractMethods.
Perhaps we should put a short comment here, as it will no doubt be confusing to future readers as well.
There was a problem hiding this comment.
As far as I can tell, it needs to be tp, or at least that solves the Parent of type parameter does not exist: Q any error I was seeing. I'm absolutely not sure if meth is correct here. I think I need to better understand what relations are affected by populateTypeParamParents.
There was a problem hiding this comment.
Just to provide some context first. The problem is coming from the select expression in
s2.GenericMethod2[string]("hello")That is s2.GenericMethod2. Without the index ([string]) this still has a generic type func[P4 any](x P4). This type is separate from the generic type the declaration of GenericMethod2 has. We do not extract s2.GenericMethod2, but only its Origin. We, however, need the type parameters of the type of s2.GenericMethod2, when we assign a type to that expression.
I think this means there are two solutions here:
- Extract
s2.GenericMethod2, which doesn't seem to be consistent with how the rest of the extractor handles generics. - Map the type parameters from the type of
s2.GenericMethod2to the type parameters from declaration that occurs in the source code.
(2) we can do by constructing a separate map from type parameters to type parameters near the call sides of getTypeParamParentLabel. However, given what ends up in the database w.r.t. type parameters, this is effectively the same as what I do here by using meth in combination with the type parameters from the instantiated type.
There was a problem hiding this comment.
Does ☝️ make sense?
There was a problem hiding this comment.
Added a comment to that effect.
83870c8 to
7213ee7
Compare
ce9e7c8 to
15907ce
Compare
No description provided.