-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethods.go
52 lines (41 loc) · 1.03 KB
/
methods.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// run
//go:build !wasm
// +build !wasm
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
)
type toobig struct {
a, b, c string
}
//go:registerparams
//go:noinline
func (x *toobig) MagicMethodNameForTestingRegisterABI(y toobig, z toobig) toobig {
return toobig{x.a, y.b, z.c}
}
type AnInterface interface {
MagicMethodNameForTestingRegisterABI(y toobig, z toobig) toobig
}
//go:registerparams
//go:noinline
func I(a, b, c string) toobig {
return toobig{a, b, c}
}
// AnIid prevents the compiler from figuring out what the interface really is.
//go:noinline
func AnIid(x AnInterface) AnInterface {
return x
}
var tmp toobig
func main() {
x := I("Ahoy", "1,", "2")
y := I("3", "there,", "4")
z := I("5", "6,", "Matey")
tmp = x.MagicMethodNameForTestingRegisterABI(y, z)
fmt.Println(tmp.a, tmp.b, tmp.c)
tmp = AnIid(&x).MagicMethodNameForTestingRegisterABI(y, z)
fmt.Println(tmp.a, tmp.b, tmp.c)
}