diff --git a/importer/pkginfo.go b/importer/pkginfo.go index 12aac26b8f..a78ece5b6a 100644 --- a/importer/pkginfo.go +++ b/importer/pkginfo.go @@ -158,12 +158,12 @@ func (info *PackageInfo) BuiltinCallSignature(e *ast.CallExpr) *types.Signature var t0, t1 types.Type t0 = info.TypeOf(e) // infer arg[0] type from result type if e.Ellipsis != 0 { - // append([]T, []T) []T - // append([]byte, string) []byte + // append(tslice, tslice...) []T + // append(byteslice, "foo"...) []byte t1 = info.TypeOf(e.Args[1]) // no conversion } else { - // append([]T, ...T) []T - t1 = t0.Underlying().(*types.Slice).Elem() + // append([]T, x, y, z) []T + t1 = t0.Underlying() isVariadic = true } params = append(params, @@ -175,7 +175,7 @@ func (info *PackageInfo) BuiltinCallSignature(e *ast.CallExpr) *types.Signature // Note, arg0 may have any type, not necessarily tEface. params = append(params, types.NewVar(token.NoPos, nil, "", info.TypeOf(e.Args[0])), - types.NewVar(token.NoPos, nil, "", tEface)) + types.NewVar(token.NoPos, nil, "", types.NewSlice(tEface))) case "close": params = append(params, types.NewVar(token.NoPos, nil, "", info.TypeOf(e.Args[0]))) diff --git a/ssa/builder.go b/ssa/builder.go index 286c006b5d..0993433ab0 100644 --- a/ssa/builder.go +++ b/ssa/builder.go @@ -893,13 +893,8 @@ func (b *builder) emitCallArgs(fn *Function, sig *types.Signature, e *ast.CallEx // f(x, y, z...): pass slice z straight through. if e.Ellipsis != 0 { for i, arg := range e.Args { - // TODO(gri): annoyingly Signature.Params doesn't - // reflect the slice type for a final ...T param. - t := sig.Params().At(i).Type() - if sig.IsVariadic() && i == len(e.Args)-1 { - t = types.NewSlice(t) - } - args = append(args, emitConv(fn, b.expr(fn, arg), t)) + v := emitConv(fn, b.expr(fn, arg), sig.Params().At(i).Type()) + args = append(args, v) } return args } @@ -935,8 +930,8 @@ func (b *builder) emitCallArgs(fn *Function, sig *types.Signature, e *ast.CallEx // and construction of slice. if sig.IsVariadic() { varargs := args[offset+np:] - vt := sig.Params().At(np).Type() - st := types.NewSlice(vt) + st := sig.Params().At(np).Type().(*types.Slice) + vt := st.Elem() if len(varargs) == 0 { args = append(args, nilLiteral(st)) } else {