-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/stub: support for method generation with same name but differen…
…t receiver Fixes golang/go#64114 Change-Id: I5581bdbe1cbaa08e1e5589a304da5e637c6a5228 Reviewed-on: https://go-review.googlesource.com/c/tools/+/544915 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Suzy Mueller <[email protected]> Reviewed-by: Benny Siegert <[email protected]>
- Loading branch information
Showing
5 changed files
with
115 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2023 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package stubmethods_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"golang.org/x/tools/go/analysis/analysistest" | ||
"golang.org/x/tools/gopls/internal/analysis/stubmethods" | ||
) | ||
|
||
func Test(t *testing.T) { | ||
testdata := analysistest.TestData() | ||
analysistest.Run(t, testdata, stubmethods.Analyzer, "a") | ||
} |
15 changes: 15 additions & 0 deletions
15
gopls/internal/analysis/stubmethods/testdata/src/typeparams/implement.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2023 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package stubmethods | ||
|
||
var _ I = Y{} // want "Implement I" | ||
|
||
type I interface{ F() } | ||
|
||
type X struct{} | ||
|
||
func (X) F(string) {} | ||
|
||
type Y struct{ X } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
gopls/internal/test/marker/testdata/stubmethods/issue64114.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
This test verifies that the embedded field has a method with the same name. | ||
|
||
-- issue64114.go -- | ||
package stub | ||
|
||
// Regression test for issue #64114: code action "implement" is not listed. | ||
|
||
var _ WriteTest = (*WriteStruct)(nil) //@suggestedfix("(", re"does not implement", issue64114) | ||
|
||
type WriterTwoStruct struct{} | ||
|
||
// Write implements io.ReadWriter. | ||
func (t *WriterTwoStruct) RRRR(str string) error { | ||
panic("unimplemented") | ||
} | ||
|
||
type WriteTest interface { | ||
RRRR() | ||
WWWW() | ||
} | ||
|
||
type WriteStruct struct { | ||
WriterTwoStruct | ||
} | ||
-- @issue64114/issue64114.go -- | ||
@@ -22 +22,11 @@ | ||
+ | ||
+// RRRR implements WriteTest. | ||
+// Subtle: this method shadows the method (WriterTwoStruct).RRRR of WriteStruct.WriterTwoStruct. | ||
+func (*WriteStruct) RRRR() { | ||
+ panic("unimplemented") | ||
+} | ||
+ | ||
+// WWWW implements WriteTest. | ||
+func (*WriteStruct) WWWW() { | ||
+ panic("unimplemented") | ||
+} |