Skip to content

x/tools/go/types: need a generalization of the Type.String method and TypeString function #11133

Closed
@adonovan

Description

@adonovan

The Type.String method and TypeString function are thin wrappers around a complex set of pretty-printing functions. Object.String and ObjectString are part of the same strongly connected component.

These functions are useful, but some clients need variants that differ in their treatment of named types. For example, when printing results about a particular place in a program, it's best to use the locally appropriate name for each imported package, as determined by the ast.File Scope.

If we changed TypeString and ObjectString so that they accept a func(*Named)string parameter that formats the named types, then all three of these variants could be easily expressed, and any future ones too.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions