1 // compile 2 3 // Copyright 2013 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 // Issue 5231: method values lose their variadic property. 8 9 package p 10 11 type T int 12 13 func (t T) NotVariadic(s []int) int { 14 return int(t) + s[0] 15 } 16 17 func (t T) Variadic(s ...int) int { 18 return int(t) + s[0] 19 } 20 21 type I interface { 22 NotVariadic(s []int) int 23 Variadic(s ...int) int 24 } 25 26 func F() { 27 var t T 28 var p *T = &t 29 var i I = p 30 31 nv := t.NotVariadic 32 nv = p.NotVariadic 33 nv = i.NotVariadic 34 var s int = nv([]int{1, 2, 3}) 35 36 v := t.Variadic 37 v = p.Variadic 38 v = i.Variadic 39 s = v(1, 2, 3) 40 41 var f1 func([]int) int = nv 42 var f2 func(...int) int = v 43 44 _, _, _ = f1, f2, s 45 } 46