Skip to content

Preserve aliased imports when parsing embedded interface packages - #311

Open
hdimer wants to merge 1 commit into
uber-go:mainfrom
hdimer:fix/254-aliased-imports
Open

Preserve aliased imports when parsing embedded interface packages#311
hdimer wants to merge 1 commit into
uber-go:mainfrom
hdimer:fix/254-aliased-imports

Conversation

@hdimer

@hdimer hdimer commented Jul 30, 2026

Copy link
Copy Markdown

Fixes #254.

In source mode, parsePackage collected an imported package's imports from ast.MergePackageFiles(..., FilterImportDuplicates). That filter dedupes imports by path, so when one file imports a package plainly and another file aliases it, the alias is dropped and later references fail with unknown package "<alias>".

Read imports from each file instead of the merged file so aliases survive. Interface discovery still uses the merged file. Added a regression test (aliased_embedded_interface fixture) reproducing the reported failure.

Used AI assistance on this; I reviewed and tested it.

In source mode, parsePackage collected an imported package's imports from
ast.MergePackageFiles(..., FilterImportDuplicates). That filter dedupes
imports by path, so when one file imports a package plainly and another
file aliases it, the alias is dropped and later references to it fail with
"unknown package".

Read imports from each file instead of the merged file so aliases survive.
Interface discovery still uses the merged file.

Fixes uber-go#254
@CLAassistant

CLAassistant commented Jul 30, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Load input failed: unknown package error with aliased imports

2 participants