-
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.
internal/refactor/inline: fix condition for splice assignment strategy
In the assign statements strategy, if there are no nontrivial result conversions, we can replace a call with its result expression regardless of the AssignStmt.Tok. For golang/go#70599 Change-Id: Ifa2b615c17d58e3bbc708b9ecf98530858915564 Reviewed-on: https://go-review.googlesource.com/c/tools/+/632937 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
- Loading branch information
Showing
4 changed files
with
70 additions
and
13 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
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,62 @@ | ||
This test checks the splice assignment substrategy. | ||
|
||
-- go.mod -- | ||
module testdata | ||
|
||
go 1.20 | ||
|
||
-- a.go -- | ||
package a | ||
|
||
func a() (int32, string) { | ||
return b() | ||
} | ||
|
||
func b() (int32, string) { | ||
return 0, "a" | ||
} | ||
|
||
func c() (int, chan<- int) { | ||
return 0, make(chan int) // nontrivial conversion | ||
} | ||
|
||
-- a1.go -- | ||
package a | ||
|
||
func _() { | ||
x, y := a() //@ inline(re"a", a1) | ||
} | ||
-- a1 -- | ||
package a | ||
|
||
func _() { | ||
x, y := b() //@ inline(re"a", a1) | ||
} | ||
-- a2.go -- | ||
package a | ||
|
||
func _() { | ||
var x, y any | ||
x, y = a() //@ inline(re"a", a2) | ||
} | ||
-- a2 -- | ||
package a | ||
|
||
func _() { | ||
var x, y any | ||
x, y = b() //@ inline(re"a", a2) | ||
} | ||
-- a3.go -- | ||
package a | ||
|
||
func _() { | ||
var y chan<- int | ||
x, y := c() //@ inline(re"c", a3) | ||
} | ||
-- a3 -- | ||
package a | ||
|
||
func _() { | ||
var y chan<- int | ||
x, y := 0, make(chan int) //@ inline(re"c", a3) | ||
} |
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