Skip to content

Commit 7841afd

Browse files
committed
fix(go): incorrect id for dot-imported symbols
1 parent e8eef7f commit 7841afd

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lang/golang/parser/file.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,15 @@ func (p *GoParser) parseASTNode(ctx *fileContext, node ast.Node, collect *collec
394394
// return false
395395
// }
396396
if use, ok := ctx.pkgTypeInfo.Uses[expr]; ok {
397-
id := NewIdentity(ctx.module.Name, ctx.pkgPath, callName)
397+
pkg := use.Pkg()
398+
if pkg == nil {
399+
return true
400+
}
401+
mod, err := ctx.GetMod(pkg.Path())
402+
if err != nil {
403+
return true
404+
}
405+
id := NewIdentity(mod, pkg.Path(), use.Name())
398406
dep := NewDependency(id, ctx.FileLine(expr))
399407
// type name
400408
if _, isNamed := use.(*types.TypeName); isNamed {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package pkg
2+
3+
import . "a.b/c/pkg/entity"
4+
5+
var G2 = G1
6+
7+
var I1 Integer
8+
9+
type S MyStructD
10+
11+
func CaseMergeRef() MyStruct {
12+
_ = G1 + G2
13+
return MyStruct{
14+
MyStructD: MyStructD{},
15+
}
16+
}

0 commit comments

Comments
 (0)