Adding new directives to prune generics #1254
Closed
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.
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:
hasDirective
toastutil.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.astutil
directive methodsparseAndAugment
into their own methods to keepparseAndAugment
from getting to long and hard to read. The new methods areaugmentOverlayFile
,augmentOriginalImports
, andaugmentOriginalFile
.augmentOverlayFile
andaugmentOriginalFile
to check for thegopherjs:purge
directive and remove from both the overlay and original files anything that was purged.pruneImports
, to remove unused imports from the overlay and original code after decl/spec have been purged from them.parseAndAugment
changes.net/http
to not useio/ioutil
since in go1.19 the original no longer usesio/ioutil
and we were failing a test for extra imports.