blob: bcd417366fbfc87b47bee90dd5b767c0078d5675 [file] [log] [blame]
Peter Collingbournead9841e2014-11-27 00:06:42 +00001// RUN: llgo -o %t %s
2// RUN: %t 2>&1 | FileCheck %s
3
4// CHECK: F1
5// CHECK-NEXT: F2
6// CHECK-NEXT: F1
7// CHECK-NEXT: F2
8
9package main
10
11type S1 struct{}
12type S2 struct {
13 S1
14}
15
16func (s S1) F1() {
17 println("F1")
18}
19
20func (s *S2) F2() {
21 println("F2")
22}
23
24func testUnnamedStructMethods() {
25 // Test method lookup on an unnamed struct type.
26 var x struct {
27 S1
28 S2
29 }
30 x.F1()
31 x.F2()
32}
33
34func main() {
35 var s S2
36
37 // Derive pointer-receiver function.
38 f1 := (*S2).F1
39 f1(&s)
40
41 f2 := (*S2).F2
42 f2(&s)
43
44 testUnnamedStructMethods()
45}