github.com/goplus/gogen@v1.16.0/internal/go/printer/typeparams_go118.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 package printer 5 6 import ( 7 "go/ast" 8 "go/token" 9 ) 10 11 // IndexListExpr is an alias for ast.IndexListExpr. 12 type IndexListExpr = ast.IndexListExpr 13 14 func (p *printer) signature(sig *ast.FuncType) { 15 if sig.TypeParams != nil { 16 p.parameters(sig.TypeParams, funcTParam) 17 } 18 if sig.Params != nil { 19 p.parameters(sig.Params, funcParam) 20 } else { 21 p.print(token.LPAREN, token.RPAREN) 22 } 23 res := sig.Results 24 n := res.NumFields() 25 if n > 0 { 26 // res != nil 27 p.print(blank) 28 if n == 1 && res.List[0].Names == nil { 29 // single anonymous res; no ()'s 30 p.expr(stripParensAlways(res.List[0].Type)) 31 return 32 } 33 p.parameters(res, funcParam) 34 } 35 } 36 37 const TILDE = token.TILDE 38 39 func specTypeParams(spec *ast.TypeSpec) *ast.FieldList { 40 return spec.TypeParams 41 }