Source file test/tailcall.go
1 // errorcheck -0 -d=tailcall=1 2 3 // Copyright 2024 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 p 8 9 // Test that when generating wrappers for methods, we generate a tail call to the pointer version of 10 // the method. 11 12 func (f *Foo) Get2Vals() [2]int { return [2]int{f.Val, f.Val + 1} } 13 func (f *Foo) Get3Vals() (int, int, int) { return f.Val, f.Val + 1, f.Val + 2 } 14 15 type Foo struct{ Val int } 16 17 type Bar struct { // ERROR "tail call emitted for the method \(\*Foo\).Get2Vals wrapper" "tail call emitted for the method \(\*Foo\).Get3Vals wrapper" 18 int64 19 *Foo // needs a method wrapper 20 string 21 } 22 23 var i any 24 25 func init() { 26 i = Bar{1, nil, "first"} 27 } 28