Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new directives to prune generics #1254

Closed
wants to merge 12 commits into from

Conversation

grantnelson-wf
Copy link
Collaborator

@grantnelson-wf grantnelson-wf commented Dec 6, 2023

WIP

Summary

After a conversation with Nevkontakte (here), the current goal is to make go1.19 support without generics possible by dropping generic code. To accomplish this, I'm adding a new directive, gopherjs:purge, which will remove parts of the original code without replacing them with something in the overlay/override code. The native code will have the directive for some declaration or specification identifier and both the overlay and original will have that decl/spec removed from it.

This will allow us, in a follow up ticket, to add things into the natives that we want to remove, e.g. type Pointer[T any] struct {} in atomic.

Changes:

  • Added hasDirective to astutil.go which will check comments on anything in the AST which can hold a comment for a given directive. This will work for existing directives and the new one.
  • Added unit-tests for the new astutil directive methods
  • Broke out some of the code from parseAndAugment into their own methods to keep parseAndAugment from getting to long and hard to read. The new methods are augmentOverlayFile, augmentOriginalImports, and augmentOriginalFile.
  • Updated augmentOverlayFile and augmentOriginalFile to check for the gopherjs:purge directive and remove from both the overlay and original files anything that was purged.
  • Added a method, pruneImports, to remove unused imports from the overlay and original code after decl/spec have been purged from them.
  • Added unit-tests for the new parseAndAugment changes.
  • Fixed the imports in the native overlay net/http to not use io/ioutil since in go1.19 the original no longer uses io/ioutil and we were failing a test for extra imports.

@grantnelson-wf
Copy link
Collaborator Author

grantnelson-wf commented Dec 18, 2023

@grantnelson-wf
Copy link
Collaborator Author

See above comment. This work has been added to four other PRs

@grantnelson-wf grantnelson-wf deleted the pruneBoth branch December 18, 2023 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant