Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ type Checker struct {
mappedSymbolLinks core.LinkStore[*ast.Symbol, MappedSymbolLinks]
deferredSymbolLinks core.LinkStore[*ast.Symbol, DeferredSymbolLinks]
aliasSymbolLinks core.LinkStore[*ast.Symbol, AliasSymbolLinks]
aliasCandidatesByExportedTarget map[*ast.Symbol]map[*ast.Symbol][]*ast.Symbol
moduleSymbolLinks core.LinkStore[*ast.Symbol, ModuleSymbolLinks]
lateBoundLinks core.LinkStore[*ast.Symbol, LateBoundLinks]
exportTypeLinks core.LinkStore[*ast.Symbol, ExportTypeLinks]
Expand Down
30 changes: 25 additions & 5 deletions internal/checker/symbolaccessibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,34 @@ func (c *Checker) getAliasForSymbolInContainer(container *ast.Symbol, symbol *as
if ok && quick != nil && c.getSymbolIfSameReference(quick, symbol) != nil {
return quick
}
var candidates []*ast.Symbol
for _, exported := range exports {
if c.getSymbolIfSameReference(exported, symbol) != nil {
candidates = append(candidates, exported)

target := c.getMergedSymbol(c.resolveSymbol(c.getMergedSymbol(symbol)))
if c.aliasCandidatesByExportedTarget != nil {
if candidatesByTarget, ok := c.aliasCandidatesByExportedTarget[container]; ok {
candidates := candidatesByTarget[target]
if len(candidates) > 0 {
if len(candidates) > 1 {
c.sortSymbols(candidates) // _must_ sort exports for stable results - symbol table is randomly iterated
}
return candidates[0]
}
return nil
}
} else {
c.aliasCandidatesByExportedTarget = make(map[*ast.Symbol]map[*ast.Symbol][]*ast.Symbol)
}

candidatesByTarget := make(map[*ast.Symbol][]*ast.Symbol, len(exports))
for _, exported := range exports {
exportedTarget := c.getMergedSymbol(c.resolveSymbol(c.getMergedSymbol(exported)))
candidatesByTarget[exportedTarget] = append(candidatesByTarget[exportedTarget], exported)
}
c.aliasCandidatesByExportedTarget[container] = candidatesByTarget
Comment on lines +361 to +382
candidates := candidatesByTarget[target]
if len(candidates) > 0 {
c.sortSymbols(candidates) // _must_ sort exports for stable results - symbol table is randomly iterated
if len(candidates) > 1 {
c.sortSymbols(candidates) // _must_ sort exports for stable results - symbol table is randomly iterated
}
return candidates[0]
}
return nil
Expand Down
Loading