| 1 |
// Copyright 2015 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package main |
| 6 |
|
| 7 |
import ( |
| 8 |
"bytes" |
| 9 |
|
| 10 |
"./a" |
| 11 |
) |
| 12 |
|
| 13 |
type X struct { |
| 14 |
*a.X |
| 15 |
} |
| 16 |
|
| 17 |
type Intf interface { |
| 18 |
Get() []byte |
| 19 |
RetPtr(int) *int |
| 20 |
RetRPtr(int) (int, *int) |
| 21 |
} |
| 22 |
|
| 23 |
func main() { |
| 24 |
x := &a.X{T: [32]byte{1, 2, 3, 4}} |
| 25 |
var ix Intf = X{x} |
| 26 |
t1 := ix.Get() |
| 27 |
t2 := x.Get() |
| 28 |
if !bytes.Equal(t1, t2) { |
| 29 |
panic(t1) |
| 30 |
} |
| 31 |
|
| 32 |
p1 := ix.RetPtr(5) |
| 33 |
p2 := x.RetPtr(7) |
| 34 |
if *p1 != 6 || *p2 != 8 { |
| 35 |
panic(*p1) |
| 36 |
} |
| 37 |
|
| 38 |
r1, r2 := ix.RetRPtr(10) |
| 39 |
r3, r4 := x.RetRPtr(13) |
| 40 |
if r1 != 11 || *r2 != 11 || r3 != 14 || *r4 != 14 { |
| 41 |
panic("bad RetRPtr") |
| 42 |
} |
| 43 |
} |