Skip to content

go/types: add Func.Signature method #65772

Closed
@adonovan

Description

@adonovan

Proposal Details

The expression f.Type().(*types.Signature), where f is a *types.Func, appears over a hundred times in x/tools. Each time I read it, I am momentarily compelled to prove a little theorem that the type assertion is sound.

For brevity, convenience, and simplicity, I propose that we add this method to go/types:

// Signature returns the signature (type) of the function or method.
func (f *Func) Signature() *Signature {
    return f.Type().(*types.Signature)
}

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions