| 1 |
// run |
| 2 |
|
| 3 |
// Copyright 2018 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
// When computing method sets with shadowed methods, make sure we |
| 8 |
// compute whether a method promotion involved a pointer traversal |
| 9 |
// based on the promoted method, not the shadowed method. |
| 10 |
|
| 11 |
package main |
| 12 |
|
| 13 |
import ( |
| 14 |
"bytes" |
| 15 |
"fmt" |
| 16 |
) |
| 17 |
|
| 18 |
type mystruct struct { |
| 19 |
f int |
| 20 |
} |
| 21 |
|
| 22 |
func (t mystruct) String() string { |
| 23 |
return "FAIL" |
| 24 |
} |
| 25 |
|
| 26 |
func main() { |
| 27 |
type deep struct { |
| 28 |
mystruct |
| 29 |
} |
| 30 |
s := struct { |
| 31 |
deep |
| 32 |
*bytes.Buffer |
| 33 |
}{ |
| 34 |
deep{}, |
| 35 |
bytes.NewBufferString("ok"), |
| 36 |
} |
| 37 |
|
| 38 |
if got := s.String(); got != "ok" { |
| 39 |
panic(got) |
| 40 |
} |
| 41 |
|
| 42 |
var i fmt.Stringer = s |
| 43 |
if got := i.String(); got != "ok" { |
| 44 |
panic(got) |
| 45 |
} |
| 46 |
} |