Source file src/cmd/link/internal/ld/testdata/deadcode/methexpr_static.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 as an element of a statically initialized package
     6  // table 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  var table = [...]func(reflect.Value, string) reflect.Value{reflect.Value.MethodByName}
    20  
    21  func main() { table[0](reflect.ValueOf(T(1)), os.Args[0]).Call(nil) }
    22  

View as plain text