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 11package main 12 13import ( 14 "bytes" 15 "fmt" 16) 17 18type mystruct struct { 19 f int 20} 21 22func (t mystruct) String() string { 23 return "FAIL" 24} 25 26func 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} 47