Source file test/reflectmethod5.go

     1  // run
     2  
     3  // Copyright 2020 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  // Issue 38515: failed to mark the method wrapper
     8  // reflect.Type.Method itself as REFLECTMETHOD.
     9  
    10  package main
    11  
    12  import "reflect"
    13  
    14  var called bool
    15  
    16  type foo struct{}
    17  
    18  func (foo) X() { called = true }
    19  
    20  var h = reflect.Type.Method
    21  
    22  func main() {
    23  	v := reflect.ValueOf(foo{})
    24  	m := h(v.Type(), 0)
    25  	f := m.Func.Interface().(func(foo))
    26  	f(foo{})
    27  	if !called {
    28  		panic("FAIL")
    29  	}
    30  }
    31  

View as plain text