diff --git a/src/go/go2go/rewrite.go b/src/go/go2go/rewrite.go index 546bb582a8..b7119486d6 100644 --- a/src/go/go2go/rewrite.go +++ b/src/go/go2go/rewrite.go @@ -581,6 +581,7 @@ func (t *translator) translateExpr(pe *ast.Expr) { t.translateExpr(&e.Key) t.translateExpr(&e.Value) case *ast.ArrayType: + t.translateExpr(&e.Len) t.translateExpr(&e.Elt) case *ast.StructType: t.translateFieldList(e.Fields) @@ -931,7 +932,7 @@ func (t *translator) typeWithoutArgs(typ *types.Named) *types.Named { func (t *translator) typeListToASTList(typeList []types.Type) ([]types.Type, []ast.Expr) { argList := make([]ast.Expr, 0, len(typeList)) for _, typ := range typeList { - arg := ast.NewIdent(typ.String()) + arg := ast.NewIdent(types.TypeString(typ, types.RelativeTo(t.tpkg))) if named, ok := typ.(*types.Named); ok { if len(named.TArgs()) > 0 { var narg *ast.Ident @@ -943,12 +944,6 @@ func (t *translator) typeListToASTList(typeList []types.Type) ([]types.Type, []a arg = ast.NewIdent(narg.Name) } } - if named.Obj().Pkg() == t.tpkg { - fields := strings.Split(arg.Name, ".") - if len(fields) > 1 { - arg = ast.NewIdent(fields[1]) - } - } } argList = append(argList, arg) t.setType(arg, typ) diff --git a/test/gen/g017.go2 b/test/gen/g017.go2 new file mode 100644 index 0000000000..59a020d079 --- /dev/null +++ b/test/gen/g017.go2 @@ -0,0 +1,24 @@ +// run + +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +type Recv <-chan int + +type sliceOf(type E) interface { + type []E +} + +func Append(type S sliceOf(T), T interface{})(s S, t ...T) S { + return append(s, t...) +} + +func main() { + a := Append([]Recv{nil}, Recv(nil)) + if len(a) != 2 || a[0] != nil || a[1] != nil { + panic(a) + } +}