fix: make reftype func variadic

This commit is contained in:
Nicholas Wiersma
2020-06-22 13:38:04 +02:00
committed by GitHub
parent 7cfa264dbc
commit e00b853971
2 changed files with 20 additions and 1 deletions

17
_test/variadic8.go Normal file
View File

@@ -0,0 +1,17 @@
package main
import (
"fmt"
"time"
)
func main() {
fn1 := func(args ...*time.Duration) string {
return ""
}
fmt.Printf("%T\n", fn1)
}
// Output:
// func(...*time.Duration) string

View File

@@ -1181,15 +1181,17 @@ func (t *itype) refType(defined map[string]*itype, wrapRecursive bool) reflect.T
if t.name != "" {
defined[name] = t
}
variadic := false
in := make([]reflect.Type, len(t.arg))
out := make([]reflect.Type, len(t.ret))
for i, v := range t.arg {
in[i] = v.refType(defined, true)
variadic = v.cat == variadicT
}
for i, v := range t.ret {
out[i] = v.refType(defined, true)
}
t.rtype = reflect.FuncOf(in, out, false)
t.rtype = reflect.FuncOf(in, out, variadic)
case interfaceT:
t.rtype = interf
case mapT: