Source file test/abi/method_wrapper.go

     1  // run
     2  
     3  // Copyright 2021 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  package main
     8  
     9  type S int
    10  
    11  type T struct {
    12  	a int
    13  	S
    14  }
    15  
    16  //go:noinline
    17  func (s *S) M(a int, x [2]int, b float64, y [2]float64) (S, int, [2]int, float64, [2]float64) {
    18  	return *s, a, x, b, y
    19  }
    20  
    21  var s S = 42
    22  var t = &T{S: s}
    23  
    24  var fn = (*T).M // force a method wrapper
    25  
    26  func main() {
    27  	a := 123
    28  	x := [2]int{456, 789}
    29  	b := 1.2
    30  	y := [2]float64{3.4, 5.6}
    31  	s1, a1, x1, b1, y1 := fn(t, a, x, b, y)
    32  	if a1 != a || x1 != x || b1 != b || y1 != y || s1 != s {
    33  		panic("FAIL")
    34  	}
    35  }
    36  

View as plain text