summaryrefslogtreecommitdiffstats
path: root/llgo/test/execution/structs/embed.go
blob: d5197945eefcd2d9d968efb3e11d6d1f005d8953 (plain)
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
53
54
55
56
57
58
// RUN: llgo -o %t %s
// RUN: %t 2>&1 | FileCheck %s

// CHECK: A.test 1
// CHECK-NEXT: A.testA
// CHECK-NEXT: A.testA2
// CHECK-NEXT: B.test 2
// CHECK-NEXT: A.testA
// CHECK-NEXT: A.testA2
// CHECK-NEXT: A.testA

package main

type A struct{ aval int }

func (a *A) test() {
	println("A.test", a.aval)
}

func (a *A) testA() {
	println("A.testA")
}

func (a A) testA2() {
	println("A.testA2")
}

type B struct {
	A
	bval int
}

func (b B) test() {
	println("B.test", b.bval)
}

type C struct {
	*B
	cval int
}

func main() {
	var b B
	b.aval = 1
	b.bval = 2
	b.A.test()
	b.A.testA()
	b.A.testA2()
	b.test()
	b.testA()
	b.testA2()

	var c C
	c.B = &b
	c.cval = 3
	c.testA()
	//c.testA2()
}
OpenPOWER on IntegriCloud