1// Copyright 2020 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// Like ifacemethod2.go, this tests that a method *is* live 6// if the type is "indirectly" converted to an interface 7// using reflection with a method descriptor as intermediate. 8 9package main 10 11import "reflect" 12 13type S int 14 15func (s S) M() { println("S.M") } 16 17type I interface{ M() } 18 19type T float64 20 21func (t T) F(s S) {} 22 23func main() { 24 var t T 25 ft := reflect.TypeOf(t).Method(0).Type 26 at := ft.In(1) 27 v := reflect.New(at).Elem() 28 v.Interface().(I).M() 29} 30