Fixing issues in analysis around generics#1351
Merged
grantnelson-wf merged 1 commit intogopherjs:masterfrom Dec 9, 2024
Merged
Fixing issues in analysis around generics#1351grantnelson-wf merged 1 commit intogopherjs:masterfrom
grantnelson-wf merged 1 commit intogopherjs:masterfrom
Conversation
387abad to
6a3f862
Compare
6a3f862 to
010220a
Compare
grantnelson-wf
added a commit
to Workiva/gopherjs
that referenced
this pull request
Nov 21, 2024
flimzy
approved these changes
Nov 21, 2024
Member
flimzy
left a comment
There was a problem hiding this comment.
LGTM, but @nevkontakte may have additional comments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While I was doing other work I ran into a few issues and fixed them:
Unused Generic Functions: Unused generic functions and methods that perform calls were making requests with the type parameters, e.g.
func Foo[T any]() { Bar[T]() }will make a request for the function information forBar[T]withTbeing the type parameter. This was because if there were no instances, I assumed that meant that it was a non-generic function, but I totally missed the possibility that it is a generic function that just isn't used. I now check for instances and check if the function is generic and if it is unused and generic, skip over the function and don't bother making a FuncInfo for it. Since it is unused, it can't be needed by anything else other than other unused functions.Function Literal Instances: Function literals that are inside a generic function were not getting the instance information, e.g.
func Foo[T any]() { func() { Bar[T]() }() }will make a request for the function information forBar[T]withTbeing the type parameter. This was because when the function literal FuncInfo is created it wasn't getting the type arguments from the instance of the generic function that it is inside of. I changed the function literal to take on the instance it is inside of. To make this work I also made the function literal FuncInfo lookup require the type arguments of the specific instance of the function literal to lookup.Delay Remote Calls: I make the
IsBlockingmethod able to use theisImportedBlockingfunction if the instance of the function that is being looked up isn't from the currentInfo. With this change I could also delay the lookup of other remote calls and defers until the end of the analysis when function information is propagating. This change will help later for getting generic changes across package boundaries.These changes will help prepare for some of the changes needed to make function lookup in the ImportContext look for the correct instance of a generic function Decl. This is related to #1013 and #1270