...

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

Documentation: cmd/link/internal/ld/testdata/deadcode

     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  // Test that a method *is* live if it matches an interface
     6  // method and the type is "indirectly" converted to an
     7  // interface through reflection.
     8  
     9  package main
    10  
    11  import "reflect"
    12  
    13  type I interface{ M() }
    14  
    15  type T int
    16  
    17  func (T) M() { println("XXX") }
    18  
    19  func main() {
    20  	e := reflect.ValueOf([]T{1}).Index(0).Interface()
    21  	e.(I).M()
    22  }
    23  

View as plain text