[tools] gopls/internal/golang/stubmethods: support generic interfaces

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
5:41 PM (2 hours ago) 5:41 PM
to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Hongxiang Jiang, golang...@luci-project-accounts.iam.gserviceaccount.com, golang-co...@googlegroups.com

Alan Donovan submitted the change

Change information

Commit message:
gopls/internal/golang/stubmethods: support generic interfaces

This CL fixes a bug in the "implement missing method" code action
when the interface is generic: previously, it would insert free
type parameters into the concrete method declarations, instead
of using their instantiations from the LHS of the failing
var I = C(...) assignment.

Also, reject attemps to implement interface types that have free
type parameters, either because they are generic, or because
they are local to a generic function and reference its type
parameters.

+ test

How should the interactive "implement interface" refactoring
work when the interface is generic? Should it prompt for a
type for each type argument? Currently it will reject it.

Also, flip incorrect got/want in marker test error message.

Fixes golang/go#79845
Change-Id: I9164c0fbb2a9255cf7068fcb221d4919d0a527d9
Reviewed-by: Hongxiang Jiang <hxj...@golang.org>
Files:
  • M gopls/internal/golang/codeaction.go
  • M gopls/internal/golang/implement_interface.go
  • M gopls/internal/golang/stubmethods/stubmethods.go
  • M gopls/internal/test/marker/marker_test.go
  • A gopls/internal/test/marker/testdata/quickfix/stubmethods/anoniface.txt
  • A gopls/internal/test/marker/testdata/quickfix/stubmethods/issue79845.txt
  • A gopls/internal/test/marker/testdata/quickfix/stubmethods/localiface.txt
Change size: M
Delta: 7 files changed, 137 insertions(+), 83 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I9164c0fbb2a9255cf7068fcb221d4919d0a527d9
Gerrit-Change-Number: 787541
Gerrit-PatchSet: 5
Gerrit-Owner: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Hongxiang Jiang <hxj...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages