blob: 92343edd840e10fc751de72baefefcf6816f5048 [file] [log] [blame]
Test of inlining a method call.
The call to (*T).g0 implicitly takes the address &x, and
the call to T.h implictly dereferences the argument *ptr.
The f1/g1 methods have parameters, exercising the
splicing of the receiver into the parameter list.
Notice that the unnamed parameters become named.
-- go.mod --
module testdata
go 1.12
-- a/f0.go --
package a
type T int
func (recv T) f0() { println(recv) }
func _(x T) {
x.f0() //@ inline(re"f0", f0)
}
-- f0 --
package a
type T int
func (recv T) f0() { println(recv) }
func _(x T) {
println(x) //@ inline(re"f0", f0)
}
-- a/g0.go --
package a
func (recv *T) g0() { println(recv) }
func _(x T) {
x.g0() //@ inline(re"g0", g0)
}
-- g0 --
package a
func (recv *T) g0() { println(recv) }
func _(x T) {
println(&x) //@ inline(re"g0", g0)
}
-- a/f1.go --
package a
func (recv T) f1(int, int) { println(recv) }
func _(x T) {
x.f1(1, 2) //@ inline(re"f1", f1)
}
-- f1 --
package a
func (recv T) f1(int, int) { println(recv) }
func _(x T) {
println(x) //@ inline(re"f1", f1)
}
-- a/g1.go --
package a
func (recv *T) g1(int, int) { println(recv) }
func _(x T) {
x.g1(1, 2) //@ inline(re"g1", g1)
}
-- g1 --
package a
func (recv *T) g1(int, int) { println(recv) }
func _(x T) {
println(&x) //@ inline(re"g1", g1)
}
-- a/h.go --
package a
func (T) h() int { return 1 }
func _() {
var ptr *T
ptr.h() //@ inline(re"h", h)
}
-- h --
package a
func (T) h() int { return 1 }
func _() {
var ptr *T
var _ T = *ptr
_ = 1 //@ inline(re"h", h)
}
-- a/i.go --
package a
func (T) i() int { return 1 }
func _() {
(*T).i(nil) //@ inline(re"i", i)
}
-- i --
package a
func (T) i() int { return 1 }
func _() {
_ = 1 //@ inline(re"i", i)
}