Source file src/cmd/link/internal/ld/testdata/deadcode/methexpr_local.go

     1  // Copyright 2026 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  // reflect.Value.MethodByName used as a function value in a local variable and
     6  // called with a name the linker cannot see must keep all exported methods.
     7  
     8  package main
     9  
    10  import (
    11  	"os"
    12  	"reflect"
    13  )
    14  
    15  type T int
    16  
    17  func (T) M() {}
    18  
    19  func main() {
    20  	f := reflect.Value.MethodByName
    21  	f(reflect.ValueOf(T(1)), os.Args[0]).Call(nil)
    22  }
    23  

View as plain text