github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/test/execution/methods/selectors.go (about) 1 // 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 9 package main 10 11 type S1 struct{} 12 type S2 struct { 13 S1 14 } 15 16 func (s S1) F1() { 17 println("F1") 18 } 19 20 func (s *S2) F2() { 21 println("F2") 22 } 23 24 func 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 34 func 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 }