blob: b423a59f77e34b54b39563292fd5bec88c6ae8c8 [file] [log] [blame]
David Crawshawcc158402016-03-10 16:15:26 -05001// run
2
3// Copyright 2016 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// The linker can prune methods that are not directly called or
8// assigned to interfaces, but only if reflect.Type.Method is
9// never used. Test it here.
10
11package main
12
13import "reflect"
14
15var called = false
16
17type M int
18
19func (m M) UniqueMethodName() {
20 called = true
21}
22
23var v M
24
25type MyType interface {
26 Method(int) reflect.Method
27}
28
29func main() {
30 var t MyType = reflect.TypeOf(v)
31 t.Method(0).Func.Interface().(func(M))(v)
32 if !called {
33 panic("UniqueMethodName not called")
34 }
35}