Skip to content

Commit

Permalink
fix: handle custom local names for widened types
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Aug 16, 2024
1 parent f661854 commit e879b00
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions go-runtime/schema/typealias/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,14 @@ func qualifiedNameFromSelectorExpr(pass *analysis.Pass, node ast.Node) string {
if !ok {
return ""
}
for _, im := range pass.Pkg.Imports() {
if im.Name() != ident.Name {
continue
}
fqName := im.Path()
if parts := strings.Split(im.Path(), "/"); parts[len(parts)-1] != ident.Name {
// if package differs from the directory name, add the package name to the fqName
fqName = fqName + "." + ident.Name
}
return fqName + "." + se.Sel.Name
pkgName, ok := pass.TypesInfo.ObjectOf(ident).(*types.PkgName)
if !ok {
return ""
}
fqName := pkgName.Imported().Path()
if parts := strings.Split(fqName, "/"); parts[len(parts)-1] != pkgName.Imported().Name() {
// if package differs from the directory name, add the package name to the fqName
fqName = fqName + "." + ident.Name
}
return ""
return fqName + "." + se.Sel.Name
}

0 comments on commit e879b00

Please sign in to comment.