func TestPointerReceiver(t *testing.T) {
files := map[string]string{
package foo
type T int
func (*T) F() {}
//inlineme
func (t *T) G() { t.F() }
func main() {
var t T
t.G() // want "inline call of (*fooT).G"
}
`,
"foo/foo.go.golden": `
package foo
type T int
func (*T) F() {}
//inlineme
func (t *T) G() { t.F() }
func main() {
var t T
t.F() // want "inline call of (*fooT).G"
}
`,
}
dir, cleanup, err := analysistest.WriteFiles(files)
if err != nil {
t.Fatal(err)
}
analysistest.RunWithSuggestedFixes(t, dir, analyzer.Analyzer, "foo")
cleanup()
}
The test fails with:
--- .../foo/foo.go.golden
+++ actual
@@ -9,5 +9,5 @@
func main() {
var t T
- t.F() // want `inline call of \(\*foo.T\).G`
+ (&t).F() // want `inline call of \(\*foo.T\).G`
}
I would be great if the inliner could just not add the unnecessary syntax although it is possible that I'm missing and edge case and this is actually needed.
The test fails with:
I would be great if the inliner could just not add the unnecessary syntax although it is possible that I'm missing and edge case and this is actually needed.