mirror of https://github.com/golang/go.git
[dev.go2go] go/go2go: don't crash on an unnamed receiver
Fixes #39707 Change-Id: I20e5fe2990ceda5429f1a22edf48494d2c6496a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/239159 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
cab5f803e8
commit
ccaf3f5560
|
|
@ -197,16 +197,18 @@ func (t *translator) instantiateTypeDecl(qid qualifiedIdent, typ *types.Named, a
|
|||
}
|
||||
tparams := rtyp.(*ast.CallExpr).Args
|
||||
ta := typeArgsFromExprs(t, astTypes, typeTypes, tparams)
|
||||
var names []*ast.Ident
|
||||
if mnames := mast.Recv.List[0].Names; len(mnames) > 0 {
|
||||
names = []*ast.Ident{mnames[0]}
|
||||
}
|
||||
newDecl := &ast.FuncDecl{
|
||||
Doc: mast.Doc,
|
||||
Recv: &ast.FieldList{
|
||||
Opening: mast.Recv.Opening,
|
||||
List: []*ast.Field{
|
||||
{
|
||||
Doc: mast.Recv.List[0].Doc,
|
||||
Names: []*ast.Ident{
|
||||
mast.Recv.List[0].Names[0],
|
||||
},
|
||||
Doc: mast.Recv.List[0].Doc,
|
||||
Names: names,
|
||||
Type: newRtype,
|
||||
Comment: mast.Recv.List[0].Comment,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
// 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 39688.
|
||||
package p
|
||||
|
||||
type S(type T) T
|
||||
|
||||
func (*S(T)) M() {}
|
||||
|
||||
var V S(int)
|
||||
Loading…
Reference in New Issue