golang.org/x/tools@v0.21.0/internal/refactor/inline/testdata/basic-literal.txtar (about)

     1  Basic tests of inlining by literalization.
     2  
     3  The use of defer forces literalization.
     4  
     5  recover() is an example of a function with effects,
     6  defeating elimination of parameter x; but parameter
     7  y is eliminated by substitution.
     8  
     9  -- go.mod --
    10  module testdata
    11  go 1.12
    12  
    13  -- a/a1.go --
    14  package a
    15  
    16  func _() {
    17  	add(recover().(int), 2) //@ inline(re"add", add1)
    18  }
    19  
    20  func add(x, y int) int { defer print(); return x + y }
    21  
    22  -- add1 --
    23  package a
    24  
    25  func _() {
    26  	func() int { var x int = recover().(int); defer print(); return x + 2 }() //@ inline(re"add", add1)
    27  }
    28  
    29  func add(x, y int) int { defer print(); return x + y }