wordsize.go
758 Bytes
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
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s
// CHECK: StringStringer(abc)
// CHECK-NEXT: abc 1 2 3
package main
type Stringer interface {
String() string
}
type StringStringer string
func (s StringStringer) String() string {
return "StringStringer(" + string(s) + ")"
}
func (s StringStringer) MethodWithArgs(a, b, c int) {
println(s, a, b, c)
}
type I interface {
MethodWithArgs(a, b, c int)
}
func testLargerThanWord() {
// string is larger than a word. Make sure it works
// well as a method receiver when using interfaces.
var s Stringer = StringStringer("abc")
println(s.String())
// Test calling a method which takes parameters
// beyond the receiver.
s.(I).MethodWithArgs(1, 2, 3)
}
func main() {
testLargerThanWord()
}