| 1 |
This test reproduces condition of golang/go#65217, where the inliner created an |
| 2 |
unnecessary eta abstraction. |
| 3 |
|
| 4 |
-- go.mod -- |
| 5 |
module unused.mod |
| 6 |
|
| 7 |
go 1.18 |
| 8 |
|
| 9 |
-- a/a.go -- |
| 10 |
package a |
| 11 |
|
| 12 |
type S struct{} |
| 13 |
|
| 14 |
func (S) Int() int { return 0 } |
| 15 |
|
| 16 |
func _() { |
| 17 |
var s S |
| 18 |
_ = f(s, s.Int()) |
| 19 |
var j int |
| 20 |
j = f(s, s.Int()) |
| 21 |
_ = j |
| 22 |
} |
| 23 |
|
| 24 |
func _() { |
| 25 |
var s S |
| 26 |
i := f(s, s.Int()) |
| 27 |
_ = i |
| 28 |
} |
| 29 |
|
| 30 |
func f(unused S, i int) int { //@codeaction("unused", "refactor.rewrite.removeUnusedParam", result=rewrite), diag("unused", re`unused`) |
| 31 |
return i |
| 32 |
} |
| 33 |
|
| 34 |
-- @rewrite/a/a.go -- |
| 35 |
package a |
| 36 |
|
| 37 |
type S struct{} |
| 38 |
|
| 39 |
func (S) Int() int { return 0 } |
| 40 |
|
| 41 |
func _() { |
| 42 |
var s S |
| 43 |
_ = f(s.Int()) |
| 44 |
var j int |
| 45 |
j = f(s.Int()) |
| 46 |
_ = j |
| 47 |
} |
| 48 |
|
| 49 |
func _() { |
| 50 |
var s S |
| 51 |
i := f(s.Int()) |
| 52 |
_ = i |
| 53 |
} |
| 54 |
|
| 55 |
func f(i int) int { //@codeaction("unused", "refactor.rewrite.removeUnusedParam", result=rewrite), diag("unused", re`unused`) |
| 56 |
return i |
| 57 |
} |