Skip to content

rf: implement mv func -> method#50

Merged
rsc merged 1 commit intorsc:mainfrom
jitsu-net:implement-mv-func-method
Oct 29, 2025
Merged

rf: implement mv func -> method#50
rsc merged 1 commit intorsc:mainfrom
jitsu-net:implement-mv-func-method

Conversation

@jitsu-net
Copy link
Copy Markdown
Collaborator

This change implements the 'mv TFunction T.Method' command.

@jitsu-net jitsu-net force-pushed the implement-mv-func-method branch from 8be7a9f to b64a88c Compare October 13, 2025 17:37
Comment thread mv.go

snap.ForEachFile(func(pkg *refactor.Package, file *ast.File) {
refactor.Walk(file, func(stack []ast.Node) {
id, ok := stack[0].(*ast.Ident)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should this code be watching for
funcVar := f
?
(where f is the global function that is being converted to a method)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

or, also, someOtherfunc(f)
or any other use of a function that is not a call?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good point; I will add support for those cases.

Copy link
Copy Markdown

@dr2chase dr2chase left a comment

Choose a reason for hiding this comment

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

I am finishing my review.

Comment thread mv.go

snap.ForEachFile(func(pkg *refactor.Package, file *ast.File) {
refactor.Walk(file, func(stack []ast.Node) {
id, ok := stack[0].(*ast.Ident)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

or, also, someOtherfunc(f)
or any other use of a function that is not a call?

@jitsu-net jitsu-net force-pushed the implement-mv-func-method branch from b64a88c to 2ec3cfb Compare October 15, 2025 21:59
This change implements the moving of a function to a method.  The
receiver of the method must match the first parameter to the funciton.
@jitsu-net jitsu-net force-pushed the implement-mv-func-method branch from 2ec3cfb to dcd4416 Compare October 16, 2025 02:53
@jitsu-net
Copy link
Copy Markdown
Collaborator Author

Updated; please let me know if I missed any edge cases.

@rsc rsc merged commit cc8efa1 into rsc:main Oct 29, 2025
1 check passed
@jitsu-net jitsu-net deleted the implement-mv-func-method branch October 29, 2025 17:12
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.

3 participants