golang/go

x/tools/internal/typesinternal: FileQualifier needs to add imports, and reject unnameable types

Open

#75604 opened on Sep 25, 2025

View on GitHub
 (8 comments) (0 reactions) (1 assignee)Go (133,883 stars) (19,008 forks)batch import
NeedsFixRefactoringToolshelp wanted

Description

The job of FileQualifier is to help TypeString print types in valid Go syntax, respecting the local lexical environment and the file's set of existing imports. However, in general this may require (a) adding new imports for types belonging to packages that are not currently imported and (b) reporting that the task cannot be completed because one or more types are members of another package and are inaccessible either because they are unexported or because that package is internal relative to this one.

The task of this issue is to augment FileQualifier to accumulate a list of import edits, and an error when it sees a type it cannot print. This should fix a number of bugs across all our refactoring tools. It could also use some good tests.

Contributor guide