internal/lsp: fix crash when there is a type alias to a struct in the symbols code
Change-Id: If492a88c9f80003d7102b4f517621e52cc15759f Reviewed-on: https://go-review.googlesource.com/c/tools/+/171861 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
2e9de471eb
commit
9c9e1878f4
|
@ -173,8 +173,9 @@ func typeSymbol(spec *ast.TypeSpec, obj types.Object, fset *token.FileSet, q typ
|
||||||
s.SelectionSpan = span
|
s.SelectionSpan = span
|
||||||
}
|
}
|
||||||
|
|
||||||
if t, ok := obj.Type().Underlying().(*types.Struct); ok {
|
t, objIsStruct := obj.Type().Underlying().(*types.Struct)
|
||||||
st := spec.Type.(*ast.StructType)
|
st, specIsStruct := spec.Type.(*ast.StructType)
|
||||||
|
if objIsStruct && specIsStruct {
|
||||||
for i := 0; i < t.NumFields(); i++ {
|
for i := 0; i < t.NumFields(); i++ {
|
||||||
f := t.Field(i)
|
f := t.Field(i)
|
||||||
child := Symbol{Name: f.Name(), Kind: FieldSymbol}
|
child := Symbol{Name: f.Name(), Kind: FieldSymbol}
|
||||||
|
|
Loading…
Reference in New Issue