Skip to content

Go: Update to 1.27#22042

Draft
jketema wants to merge 8 commits into
mainfrom
jketema/go-1.27
Draft

Go: Update to 1.27#22042
jketema wants to merge 8 commits into
mainfrom
jketema/go-1.27

Conversation

@jketema

@jketema jketema commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot added the Go label Jun 24, 2026
@jketema jketema added the depends on internal PR This PR should only be merged in sync with an internal Semmle PR label Jun 24, 2026
@jketema jketema force-pushed the jketema/go-1.27 branch 3 times, most recently from f0842b5 to 91e1d28 Compare June 30, 2026 15:20

@owen-mc owen-mc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass review.

Comment thread go/extractor/extractor.go Outdated
Comment thread go/extractor/extractor.go Outdated
for i := 0; i < origintp.NumMethods(); i++ {
meth := origintp.Method(i).Origin()

typeParams := tp.Method(i).Type().(*types.Signature).TypeParams()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Extract s2.GenericMethod2, which doesn't seem to be consistent with how the rest of the extractor handles generics.
  2. Map the type parameters from the type of s2.GenericMethod2 to 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ☝️ make sense?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment to that effect.

Comment thread go/extractor/extractor.go Outdated
Comment thread go/extractor/extractor.go Outdated
Comment thread go/ql/test/library-tests/semmle/go/Function/genericMethods.go Outdated
@jketema jketema force-pushed the jketema/go-1.27 branch 3 times, most recently from 83870c8 to 7213ee7 Compare July 10, 2026 15:37
@jketema jketema force-pushed the jketema/go-1.27 branch 2 times, most recently from ce9e7c8 to 15907ce Compare July 14, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

depends on internal PR This PR should only be merged in sync with an internal Semmle PR documentation Go

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants