compiler: properly inline methods, use receiver
Notice that this doesn't differentiate between (*T) and (T) receivers always treating them as is. But we have the same problem with arguments now and the number of inlined calls is limited, usually we want this behavior.
This commit is contained in:
parent
6014dd720f
commit
b57dd2cad6
3 changed files with 38 additions and 0 deletions
|
@ -336,3 +336,22 @@ func TestPackageVarsInInlinedCalls(t *testing.T) {
|
|||
}`
|
||||
eval(t, src, big.NewInt(13))
|
||||
}
|
||||
|
||||
func TestInlinedMethod(t *testing.T) {
|
||||
src := `package foo
|
||||
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/inline"
|
||||
func Main() int {
|
||||
// It's important for this variable to not be named 't'.
|
||||
var z inline.T
|
||||
i := z.Inc(42)
|
||||
if i != 0 || z.N != 42 {
|
||||
return 0
|
||||
}
|
||||
i = z.Inc(100500)
|
||||
if i != 42 {
|
||||
return 0
|
||||
}
|
||||
return z.N
|
||||
}`
|
||||
eval(t, src, big.NewInt(100542))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue