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

Fix generation failure when multiple type parameters are in the receiver #52

Merged
merged 1 commit into from Apr 24, 2024

Conversation

ArtAndreev
Copy link
Contributor

@ArtAndreev ArtAndreev commented Apr 23, 2024

Before generation failed when receiver had multiple type parameters. For example, impl 'n *Node[T, U]' fmt.Stringer produced an error invalid receiver: "n *Node[T, U]".

Copy link
Owner

@josharian josharian left a comment

Choose a reason for hiding this comment

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

Thanks! One small nit…

@@ -82,6 +82,12 @@ func getReceiverType(recv string) string {
// VSCode adds a trailing space to receiver (it runs impl like: impl 'r *Receiver ' io.Writer)
// so we have to remove spaces.
recv = strings.TrimSpace(recv)

// Remove type parameters. They can contain spaces too, for example 'r *Receiver[T, U]'.
Copy link
Owner

Choose a reason for hiding this comment

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

Use strings.Cut?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@ArtAndreev
Copy link
Contributor Author

Sorry, just found a bug, will fix and write a test

Also fixes duplicate method generation for already implemented methods
of structs with type parameters.
@ArtAndreev
Copy link
Contributor Author

Sorry, just found a bug, will fix and write a test

The bug duplicated method generation for already implemented methods of structs with type parameters.

@josharian josharian merged commit fe5f430 into josharian:main Apr 24, 2024
1 check passed
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.

None yet

2 participants