mirror of
https://github.com/burrowers/garble.git
synced 2025-12-24 12:58:05 +08:00
start using go/types.Func.Signature
Guaranteed to return a *types.Signature, so no need to type assert.
This commit is contained in:
@@ -174,7 +174,7 @@ func isGenericType(p types.Type) bool {
|
||||
|
||||
// isSupportedSig checks that the function is not generic and all parameters can be generated using valueGenerators
|
||||
func isSupportedSig(m *types.Func) bool {
|
||||
sig := m.Type().(*types.Signature)
|
||||
sig := m.Signature()
|
||||
if isGenericType(sig) {
|
||||
return false
|
||||
}
|
||||
@@ -430,7 +430,7 @@ func (t *trashGenerator) generateCall(vars map[string]*definedVar) ast.Stmt {
|
||||
|
||||
var args []ast.Expr
|
||||
|
||||
targetSig := targetFunc.Type().(*types.Signature)
|
||||
targetSig := targetFunc.Signature()
|
||||
params := targetSig.Params()
|
||||
for i := 0; i < params.Len(); i++ {
|
||||
param := params.At(i)
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestConvertSignature(t *testing.T) {
|
||||
funcDecl.Body = nil
|
||||
|
||||
funcObj := info.Defs[funcDecl.Name].(*types.Func)
|
||||
funcDeclConverted, err := conv.convertSignatureToFuncDecl(funcObj.Name(), funcObj.Type().(*types.Signature))
|
||||
funcDeclConverted, err := conv.convertSignatureToFuncDecl(funcObj.Name(), funcObj.Signature())
|
||||
qt.Assert(t, qt.IsNil(err))
|
||||
qt.Assert(t, qt.CmpEquals(funcDeclConverted, funcDecl, astCmpOpt))
|
||||
}
|
||||
|
||||
2
main.go
2
main.go
@@ -1966,7 +1966,7 @@ func (tf *transformer) transformGoFile(file *ast.File) *ast.File {
|
||||
return true
|
||||
}
|
||||
|
||||
sign := obj.Type().(*types.Signature)
|
||||
sign := obj.Signature()
|
||||
if sign.Recv() == nil {
|
||||
debugName = "func"
|
||||
} else {
|
||||
|
||||
@@ -145,7 +145,7 @@ func (ri *reflectInspector) checkInterfaceMethod(m *types.Func) {
|
||||
|
||||
maps.Copy(reflectParams, ri.result.ReflectAPIs[m.FullName()])
|
||||
|
||||
sig := m.Type().(*types.Signature)
|
||||
sig := m.Signature()
|
||||
if m.Exported() {
|
||||
ri.checkMethodSignature(reflectParams, sig)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user