Skip to content

go/internal/srcimporter: src importer cannot handle re-import #19337

Open
@griesemer

Description

@griesemer

The existing importers go out of their way to augment partially imported packages (types, etc.).

A source importer doesn't do that - it uses go/types to always create a new package. If only the source importer is used, then (recursively), any package that is imported somewhere is imported as a whole, so all packages are complete upon import and there's never a need to augment a package.

If we want to provide a "mixed-mode" importer, where some packages are imported from installed packages, and some from source, depending on which is newer, the above is not so simple anymore: A package may be imported from an installed location, which in turn may contain partial package information about another package.

If that other package is imported from source, it must augment the partial package in the packages map rather than replace it.

This matters only for types since they are the only objects that may be used in the construction of other package-level objects - they must be unique.

One could expand the go/types API and provide a partially complete package that is then expanded. Or one could do a "full" import and then somehow merge the new with the old package (and update any types that need to be canonicalized - a tricky proposition).

Or one could disallow "mixed-mode" imports (currently they are not supported anyway).

Needs to be resolved before we can implement mixed-mode imports.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions