diff --git a/src/go/go2go/rewrite.go b/src/go/go2go/rewrite.go index b84ffd0adc..3f34eb1a8c 100644 --- a/src/go/go2go/rewrite.go +++ b/src/go/go2go/rewrite.go @@ -25,7 +25,7 @@ var config = printer.Config{ // isParameterizedFuncDecl reports whether fd is a parameterized function. func isParameterizedFuncDecl(fd *ast.FuncDecl, info *types.Info) bool { - if fd.Type.TParams != nil { + if fd.Type.TParams != nil && len(fd.Type.TParams.List) > 0 { return true } if fd.Recv != nil { @@ -64,7 +64,7 @@ func isTranslatableType(s ast.Spec, info *types.Info) bool { // isParameterizedTypeDecl reports whether s is a parameterized type. func isParameterizedTypeDecl(s ast.Spec, info *types.Info) bool { ts := s.(*ast.TypeSpec) - if ts.TParams != nil { + if ts.TParams != nil && len(ts.TParams.List) > 0 { return true } if ts.Assign == token.NoPos { @@ -523,7 +523,7 @@ func (t *translator) translateFuncDecl(pd *ast.Decl) { return } fd := (*pd).(*ast.FuncDecl) - if fd.Type.TParams != nil { + if fd.Type.TParams != nil && len(fd.Type.TParams.List) > 0 { panic("parameterized function") } if fd.Recv != nil { diff --git a/test/gen/g041.go2 b/test/gen/g041.go2 new file mode 100644 index 0000000000..0315f0cc72 --- /dev/null +++ b/test/gen/g041.go2 @@ -0,0 +1,12 @@ +// compile + +// 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. + +// Issue 40015. +package p + +func F1(type)(s []int) {} + +func F2() { F1([]int{1, 2}) }