1// Copyright 2023 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// This test only uses MethodByName() with constant names 6// of methods to look up. These methods need to be kept, 7// but other methods must be eliminated. 8 9package main 10 11import "reflect" 12 13type S int 14 15func (s S) M() { println("S.M") } 16 17func (s S) N() { println("S.N") } 18 19type T float64 20 21func (t T) F(s S) {} 22 23func main() { 24 var t T 25 meth, _ := reflect.TypeOf(t).MethodByName("F") 26 ft := meth.Type 27 at := ft.In(1) 28 v := reflect.New(at).Elem() 29 methV := v.MethodByName("M") 30 methV.Call([]reflect.Value{v}) 31} 32