[dev.go2go] go/go2go: F(type)() is not a parameterized function

Fixes #40015

Change-Id: I4e70398e693a53268d3400e829a179c76ff70e75
Reviewed-on: https://go-review.googlesource.com/c/go/+/241124
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Ian Lance Taylor 2020-07-06 16:17:08 -07:00
parent c583a5d512
commit b97f992a7e
2 changed files with 15 additions and 3 deletions

View File

@ -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 {

12
test/gen/g041.go2 Normal file
View File

@ -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}) }